basePath: /
definitions:
  entity.Oauth2Scope:
    properties:
      org:
        type: string
      project:
        type: string
    type: object
  oauth2.AccessTokenInfo:
    properties:
      grant_all_projects:
        type: boolean
      grant_type:
        type: string
      org_id:
        type: integer
      project_ids:
        items:
          type: integer
        type: array
      scopes:
        $ref: '#/definitions/entity.Oauth2Scope'
      user_email:
        type: string
      user_id:
        type: integer
    type: object
  oauth2.Action:
    enum:
    - approve
    - deny
    type: string
    x-enum-varnames:
    - ActionApprove
    - ActionDeny
  oauth2.Application:
    properties:
      home_page_uri:
        type: string
      logo_uri_dark:
        type: string
      logo_uri_light:
        type: string
      name:
        type: string
    type: object
  oauth2.ApplicationRequest:
    properties:
      application_id:
        type: integer
    type: object
  oauth2.AuthorizationCodeTokenRequest:
    properties:
      client_id:
        type: string
      client_secret:
        type: string
      code:
        type: string
      grant_type:
        type: string
      redirect_uri:
        type: string
    type: object
  oauth2.DeviceAuthorizationRequest:
    properties:
      client_id:
        type: string
    type: object
  oauth2.DeviceAuthorizationResponse:
    properties:
      device_code:
        type: string
      expires_in:
        type: integer
      interval:
        type: integer
      user_code:
        type: string
      verification_uri:
        type: string
      verification_uri_complete:
        type: string
    type: object
  oauth2.DeviceTokenRequest:
    properties:
      client_id:
        type: string
      device_code:
        type: string
      grant_type:
        type: string
    type: object
  oauth2.ErrorResponse:
    properties:
      error:
        type: string
      error_description:
        type: string
      error_uri:
        type: string
    type: object
  oauth2.InnerAuthorizationCodeCheckRequest:
    properties:
      client_id:
        type: string
      redirect_uri:
        type: string
      response_type:
        type: string
      scope:
        type: string
      state:
        type: string
    type: object
  oauth2.InnerAuthorizationCodeConfirmationRequest:
    properties:
      client_id:
        type: string
      org_id:
        description: Accept OrgId & ProjectID as a string to prevent overflow in the
          frontend.
        type: string
      project_ids:
        items:
          type: string
        type: array
      redirect_uri:
        type: string
      response_type:
        type: string
      scope:
        type: string
      state:
        type: string
    type: object
  oauth2.InnerAuthorizationCodeResponse:
    properties:
      application:
        $ref: '#/definitions/oauth2.Application'
      code:
        type: integer
      message:
        type: string
      need_redirect:
        type: boolean
      redirect_to:
        type: string
    type: object
  oauth2.InnerBasicResponse:
    properties:
      code:
        type: integer
      message:
        type: string
    type: object
  oauth2.InnerDeviceCheckRequest:
    properties:
      user_code:
        type: string
    type: object
  oauth2.InnerDeviceCheckResponse:
    properties:
      code:
        type: integer
      data:
        properties:
          created_at:
            type: string
          ip:
            type: string
          user_agent:
            type: string
        type: object
      message:
        type: string
    type: object
  oauth2.InnerDeviceConfirmRequest:
    properties:
      action:
        $ref: '#/definitions/oauth2.Action'
      org_id:
        description: Accept OrgId as a string to prevent overflow in the frontend.
        type: string
      user_code:
        type: string
    type: object
  oauth2.InnerGetUserLastTokenResponse:
    properties:
      code:
        type: integer
      message:
        type: string
      token:
        $ref: '#/definitions/oauth2.InnerQueryToken'
    type: object
  oauth2.InnerQueryToken:
    properties:
      application_id:
        type: integer
      application_logo_uri_dark:
        type: string
      application_logo_uri_light:
        type: string
      application_name:
        type: string
      company:
        type: string
      created_at:
        type: string
      expire_at:
        type: string
      grant_type:
        type: string
      id:
        type: integer
      org_id:
        type: string
      scopes:
        $ref: '#/definitions/entity.Oauth2Scope'
      user_email:
        type: string
      user_id:
        type: string
    type: object
  oauth2.InnerQueryUserAuthorizedAppsResponse:
    properties:
      applications:
        items:
          $ref: '#/definitions/oauth2.UserAuthorizedApp'
        type: array
      code:
        type: integer
      message:
        type: string
    type: object
  oauth2.RefreshTokenRequest:
    properties:
      client_id:
        type: string
      client_secret:
        type: string
      grant_type:
        type: string
      refresh_token:
        type: string
    type: object
  oauth2.RevokeTokenRequest:
    properties:
      client_id:
        type: string
      client_secret:
        type: string
      token:
        type: string
      token_type_hint:
        type: string
    type: object
  oauth2.TokenResponse:
    properties:
      access_token:
        type: string
      expires_in:
        type: integer
      refresh_token:
        type: string
      token_type:
        type: string
    type: object
  oauth2.UserAuthorizedApp:
    properties:
      authorized:
        type: boolean
      company:
        type: string
      company_uri:
        type: string
      description:
        type: string
      grant_typ:
        type: string
      home_page_uri:
        type: string
      id:
        type: integer
      last_used_at:
        type: string
      logo_uri_dark:
        type: string
      logo_uri_light:
        type: string
      name:
        type: string
    type: object
  oauth2.UserInfo:
    properties:
      company name:
        description: only for tms
        type: string
      country:
        description: only for tms
        type: string
      email:
        type: string
      first_name:
        type: string
      last_name:
        type: string
      username:
        type: string
    type: object
host: 127.0.0.1:10010
info:
  contact: {}
  description: AuthServer OAuth2 API
  title: AuthServer OAuth2
  version: "1.0"
paths:
  /api/v1/oauth/authorize/check:
    post:
      consumes:
      - application/json
      description: Check if the authorization code request is valid and return the
        application info.
      parameters:
      - description: request
        in: body
        name: request
        required: true
        schema:
          $ref: '#/definitions/oauth2.InnerAuthorizationCodeCheckRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/oauth2.InnerAuthorizationCodeResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/oauth2.InnerAuthorizationCodeResponse'
      summary: Check the authorization code request.
      tags:
      - oauth2_authorization_code_inner
  /api/v1/oauth/authorize/confirmation:
    post:
      consumes:
      - application/json
      description: Approve the authorization code grant request and redirect to the
        redirect_uri.
      parameters:
      - description: request
        in: body
        name: request
        required: true
        schema:
          $ref: '#/definitions/oauth2.InnerAuthorizationCodeConfirmationRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/oauth2.InnerAuthorizationCodeResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/oauth2.InnerAuthorizationCodeResponse'
      summary: Approve the authorization code grant request.
      tags:
      - oauth2_authorization_code_inner
  /api/v1/oauth/console/application/user-authorized:
    get:
      consumes:
      - application/json
      description: Inner query user authorized application  for console request.
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/oauth2.InnerQueryUserAuthorizedAppsResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/oauth2.InnerBasicResponse'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/oauth2.InnerBasicResponse'
      summary: query user authorized application request.
      tags:
      - console_inner
  /api/v1/oauth/console/token:
    get:
      consumes:
      - application/json
      description: Inner query user last token for console request.
      parameters:
      - in: query
        name: application_id
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/oauth2.InnerGetUserLastTokenResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/oauth2.InnerBasicResponse'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/oauth2.InnerBasicResponse'
      summary: query token request.
      tags:
      - console_inner
  /api/v1/oauth/console/token/:
    post:
      consumes:
      - application/json
      description: revoke token for console request.
      parameters:
      - description: console revoke token request
        in: body
        name: revoke
        required: true
        schema:
          $ref: '#/definitions/oauth2.ApplicationRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/oauth2.InnerBasicResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/oauth2.InnerBasicResponse'
        "404":
          description: Not Found
          schema:
            $ref: '#/definitions/oauth2.InnerBasicResponse'
      summary: console revoke token request.
      tags:
      - console_inner
  /api/v1/oauth/device/check:
    post:
      consumes:
      - application/json
      description: Check if the user_code is valid and return the device grant request
        info.
      parameters:
      - description: user_code
        in: body
        name: user_code
        required: true
        schema:
          $ref: '#/definitions/oauth2.InnerDeviceCheckRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/oauth2.InnerDeviceCheckResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/oauth2.InnerBasicResponse'
      summary: Check user_code for device authorization.
      tags:
      - oauth2_device_inner
  /api/v1/oauth/device/confirmation:
    post:
      consumes:
      - application/json
      description: User can approve or deny the device authorization request.
      parameters:
      - description: confirm device authorization request
        in: body
        name: confirm
        required: true
        schema:
          $ref: '#/definitions/oauth2.InnerDeviceConfirmRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/oauth2.InnerBasicResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/oauth2.InnerBasicResponse'
        "404":
          description: Can't find the device authorization request by user_code.
          schema:
            $ref: '#/definitions/oauth2.InnerBasicResponse'
      summary: Confirm the device authorization request.
      tags:
      - oauth2_device_inner
  /v1/authInfo:
    get:
      consumes:
      - application/json
      - application/x-www-form-urlencoded
      description: OAuth2 get authorization info endpoint.
      parameters:
      - description: Bearer token
        in: header
        name: Authorization
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/oauth2.AccessTokenInfo'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/oauth2.ErrorResponse'
      summary: Get authInfo endpoint.
      tags:
      - oauth2_public
  /v1/device_authorization:
    post:
      consumes:
      - application/json
      - application/x-www-form-urlencoded
      description: Device starts the authorization request, get the user_code, device_code
        and verification_uri.
      parameters:
      - description: client_id
        in: body
        name: client_id
        required: true
        schema:
          $ref: '#/definitions/oauth2.DeviceAuthorizationRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/oauth2.DeviceAuthorizationResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/oauth2.ErrorResponse'
      summary: Device authorization endpoint.
      tags:
      - oauth2_device_public
  /v1/revoke:
    post:
      consumes:
      - application/json
      - application/x-www-form-urlencoded
      description: OAuth2 revoke token endpoint.
      parameters:
      - description: token
        in: body
        name: token
        required: true
        schema:
          $ref: '#/definitions/oauth2.RevokeTokenRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/oauth2.ErrorResponse'
      summary: Revoke token endpoint.
      tags:
      - oauth2_public
  /v1/token:
    post:
      consumes:
      - application/json
      - application/x-www-form-urlencoded
      description: OAuth2 token endpoint, support device code grant and refresh token
        grant.
      parameters:
      - description: device_flow
        in: body
        name: device_flow
        required: true
        schema:
          $ref: '#/definitions/oauth2.DeviceTokenRequest'
      - description: refresh_token
        in: body
        name: refresh_token
        required: true
        schema:
          $ref: '#/definitions/oauth2.RefreshTokenRequest'
      - description: authorization_code
        in: body
        name: authorization_code
        required: true
        schema:
          $ref: '#/definitions/oauth2.AuthorizationCodeTokenRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/oauth2.TokenResponse'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/oauth2.ErrorResponse'
      summary: Token endpoint.
      tags:
      - oauth2_public
  /v1/userinfo:
    get:
      consumes:
      - application/json
      - application/x-www-form-urlencoded
      description: OAuth2 get userinfo endpoint.
      parameters:
      - description: Bearer token
        in: header
        name: Authorization
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/oauth2.UserInfo'
        "400":
          description: Bad Request
          schema:
            $ref: '#/definitions/oauth2.ErrorResponse'
      summary: Get userinfo endpoint.
      tags:
      - oauth2_public
swagger: "2.0"
