Validate extracted authorization token by validating it as a JWT token.
This module should be used together with Oidcc.Plug.ExtractAuthorization.
defmodule SampleAppWeb.Endpoint do
use Phoenix.Endpoint, otp_app: :sample_app
# ...
plug Oidcc.Plug.ExtractAuthorization
plug Oidcc.Plug.ValidateJwtToken,
provider: SampleApp.GoogleOpenIdConfigurationProvider,
client_id: Application.compile_env!(:sample_app, [Oidcc.Plug.ValidateJwtToken, :client_id]),
client_secret: Application.compile_env!(:sample_app, [Oidcc.Plug.ValidateJwtToken, :client_secret]),
# optional validation options to pass to Oidcc.Token.validate_id_token/3
validate_opts: %{validate_azp: :any}
plug SampleAppWeb.Router
end
Summary
Types
@type opts() :: [ provider: GenServer.name(), client_id: String.t() | (-> String.t()), client_secret: String.t() | (-> String.t()), send_inactive_token_response: (conn :: Plug.Conn.t() -> Plug.Conn.t()), validate_opts: Oidcc.Token.retrieve_opts() ]
Plug Configuration Options
Options
provider- name of theOidcc.ProviderConfiguration.Workerclient_id- OAuth Client ID to use for the token validationclient_secret- OAuth Client Secret to use for the token validationsend_inactive_token_response- Customize Error Response for inactive tokenclient_store- A module name that implements theOidcc.Plug.ClientStorebehaviour to fetch the client context from a store instead of using theprovider,client_idandclient_secretdirectly. This is useful for storing the client context in a database or other persistent storage.validate_opts- A map of options to pass toOidcc.Token.validate_id_token/3.