# Copyright 2021 - 2021 PeopleWare n.v.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

type: object
required:
  - access_token
  - token_type
  - expires_in
  - refresh_token
  - scope
properties:
  access_token:
    $ref: '../../../BearerAccessToken.yaml'
    description: The access token issued by the authorization server. See [`/jwt`](#operation/jwtGet) for details.
  token_type:
    type: string
    description: >-
      The access token type provides the client with the information required to successfully utilize the access token
      to make a protected resource request (along with type-specific attributes).  The client **must not** use an access
      token if it does not understand the token type.


      In this case, the value is always `Bearer`, as defined in [RFC 6750](https://tools.ietf.org/html/rfc6750).
    enum:
      - Bearer
    example: Bearer
  expires_in:
    type: integer
    minimum: 1
    description: >-
      The lifetime in seconds of the access token.  For example, the value "3600" denotes that the access token will
      expire in one hour from the time the response was generated.


      Although optional in [RFC 6749](https://tools.ietf.org/html/rfc6749#section-5.1), it is required here.


      This value should not be < 60, to accomodate for clock drift on the STS, the client, and the resource service.
      Furthermore, the shorter the lifetime of access tokens, the more often clients will need to request new access
      tokens. A shorter lifetime thus results in more token requests on the STS, which has a cost.


      This value should not be too large, for security reasons. For performance reasons, the resource service will not
      check with the STS for toking validity. Issued tokes therefore cannot be retracted. When an account's mandates are
      retracted in the STS, the account will not be able to get new access tokens, but the tokens already issued remain
      valid throughout their lifetime. Worst case, the last valid token was issued just before the account's mandates
      where retracted. The account will be able to continue to use the service after it's mandates were retracted for at
      most the lifetime of that token.


      Since retracting the mandate of an account is a human endeavor, it is acceptable to use a human timescale for the
      lifetime of an access token. We suggest 5 minutes (`300`).
    example: 300
  refresh_token:
    type: string
    minLength: 1
    description: >-
      The refresh token, which can be used to obtain new access tokens using the same authorization grant as described
      in [Section 6 of RFC 6749](https://tools.ietf.org/html/rfc6749#section-6).


      Although optional in [RFC 6749](https://tools.ietf.org/html/rfc6749#section-5.1), it is required here.
    example: tGzv3JOkF0XG5Qx2TlKWIA
  scope:
    type: string
    description: >-
      The scope of the access token as described by [Section 3.3 of RFC
      6749](https://tools.ietf.org/html/rfc6749#section-3.3).
    example: scope1 scope2 scope3
