|
| 1 | +%% This Source Code Form is subject to the terms of the Mozilla Public |
| 2 | +%% License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 | +%% file, You can obtain one at https://mozilla.org/MPL/2.0/. |
| 4 | +%% |
| 5 | +%% Copyright (c) 2020-2023 VMware, Inc. or its affiliates. All rights reserved. |
| 6 | +%% |
| 7 | + |
| 8 | +%% Matches the option type in rabbit_types without introducing a dependency |
| 9 | +%% on that module and RabbitMQ core (rabbit_common) |
| 10 | +-type(option(T) :: T | 'none' | 'undefined'). |
| 11 | + |
| 12 | +-type oauth_provider_id() :: root | binary(). |
| 13 | + |
| 14 | +-record(openid_configuration, { |
| 15 | + issuer :: option(uri_string:uri_string()), |
| 16 | + token_endpoint :: option(uri_string:uri_string()), |
| 17 | + authorization_endpoint :: option(uri_string:uri_string()), |
| 18 | + end_session_endpoint :: option(uri_string:uri_string()), |
| 19 | + jwks_uri :: option(uri_string:uri_string()) |
| 20 | +}). |
| 21 | +-type openid_configuration() :: #openid_configuration{}. |
| 22 | + |
| 23 | +-record(oauth_provider, { |
| 24 | + id :: oauth_provider_id(), |
| 25 | + issuer :: option(uri_string:uri_string()), |
| 26 | + discovery_endpoint :: option(uri_string:uri_string()), |
| 27 | + token_endpoint :: option(uri_string:uri_string()), |
| 28 | + authorization_endpoint :: option(uri_string:uri_string()), |
| 29 | + end_session_endpoint :: option(uri_string:uri_string()), |
| 30 | + jwks_uri :: option(uri_string:uri_string()), |
| 31 | + ssl_options :: option(list()) |
| 32 | +}). |
| 33 | + |
| 34 | +-type query_list() :: [{unicode:chardata(), unicode:chardata() | true}]. |
| 35 | + |
| 36 | +-type oauth_provider() :: #oauth_provider{}. |
| 37 | + |
| 38 | +-record(access_token_request, { |
| 39 | + client_id :: string() | binary(), |
| 40 | + client_secret :: string() | binary(), |
| 41 | + scope :: option(string() | binary()), |
| 42 | + extra_parameters :: option(query_list()), |
| 43 | + timeout :: option(integer()) |
| 44 | +}). |
| 45 | + |
| 46 | +-type access_token_request() :: #access_token_request{}. |
| 47 | + |
| 48 | +-record(successful_access_token_response, { |
| 49 | + access_token :: binary(), |
| 50 | + token_type :: binary(), |
| 51 | + %% Note: a refresh token SHOULD NOT be included |
| 52 | + %% ... for client-credentials flow. |
| 53 | + %% See https://www.rfc-editor.org/rfc/rfc6749#section-4.4.3 |
| 54 | + refresh_token :: option(binary()), |
| 55 | + expires_in :: option(integer()) |
| 56 | +}). |
| 57 | + |
| 58 | +-type successful_access_token_response() :: #successful_access_token_response{}. |
| 59 | + |
| 60 | +-record(unsuccessful_access_token_response, { |
| 61 | + error :: integer(), |
| 62 | + error_description :: binary() | string() | undefined |
| 63 | +}). |
| 64 | + |
| 65 | +-type unsuccessful_access_token_response() :: #unsuccessful_access_token_response{}. |
| 66 | + |
| 67 | +-record(refresh_token_request, { |
| 68 | + client_id :: string() | binary(), |
| 69 | + client_secret :: string() | binary(), |
| 70 | + scope :: string() | binary() | undefined, |
| 71 | + refresh_token :: binary(), |
| 72 | + timeout :: option(integer()) |
| 73 | +}). |
| 74 | + |
| 75 | +-type refresh_token_request() :: #refresh_token_request{}. |
0 commit comments