View Source oidcc_cowboy_authorize (oidcc_cowboy v2.0.0-rc.1)
Cowboy Oidcc Authorization Handler
Usage
OidccCowboyOpts = #{
provider => config_provider_gen_server_name,
client_id => <<"client_id">>,
client_secret => <<"client_secret">>,
redirect_uri => "http://localhost/oidc/return"
},
OidccCowboyCallbackOpts = maps:merge(OidccCowboyOpts, #{
%% ...
}),
Dispatch = cowboy_router:compile([
{'_', [
{"/", oidcc_cowboy_authorize, OidccCowboyOpts},
{"/oidc/return", oidcc_cowboy_callback, OidccCowboyCallbackOpts}
]}
]),
{ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
env => #{dispatch => Dispatch}
})
Summary
Types
Link to this type
error/0
View Source (since 2.0.0 -------------------------------------------------------------------)-type error() :: oidcc_client_context:error() | oidcc_authorization:error().
Link to this type
opts/0
View Source (since 2.0.0 -------------------------------------------------------------------)-type opts() :: #{provider := gen_server:server_ref(), client_id := binary(), client_secret := binary(), redirect_uri := uri_string:uri_string(), scopes => oidcc_scope:scopes(), state => binary(), pkce => oidcc_authorization:pkce() | undefined, url_extension => oidcc_http_util:query_params(), handle_failure => fun((Req :: cowboy_req:req(), Reason :: error()) -> cowboy_req:req())}.
Configure authorization redirection
See https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest
Parameters
provider
- name of the runningoidcc_provider_configuration_worker
client_id
- Client IDclient_secret
- Client Secretredirect_uri
- redirect target after authorization is completedscopes
- list of scopes to request (defaults to[<<"openid">>]
)state
- state to pass to the providerpkce
- pkce arguments to pass to the providerurl_extension
- add custom query parameters to the authorization urlhandle_failure
- handler to react to errors (render response etc.)