openapi: 3.0.1
info:
  title: AuthZ Connector REST APIs
  description: AuthZ Connector Internal REST APIs
  version: '1'
servers:
  - url: 'https://api.plumery.com'
    description: Live Server
paths:
  '/internal/v1/external-authz':
    post:
      tags:
        - AuthZ Internal
      summary: Externally Authorize
      description: 'Externally Authorize'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AuthzRequest'
      responses:
        '200':
          description: Successfully authorized
          headers:
            x-fraud-score:
              schema:
                type: string
              description: Describes fraud score.
            x-fraud-decision:
              schema:
                type: string
              description: Describes fraud decision.
        '401':
          description: 'Unauthorized'
          headers:
            x-fraud-score:
              schema:
                type: string
              description: Describes fraud score.
            x-fraud-decision:
              schema:
                type: string
              description: Describes fraud decision.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthzResponse'
        '403':
          description: 'Forbidden'
          headers:
            x-fraud-score:
              schema:
                type: string
              description: Describes fraud score.
            x-fraud-decision:
              schema:
                type: string
              description: Describes fraud decision.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthzResponse'
        '500':
          description: Internal server error occurred
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerErrorResponse'
        default:
          description: Unexpected error
      x-internal: true
      operationId: AuthZ Request
  '/internal/v1/external-authz/timeout':
    post:
      tags:
        - AuthZ Internal
      summary: Authz Timeout Notification
      description: 'Notify about timeout of authz request'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AuthzRequest'
      responses:
        '200':
          description: Successfully notified
        '500':
          description: Internal server error occurred
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerErrorResponse'
        default:
          description: Unexpected error
      x-internal: true
      operationId: AuthZ Request Timeout Notification
components:
  schemas:
    AuthzResponse:
      description: Authz response
      type: object
      properties:
        message:
          type: string
        checkResult:
          type: string
          enum:
            - BLOCK
            - REJECT
            - CHALLENGE
    AuthzRequest:
      description: Authz request
      type: object
      properties:
        requestId:
          type: string
        method:
          type: string
        path:
          type: string
        contentLength:
          type: string
        headers:
          type: object
          additionalProperties:
            type: string
          description: HTTP request headers as key-value pairs
        contentType:
          type: string
        bodyBytes:
          type: string
          format: byte
          description: Base64-encoded request body
    ErrorCode:
      type: string
      enum:
        - 'urn:plmr:authorization:connector:INTERNAL_SERVER_ERROR'
    InternalServerErrorResponse:
      description: Internal server error response
      type: object
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
        requestId:
          type: string