View Source oidcc_cowboy_introspect_token (oidcc_cowboy v2.0.0)

Validate extracted authorization token using introspection.

See: https://datatracker.ietf.org/doc/html/rfc7662

This middleware should be used together with oidcc_cowboy_extract_authorization.

This middleware will send a introspection request for ever request. To avoid this, provide a cache to opts().

Usage

  OidccCowboyOpts = #{
      provider => openid_confi_provider_name,
      client_id => <<"client_id">>,
      client_secret => <<"client_secret">>
  },
  Dispatch = cowboy_router:compile([
      {'_', [
          %% ...
      ]}
  ]),
  {ok, _} = cowboy:start_clear(http, [{port, 8080}], #{
      middlewares => [
          oidcc_cowboy_extract_authorization,
          oidcc_cowboy_introspect_token,
          cowboy_router,
          cowboy_handler
      ],
      env => #{
          dispatch => Dispatch,
          oidcc_cowboy_introspect_token => OidccCowboyOpts
      }
  })

Summary

Types

Options for the middleware

Types

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(),
      token_introspection_opts => oidcc_token_introspection:opts(),
      cache => oidcc_cowboy_cache:t(),
      send_inactive_token_response =>
          fun((Req :: cowboy_req:req(),
               Env :: cowboy_middleware:env(),
               Introspection :: oidcc_token_introspection:t()) ->
                  {ok, cowboy_req:req(), cowboy_middleware:env()} | {stop, cowboy_req:req()})}.

Options for the middleware

Options

  • provider - name of the oidcc_provider_configuration_worker
  • client_id - OAuth Client ID to use for the token introspection
  • client_secret - OAuth Client Secret to use for the token introspection
  • token_introspection_opts - Options to pass to the introspection
  • send_inactive_token_response - Customize Error Response for inactive token
  • cache - Cache introspection response - See oidcc_cowboy_cache