Identity and Access Management

Github Gist com a especificação das rotas de autenticação e identidade em OpenAPI v2.

definitions:
  CheckResult:
    properties:
      duration:
        example: 100ms
        type: string
      error:
        type: string
      status:
        allOf:
        - $ref: '#/definitions/HealthStatus'
        enum:
        - healthy
        - degraded
        - unhealthy
    required:
    - duration
    - status
    type: object
  DecodeRequest:
    properties:
      token:
        example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
        type: string
    required:
    - token
    type: object
  DecodeResponse:
    properties:
      claims:
        additionalProperties: true
        type: object
    type: object
  ErrorInfo:
    properties:
      code:
        description: Example error code
        example: ERR001
        type: string
      message:
        description: Example error message
        example: An error occurred
        type: string
    type: object
  HealthResponse:
    properties:
      checks:
        additionalProperties:
          $ref: '#/definitions/CheckResult'
        type: object
      duration:
        example: 100ms
        type: string
      status:
        allOf:
        - $ref: '#/definitions/HealthStatus'
        enum:
        - healthy
        - degraded
        - unhealthy
      system:
        $ref: '#/definitions/SystemInfo'
      timestamp:
        example: "2024-01-01T00:00:00Z"
        type: string
    required:
    - checks
    - duration
    - status
    - timestamp
    type: object
  HealthStatus:
    enum:
    - healthy
    - degraded
    - unhealthy
    type: string
    x-enum-varnames:
    - HealthStatusHealthy
    - HealthStatusDegraded
    - HealthStatusUnhealthy
  LoginFormResponse:
    properties:
      access_token:
        example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
        type: string
      expires_in:
        example: 3600
        type: integer
      token_type:
        example: Bearer
        type: string
    type: object
  Meta:
    properties:
      request_id:
        description: Example request ID
        example: "12345"
        type: string
      timestamp:
        description: Example timestamp
        example: "2024-01-01T12:00:00Z"
        type: string
      version:
        description: Example version
        example: "1.0"
        type: string
    type: object
  PublicKeyResponse:
    properties:
      public_key:
        example: |-
          -----BEGIN PUBLIC KEY-----
          MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQ...
          -----END PUBLIC KEY-----
        type: string
    type: object
  Response-any:
    properties:
      data: {}
      error:
        allOf:
        - $ref: '#/definitions/ErrorInfo'
        description: Example error information
      meta:
        allOf:
        - $ref: '#/definitions/Meta'
        description: Example metadata
      success:
        example: true
        type: boolean
    type: object
  Response-http_DecodeResponse:
    properties:
      data:
        $ref: '#/definitions/DecodeResponse'
      error:
        allOf:
        - $ref: '#/definitions/ErrorInfo'
        description: Example error information
      meta:
        allOf:
        - $ref: '#/definitions/Meta'
        description: Example metadata
      success:
        example: true
        type: boolean
    type: object
  Response-http_HealthResponse:
    properties:
      data:
        $ref: '#/definitions/HealthResponse'
      error:
        allOf:
        - $ref: '#/definitions/ErrorInfo'
        description: Example error information
      meta:
        allOf:
        - $ref: '#/definitions/Meta'
        description: Example metadata
      success:
        example: true
        type: boolean
    type: object
  Response-http_LoginFormResponse:
    properties:
      data:
        $ref: '#/definitions/LoginFormResponse'
      error:
        allOf:
        - $ref: '#/definitions/ErrorInfo'
        description: Example error information
      meta:
        allOf:
        - $ref: '#/definitions/Meta'
        description: Example metadata
      success:
        example: true
        type: boolean
    type: object
  Response-http_PublicKeyResponse:
    properties:
      data:
        $ref: '#/definitions/PublicKeyResponse'
      error:
        allOf:
        - $ref: '#/definitions/ErrorInfo'
        description: Example error information
      meta:
        allOf:
        - $ref: '#/definitions/Meta'
        description: Example metadata
      success:
        example: true
        type: boolean
    type: object
  Response-http_ValidateTokenResponse:
    properties:
      data:
        $ref: '#/definitions/ValidateTokenResponse'
      error:
        allOf:
        - $ref: '#/definitions/ErrorInfo'
        description: Example error information
      meta:
        allOf:
        - $ref: '#/definitions/Meta'
        description: Example metadata
      success:
        example: true
        type: boolean
    type: object
  SystemInfo:
    properties:
      go_version:
        example: go1.20
        type: string
      mem_alloc_mb:
        example: 50
        type: integer
      mem_sys_mb:
        example: 150
        type: integer
      mem_total_mb:
        example: 100
        type: integer
      num_cpu:
        example: 4
        type: integer
      num_gc:
        example: 5
        type: integer
      num_goroutine:
        example: 10
        type: integer
      uptime:
        example: 1h30m
        type: string
      version:
        example: 1.0.0
        type: string
    required:
    - go_version
    - mem_alloc_mb
    - mem_sys_mb
    - mem_total_mb
    - num_cpu
    - num_gc
    - num_goroutine
    - uptime
    type: object
  ValidateTokenRequest:
    properties:
      token:
        example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
        type: string
    required:
    - token
    type: object
  ValidateTokenResponse:
    properties:
      is_valid:
        example: true
        type: boolean
    type: object
host: iam.qesh.tech
info:
  contact:
    email: [email protected]
    name: API Support
  description: |
    This is the IAM (Identity and Access Management) service API for Qesh applications.
  title: IAM Service API
  version: "1.0"
paths:
  /v1/iam/decode:
    post:
      consumes:
      - application/json
      description: Decodes a JWT token and returns its claims
      operationId: decode
      parameters:
      - description: Token to decode
        in: body
        name: token
        required: true
        schema:
          $ref: '#/definitions/DecodeRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            allOf:
            - $ref: '#/definitions/Response-http_DecodeResponse'
            - properties:
                data:
                  $ref: '#/definitions/DecodeResponse'
              type: object
        "400":
          description: Bad Request
          schema:
            allOf:
            - $ref: '#/definitions/Response-any'
            - properties:
                error:
                  $ref: '#/definitions/ErrorInfo'
              type: object
        "422":
          description: Unprocessable Entity
          schema:
            allOf:
            - $ref: '#/definitions/Response-any'
            - properties:
                error:
                  $ref: '#/definitions/ErrorInfo'
              type: object
        "503":
          description: Service Unavailable
          schema:
            allOf:
            - $ref: '#/definitions/Response-any'
            - properties:
                error:
                  $ref: '#/definitions/ErrorInfo'
              type: object
      summary: Decode a Token and return its claims
      tags:
      - Authentication
  /v1/iam/health:
    get:
      consumes:
      - application/json
      description: Returns OK if the service is healthy
      operationId: health-check
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            allOf:
            - $ref: '#/definitions/Response-http_HealthResponse'
            - properties:
                data:
                  $ref: '#/definitions/HealthResponse'
              type: object
      summary: Health Check
      tags:
      - Health
  /v1/iam/public-key:
    get:
      consumes:
      - application/json
      description: Returns the public key used for token validation
      operationId: public-key
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            allOf:
            - $ref: '#/definitions/Response-http_PublicKeyResponse'
            - properties:
                data:
                  $ref: '#/definitions/PublicKeyResponse'
              type: object
        "500":
          description: Internal Server Error
          schema:
            allOf:
            - $ref: '#/definitions/Response-any'
            - properties:
                error:
                  $ref: '#/definitions/ErrorInfo'
              type: object
      summary: Public Key
      tags:
      - Authentication
  /v1/iam/users/login:
    post:
      consumes:
      - application/x-www-form-urlencoded
      description: Authenticates a user and returns an access token
      operationId: login
      parameters:
      - example: my_client_id
        in: formData
        name: client_id
        required: true
        type: string
      - example: my_client_secret
        in: formData
        name: client_secret
        required: true
        type: string
      - default: client_credentials
        example: client_credentials
        in: formData
        name: grant_type
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            allOf:
            - $ref: '#/definitions/Response-http_LoginFormResponse'
            - properties:
                data:
                  $ref: '#/definitions/LoginFormResponse'
              type: object
        "400":
          description: Bad Request
          schema:
            allOf:
            - $ref: '#/definitions/Response-any'
            - properties:
                error:
                  $ref: '#/definitions/ErrorInfo'
              type: object
        "422":
          description: Unprocessable Entity
          schema:
            allOf:
            - $ref: '#/definitions/Response-any'
            - properties:
                error:
                  $ref: '#/definitions/ErrorInfo'
              type: object
        "503":
          description: Service Unavailable
          schema:
            allOf:
            - $ref: '#/definitions/Response-any'
            - properties:
                error:
                  $ref: '#/definitions/ErrorInfo'
              type: object
      summary: Login
      tags:
      - Authentication
  /v1/iam/validate:
    post:
      consumes:
      - application/json
      description: Validates a given token
      operationId: validate
      parameters:
      - description: Token to be validated
        in: body
        name: body
        required: true
        schema:
          $ref: '#/definitions/ValidateTokenRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            allOf:
            - $ref: '#/definitions/Response-http_ValidateTokenResponse'
            - properties:
                data:
                  $ref: '#/definitions/ValidateTokenResponse'
              type: object
        "400":
          description: Bad Request
          schema:
            allOf:
            - $ref: '#/definitions/Response-any'
            - properties:
                error:
                  $ref: '#/definitions/ErrorInfo'
              type: object
        "401":
          description: Unauthorized
          schema:
            allOf:
            - $ref: '#/definitions/Response-any'
            - properties:
                error:
                  $ref: '#/definitions/ErrorInfo'
              type: object
        "500":
          description: Internal Server Error
          schema:
            allOf:
            - $ref: '#/definitions/Response-any'
            - properties:
                error:
                  $ref: '#/definitions/ErrorInfo'
              type: object
      summary: Validate
      tags:
      - Authentication
securityDefinitions:
  BasicAuth:
    type: basic
swagger: "2.0"