Skip to content

Commit e28301c

Browse files
Add function to download jwks
1 parent 1de83a5 commit e28301c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

deps/oauth2_client/src/oauth2_client.erl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
-module(oauth2_client).
88
-export([get_access_token/2, get_expiration_time/1,
99
refresh_access_token/2,
10+
get_jwks/2, get_jwks/3,
1011
get_oauth_provider/1, get_oauth_provider/2,
1112
get_openid_configuration/2,get_openid_configuration/3,
1213
build_openid_discovery_endpoint/3,
@@ -139,6 +140,22 @@ get_openid_configuration(DiscoverEndpoint, TLSOptions, ProxyOptions) ->
139140
Response = http_get(DiscoverEndpoint, HTTPOptions, ProxyOptions),
140141
parse_openid_configuration_response(Response).
141142

143+
-spec get_jwks(JWKSEndpoint :: uri_string:uri_string(),
144+
ssl:tls_option() | []) -> {ok, openid_configuration()} | {error, term()}.
145+
get_jwks(JWKSEndpoint, TLSOptions) ->
146+
get_jwks(JWKSEndpoint, TLSOptions, undefined).
147+
148+
-spec get_jwks(JWKSEndpoint :: uri_string:uri_string(),
149+
ssl:tls_option() | [], proxy_options() | undefined | 'none')
150+
-> {ok, openid_configuration()} | {error, term()}.
151+
get_jwks(JWKSEndpoint, TLSOptions, ProxyOptions) ->
152+
rabbit_log:debug("get_jwks from ~p (~p) [~p]", [JWKSEndpoint,
153+
format_ssl_options(TLSOptions), format_proxy_options(ProxyOptions)]),
154+
HTTPOptions =
155+
map_ssl_options_to_httpc_option(TLSOptions) ++
156+
map_timeout_to_httpc_option(?DEFAULT_HTTP_TIMEOUT),
157+
http_get(JWKSEndpoint, HTTPOptions, ProxyOptions).
158+
142159
-spec merge_openid_configuration(openid_configuration(), oauth_provider()) ->
143160
oauth_provider().
144161
merge_openid_configuration(OpenId, OAuthProvider0) ->

0 commit comments

Comments
 (0)