Überauth v0.4.0 Ueberauth.Strategy.Helpers

Provides helper methods for use within your strategy.

These helpers are provided as a convenience for accessing the options passed to the specific pipelined strategy, considering the pipelined options and falling back to defaults.

Summary

Functions

Is the current request http method one of the allowed callback methods?

The configured allowed callback http methods

The callback path for the requests strategy

The full URL for the callback phase for the requests strategy

A helper for constructing error entries on failure

The full list of options passed to the strategy in the configuration

Redirects to a url and halts the plug pipeline

The request path for the strategy to hit

The full url for the request phase for the requests strategy

Sets a failure onto the connection containing a List of errors

The strategy module that is being used for the request

Provides the name of the strategy or provider name

Functions

allowed_callback_method?(conn)

Specs

allowed_callback_method?(Plug.Conn.t) :: boolean

Is the current request http method one of the allowed callback methods?

allowed_callback_methods(conn)

Specs

allowed_callback_methods(Plug.Conn.t) :: [String.t]

The configured allowed callback http methods.

This will use any supplied options from the configuration, but fallback to the default options

callback_path(conn)

Specs

callback_path(Plug.Conn.t) :: String.t

The callback path for the requests strategy.

When a client hits this path, the callback phase will be triggered for the strategy.

callback_url(conn, opts \\ [])

The full URL for the callback phase for the requests strategy.

The URL is based on the current requests host and scheme. The options will be encoded as query params.

error(key, message)

Specs

error(String.t, String.t) :: Ueberauth.Failure.Error.t
error(Plug.Conn.t, [Ueberauth.Failure.Error.t]) :: Plug.Conn.t

A helper for constructing error entries on failure.

The message_key is intended for use by machines for translations etc. The message is a human readable error message.

Example

error("something_bad", "Something really bad happened")
options(conn)

Specs

options(Plug.Conn.t) :: Keyword.t

The full list of options passed to the strategy in the configuration.

redirect!(conn, url)

Specs

redirect!(Plug.Conn.t, String.t) :: Plug.Conn.t

Redirects to a url and halts the plug pipeline.

request_path(conn)

Specs

request_path(Plug.Conn.t) :: String.t

The request path for the strategy to hit.

Requests to this path will trigger the request_phase of the strategy.

request_url(conn, opts \\ [])

The full url for the request phase for the requests strategy.

The URL is based on the current requests host and scheme. The options will be encoded as query params.

set_errors!(conn, errors)

Sets a failure onto the connection containing a List of errors.

During your callback phase, this should be called to ‘fail’ the authentication request and include a collection of errors outlining what the problem is.

Note this changes the conn object and should be part of your returned connection of the callback_phase!.

strategy(conn)

Specs

strategy(Plug.Conn.t) :: module

The strategy module that is being used for the request.

strategy_name(conn)

Specs

strategy_name(Plug.Conn.t) :: String.t

Provides the name of the strategy or provider name.

This is defined in your configuration as the provider name.