openapi: "3.0.3"
info:
  description: "Service for User Authentication"
  version: "1.0.0"
  title: "Authentication Service"
tags:
  - name: "Auth"
    description: "Authentication Routes"
paths:
  /refresh:
    post:
      tags:
        - "Auth"
      summary: "Refresh Assess Token"
      responses:
        "200":
          description: "Success"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Token'
        "401":
          description: "Unauthorized"
        "403":
          description: "Forbidden"
        "500":
          description: "Internal Server Error"
      security:
        - bearerAuth: []
  /logout:
    post:
      tags:
        - "Auth"
      summary: "Logout a User by deleting browser cookies"
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Refresh'
      responses:
        "200":
          description: "Success"
        "400":
          description: "BadRequest"
  /authzero:
    post:
      tags:
        - "Auth"
      summary: "Login from Auth0 using username/password for first authentication"
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Credentials'
      responses:
        "200":
          description: "Success"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MemberData'
        "401":
          description: "Unauthorized"
        "500":
          description: "Internal Server Error"
  /authtokenhandler:
    post:
      tags:
        - "Auth"
      summary: "Gets an authenticated user's access and refresh tokens"
      responses:
        "200":
          description: "Success"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Token'
        "401":
          description: "Unauthorized"
        "500":
          description: "Internal Server Error"
      security:
        - bearerAuth: [ ]
  /emailcheck:
    post:
      tags:
        - "Auth"
      summary: "Checks to see if email is valid for a user"
      responses:
        "200":
          description: "Success"
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MemberData'
        "401":
          description: "Unauthorized"
        "500":
          description: "Internal Server Error"
      security:
        - apiKey: [ ]
components:
  schemas:
    Credentials:
      type: object
      properties:
        username:
          type: string
        password:
          type: string
      required:
        - username
        - password
    Refresh:
      type: object
      properties:
        tokenId:
          type: string
    Token:
      type: object
      properties:
        id_token:
          type: string
        assess_token:
          type: string
        refresh_token:
          type: string
    MemberData:
      type: object
      properties:
        memberId:
          type: integer
        username:
          type: string
        email:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    apiKey:
      type: apiKey
      name: x-api-key
      in: header
