openapi: 3.1.0
info:
  title: AuthAPI
  description: A microservice to generate downloadable exports for charts and dashboards.
  version: 0.1.0
paths:
  /auth/health:
    get:
      tags:
        - Utility
      summary: Health check endpoint
      operationId: health_check_auth_health_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
  /auth/login:
    post:
      tags:
        - Authentication
      summary: Login For Access Token
      description: '**Authenticates a user and returns an access token (JWT).**'
      operationId: login_for_access_token_auth_login_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoginRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TokenResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
  /auth/me:
    get:
      tags:
        - Authentication
      summary: Read User Profile
      description: >-
        **Returns the profile and entitlements for the currently authenticated
        user.**


        Requires a valid JWT in the Authorization header.
      operationId: read_user_profile_auth_me_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserProfile'
      security:
        - HTTPBearer: []
  /auth/roles:
    get:
      tags:
        - Authentication
      summary: Get All Roles
      description: >-
        **Returns a list of all defined roles and their associated
        permissions.**
      operationId: get_all_roles_auth_roles_get
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                items:
                  $ref: '#/components/schemas/RoleDetail'
                type: array
                title: Response Get All Roles Auth Roles Get
      security:
        - HTTPBearer: []
components:
  schemas:
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    LoginRequest:
      properties:
        username:
          type: string
          title: Username
          example: john.doe
        password:
          type: string
          title: Password
          example: secure_password_123
      type: object
      required:
        - username
        - password
      title: LoginRequest
    RoleDetail:
      properties:
        role_name:
          type: string
          title: Role Name
          example: admin
        description:
          type: string
          title: Description
          example: Full access to all systems.
        permissions:
          items:
            type: string
          type: array
          title: Permissions
          example:
            - users:manage
            - reports:view_all
            - exports:*
      type: object
      required:
        - role_name
        - description
        - permissions
      title: RoleDetail
    TokenResponse:
      properties:
        access_token:
          type: string
          title: Access Token
          example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
        token_type:
          type: string
          title: Token Type
          default: bearer
          example: bearer
      type: object
      required:
        - access_token
      title: TokenResponse
    UserProfile:
      properties:
        user_id:
          type: string
          title: User Id
          example: u4567
        username:
          type: string
          title: Username
          example: john.doe
        email:
          type: string
          title: Email
          example: john.doe@company.com
        full_name:
          type: string
          title: Full Name
          example: John Doe
        is_active:
          type: boolean
          title: Is Active
          default: true
        roles:
          items:
            type: string
          type: array
          title: Roles
          example:
            - admin
            - editor
        entitlements:
          items:
            type: string
          type: array
          title: Entitlements
          example:
            - exports:create
            - charts:read_all
      type: object
      required:
        - user_id
        - username
        - email
        - full_name
        - roles
        - entitlements
      title: UserProfile
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer
