Forum Discussion

jabelli's avatar
jabelli
New Contributor
2 months ago

Cookie Authentication used to work

Hi, I recently tried to use the latest generator (7.11) and I can't get cookie auth to work, because I get the following error:

<b>Fatal error</b>:  Uncaught InvalidArgumentException: Authenticator option has not been setted. in C:\MyApp\json\vendor\dyorg\slim-token-authentication\src\TokenAuthentication.php:52
Stack trace:
#0 C:\MyApp\json\lib\App\RegisterRoutes.php(9021): Dyorg\TokenAuthentication-&gt;__construct(Array)
#1 C:\MyApp\json\public\index.php(85): OpenAPIServer\App\RegisterRoutes-&gt;__invoke(Object(Slim\App))
#2 {main}
  thrown in <b>C:\MyApp\json\vendor\dyorg\slim-token-authentication\src\TokenAuthentication.php</b> on line <b>52</b><br />

With old generator versions (5.x) it used to work. Am I doing something wrong?

openapi: 3.0.3
info:
  title: MyApp
  version: 1.0.0
  contact:
    name: Me
servers:
  - url: /json
paths:
  /log_in:
    post:
      summary: Logs in and returns PHP session ID. This must be passed back on subsequent requests, and is regenerated every request. The dafault lifetime is 10 minutes.
      operationId: logIn
      requestBody:
        required: true
        description: json object containing the credentials 'login' and 'pass'
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LogInReq'
      security: []
      responses:
        '200':
          description: An Acknowledgement object. If the result is TRUE the message contains the roles assigned to the user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Acknowledgement'
          headers: 
           Set-Cookie:
             schema: 
               type: string
               example: slim_session=u3scl3uu7nfj4av5q5lu1oafrocu6t6vdtdlvc9gc33upimi05s0; path=/; HttpOnly
        '401':
          description: Incorrect user name or password
        '500':
          description: Other error
  /log_out:
    get:
      summary: Logs the user out & invalidates the PHP session. No login need be specified as it is retrieved from the session.
      operationId: logOut
      responses:
        '200':
          description: An Acknowledgement object.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Acknowledgement'
          headers: 
           Set-Cookie:
             schema: 
               type: string
               example: slim_session=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; httponly
        '401':
          description: User is not logged in or session has expired.
        '500':
          description: Other error
      security:
        - cookieAuth: []
components:
  schemas:
    LogInReq:
      type: object
      required:
        - login
        - pass
      properties:
        login:
          type: string
        pass:
          type: string
    Acknowledgement:
      type: object
      properties:
        message:
          type: string
  securitySchemes:
    cookieAuth:
      type: apiKey
      in: cookie
      name: slim_session