View Source oidcc_cowboy_authorize (oidcc_cowboy v2.0.0-alpha.2)

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

Configure authorization redirection

Types

Link to this type

error/0

View Source (since 2.0.0 -------------------------------------------------------------------)
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 running oidcc_provider_configuration_worker
  • client_id - Client ID
  • client_secret - Client Secret
  • redirect_uri - redirect target after authorization is completed
  • scopes - list of scopes to request (defaults to [<<"openid">>])
  • state - state to pass to the provider
  • pkce - pkce arguments to pass to the provider
  • url_extension - add custom query parameters to the authorization url
  • handle_failure - handler to react to errors (render response etc.)