Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make some OAuth2 settings optional #12258

Open
wants to merge 54 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
33efdf9
Deprecate resource req parameter from authorize endpoint
MarcialRosales Sep 9, 2024
97b3f1f
Minor refactor
MarcialRosales Sep 9, 2024
fef0c5d
Reduce verbosity of some log statements
MarcialRosales Sep 10, 2024
072b144
Reduce logging verbosity
MarcialRosales Sep 10, 2024
0124739
WIP Refactor code
MarcialRosales Sep 11, 2024
2a3c4a7
WIP More refactoring
MarcialRosales Sep 12, 2024
02b49ea
WIP Fix compilation errors
MarcialRosales Sep 13, 2024
51dacf1
WIP Continue refactoring + clean up
MarcialRosales Sep 13, 2024
9ed6e6b
WIP Fix compilation errors
MarcialRosales Sep 13, 2024
2888225
Refactor assertion function
MarcialRosales Sep 13, 2024
357f656
WIP Fix test cases
MarcialRosales Sep 13, 2024
90faa0d
WIP fix some test cases
MarcialRosales Sep 13, 2024
dd0d3fd
WIP fix more test cases
MarcialRosales Sep 13, 2024
fcbfeac
Simplify module names
MarcialRosales Sep 16, 2024
d6cac5f
Fix some test cases
MarcialRosales Sep 16, 2024
9916822
Fix test cases
MarcialRosales Sep 16, 2024
e53e16b
fix some test cases
MarcialRosales Sep 16, 2024
640c677
Fix test cases
MarcialRosales Sep 16, 2024
76a095b
WIP Use resource_server() type
MarcialRosales Sep 16, 2024
30f6798
Fix test cases
MarcialRosales Sep 17, 2024
c80261d
Fix test system test cases
MarcialRosales Sep 17, 2024
d2ec633
More test fixes + clean up + refactor
MarcialRosales Sep 17, 2024
07d8dbb
Fix issue and test
MarcialRosales Sep 17, 2024
dd496f3
Fix test cases and refactor rar and keycloak
MarcialRosales Sep 18, 2024
7bc9334
Fix all test in unit_SUITE
MarcialRosales Sep 18, 2024
5a18518
Fix dialyzer errors
MarcialRosales Sep 18, 2024
9cc86c6
Add token endpoint params to schema
MarcialRosales Sep 18, 2024
2845e50
Remove unnecessary statement
MarcialRosales Sep 18, 2024
9c05683
Test invalid token parameter config
MarcialRosales Sep 18, 2024
5f75fe3
Fix test
MarcialRosales Sep 19, 2024
b79cfe7
Improve format
MarcialRosales Sep 19, 2024
c0957ce
Add explicitly sub preferred_username
MarcialRosales Sep 19, 2024
612dc51
WIP Build discovery_endpoint
MarcialRosales Sep 19, 2024
caf0662
Fix test case
MarcialRosales Sep 19, 2024
cb947f9
Clean up ct:log statements
MarcialRosales Sep 19, 2024
0623b99
Fix dialyzer error
MarcialRosales Sep 20, 2024
3cb81f0
Modify management schema
MarcialRosales Sep 20, 2024
101e89e
Send new params to management ui
MarcialRosales Sep 20, 2024
b8da455
WIP Elminate defaults and take from config
MarcialRosales Sep 20, 2024
6f1f74d
Add auth and token endpoint params to authSettings
MarcialRosales Sep 23, 2024
da8a1e3
Test authSettings with extra endpoint params
MarcialRosales Sep 23, 2024
135f6aa
Teet extra token parans for additioal resource servers
MarcialRosales Sep 23, 2024
1675b2e
Fix schema issues
MarcialRosales Sep 23, 2024
2f1a878
Always use list() type for urls
MarcialRosales Sep 24, 2024
f0cd2ca
Fix schema mapping issues
MarcialRosales Sep 24, 2024
0592732
Remove function
MarcialRosales Sep 24, 2024
4c859bb
Fix fucntion signature
MarcialRosales Sep 24, 2024
4a7de0b
Fix issue initializing oidc-client
MarcialRosales Sep 24, 2024
b413d77
Remove unnecessary log statements
MarcialRosales Sep 24, 2024
697b5a2
Fix error
MarcialRosales Sep 25, 2024
b572872
Remove some spaces
MarcialRosales Sep 27, 2024
0e9f8bc
Remove wrong file
MarcialRosales Sep 27, 2024
762d615
OAuth 2 client: sync option/1 with rabbit_types, add a comment
michaelklishin Oct 4, 2024
11d405d
Refactoring
MarcialRosales Oct 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions deps/oauth2_client/app.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def all_srcs(name = "all_srcs"):
)
filegroup(
name = "public_hdrs",
srcs = ["include/oauth2_client.hrl"],
srcs = ["include/oauth2_client.hrl", "include/types.hrl"],
)
filegroup(
name = "license_files",
Expand All @@ -88,7 +88,7 @@ def test_suite_beam_files(name = "test_suite_beam_files"):
testonly = True,
srcs = ["test/system_SUITE.erl"],
outs = ["test/system_SUITE.beam"],
hdrs = ["include/oauth2_client.hrl"],
hdrs = ["include/oauth2_client.hrl", "include/types.hrl"],
app_name = "oauth2_client",
erlc_opts = "//:test_erlc_opts",
)
Expand All @@ -97,7 +97,7 @@ def test_suite_beam_files(name = "test_suite_beam_files"):
testonly = True,
srcs = ["test/unit_SUITE.erl"],
outs = ["test/unit_SUITE.beam"],
hdrs = ["include/oauth2_client.hrl"],
hdrs = ["include/oauth2_client.hrl", "include/types.hrl"],
app_name = "oauth2_client",
erlc_opts = "//:test_erlc_opts",
)
Expand Down
64 changes: 1 addition & 63 deletions deps/oauth2_client/include/oauth2_client.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
%% Copyright (c) 2020-2023 VMware, Inc. or its affiliates. All rights reserved.
%%

-include("types.hrl").

% define access token request common constants

Expand Down Expand Up @@ -44,66 +45,3 @@
-define(RESPONSE_END_SESSION_ENDPOINT, <<"end_session_endpoint">>).
-define(RESPONSE_JWKS_URI, <<"jwks_uri">>).
-define(RESPONSE_TLS_OPTIONS, <<"ssl_options">>).

%% The closest we have to a type import in Erlang
-type option(T) :: rabbit_types:option(T).

-type oauth_provider_id() :: root | binary().

-record(openid_configuration, {
issuer :: option(uri_string:uri_string()),
token_endpoint :: option(uri_string:uri_string()),
authorization_endpoint :: option(uri_string:uri_string()),
end_session_endpoint :: option(uri_string:uri_string()),
jwks_uri :: option(uri_string:uri_string())
}).
-type openid_configuration() :: #openid_configuration{}.

-record(oauth_provider, {
id :: oauth_provider_id(),
issuer :: option(uri_string:uri_string()),
token_endpoint :: option(uri_string:uri_string()),
authorization_endpoint :: option(uri_string:uri_string()),
end_session_endpoint :: option(uri_string:uri_string()),
jwks_uri :: option(uri_string:uri_string()),
ssl_options :: option(list())
}).

-type oauth_provider() :: #oauth_provider{}.

-record(access_token_request, {
client_id :: string() | binary(),
client_secret :: string() | binary(),
scope :: string() | binary() | undefined,
timeout :: option(integer())
}).

-type access_token_request() :: #access_token_request{}.

-record(successful_access_token_response, {
access_token :: binary(),
token_type :: binary(),
refresh_token :: option(binary()), % A refresh token SHOULD NOT be included
% .. for client-credentials flow.
% https://www.rfc-editor.org/rfc/rfc6749#section-4.4.3
expires_in :: option(integer())
}).

-type successful_access_token_response() :: #successful_access_token_response{}.

-record(unsuccessful_access_token_response, {
error :: integer(),
error_description :: binary() | string() | undefined
}).

-type unsuccessful_access_token_response() :: #unsuccessful_access_token_response{}.

-record(refresh_token_request, {
client_id :: string() | binary(),
client_secret :: string() | binary(),
scope :: string() | binary() | undefined,
refresh_token :: binary(),
timeout :: option(integer())
}).

-type refresh_token_request() :: #refresh_token_request{}.
75 changes: 75 additions & 0 deletions deps/oauth2_client/include/types.hrl
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
%% This Source Code Form is subject to the terms of the Mozilla Public
%% License, v. 2.0. If a copy of the MPL was not distributed with this
%% file, You can obtain one at https://mozilla.org/MPL/2.0/.
%%
%% Copyright (c) 2020-2023 VMware, Inc. or its affiliates. All rights reserved.
%%

%% Matches the option type in rabbit_types without introducing a dependency
%% on that module and RabbitMQ core (rabbit_common)
-type(option(T) :: T | 'none' | 'undefined').

-type oauth_provider_id() :: root | binary().

-record(openid_configuration, {
issuer :: option(uri_string:uri_string()),
token_endpoint :: option(uri_string:uri_string()),
authorization_endpoint :: option(uri_string:uri_string()),
end_session_endpoint :: option(uri_string:uri_string()),
jwks_uri :: option(uri_string:uri_string())
}).
-type openid_configuration() :: #openid_configuration{}.

-record(oauth_provider, {
id :: oauth_provider_id(),
issuer :: option(uri_string:uri_string()),
discovery_endpoint :: option(uri_string:uri_string()),
token_endpoint :: option(uri_string:uri_string()),
authorization_endpoint :: option(uri_string:uri_string()),
end_session_endpoint :: option(uri_string:uri_string()),
jwks_uri :: option(uri_string:uri_string()),
ssl_options :: option(list())
}).

-type query_list() :: [{unicode:chardata(), unicode:chardata() | true}].

-type oauth_provider() :: #oauth_provider{}.

-record(access_token_request, {
client_id :: string() | binary(),
client_secret :: string() | binary(),
scope :: option(string() | binary()),
extra_parameters :: option(query_list()),
timeout :: option(integer())
}).

-type access_token_request() :: #access_token_request{}.

-record(successful_access_token_response, {
access_token :: binary(),
token_type :: binary(),
%% Note: a refresh token SHOULD NOT be included
%% ... for client-credentials flow.
%% See https://www.rfc-editor.org/rfc/rfc6749#section-4.4.3
refresh_token :: option(binary()),
expires_in :: option(integer())
}).

-type successful_access_token_response() :: #successful_access_token_response{}.

-record(unsuccessful_access_token_response, {
error :: integer(),
error_description :: binary() | string() | undefined
}).

-type unsuccessful_access_token_response() :: #unsuccessful_access_token_response{}.

-record(refresh_token_request, {
client_id :: string() | binary(),
client_secret :: string() | binary(),
scope :: string() | binary() | undefined,
refresh_token :: binary(),
timeout :: option(integer())
}).

-type refresh_token_request() :: #refresh_token_request{}.
Loading
Loading