# Copyright 2020 - 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.

x-summary: >-
  The request requires higher privileges than provided by the access token
description: >-
  The returned `x-flow-id` and `x-mode` header values are the same as in the request, if they are available.


  If there is no `x-flow-id` in the request, or if it is malformed, the service generates a random UUID itself, and
  returns that. Therefor, a `401` response always has an `x-flow-id` header. (A missing `x-flow-id` in the request would
  normally result in a `400` response, but authNZ takes precedence.)


  If there is a valid `authorization` token, but there is no `x-mode` in the request, or if it is malformed,
  authorization is impossible, and a `403` is returned. Since we will never return invalid values, in this case, there
  is no `x-mode` header in the response. If there is a valid `authorization` token, and there is a valid `x-mode` in the
  request, but the resource action is not authorized for other reasons, the response `x-mode` header contains the
  `x-mode` value from the request.
headers:
  www-authenticate:
    required: true
    schema:
      $ref: 'WWWAuthenticate.yaml'
  x-flow-id:
    required: true
    schema:
      $ref: '../id/UUID.yaml'
  x-mode:
    required: false # because without a mode, we cannot authorize
    schema:
      $ref: '../id/mode.yaml'
  x-date:
    required: true
    schema:
      $ref: '../time/DateTime.yaml'
