Keycloak (keycloak v1.1.0) View Source

An OAuth2.Strategy implementation for authorizing with a Keycloak server.

Example

Phoenix controller

def login(conn, _) do
  redirect(conn, external: Keycloak.authorize_url!())
end

def callback(conn, %{"code" => code}) do
  %{token: token} = Keycloak.get_token!(code: code)

  conn
  |> put_session(:token, token)
  |> redirect(to: "/manage")
end

Link to this section Summary

Functions

Returns the authorize url for the keycloak client.

Gets a token given a preconfigured OAuth2.Client.

Creates a OAuth2.Client using the keycloak configuration and attempts fetch a access token.

Link to this section Functions

Link to this function

authorize_url(client, params)

View Source

Specs

authorize_url(
  OAuth2.Client.t(),
  keyword()
) :: any()

Returns the authorize url for the keycloak client.

Link to this function

authorize_url!(params \\ [])

View Source
Link to this function

get_token(client, params, headers)

View Source

Specs

get_token(OAuth2.Client.t(), keyword(), keyword()) :: any()

Gets a token given a preconfigured OAuth2.Client.

Link to this function

get_token!(params \\ [], headers \\ [])

View Source

Specs

get_token!(keyword(), keyword()) :: any()

Creates a OAuth2.Client using the keycloak configuration and attempts fetch a access token.