Ueberauth.Strategy.Cognito (Ueberauth Cognito v0.6.0)

View Source

Implements an Ueberauth.Strategy for AWS Cognito.

Several options are available for configuring the strategy. The main keys you need to worry about are:

  • auth_domain
  • client_id
  • client_secret
  • user_pool_id
  • aws_region

These should all be available from your AWS Cognito setup, and are required. The following keys are optional:

  • scope - the OAuth scopes to request (defaults to "openid profile email")
  • uid_field - the id token claim used for auth.uid (defaults to "cognito:username")
  • name_field - the id token claim used for auth.info.name (defaults to "name")

Each value can be a string, an atom, or an {module, function, args} tuple resolved at runtime. Configuration can be set globally under config :ueberauth, Ueberauth.Strategy.Cognito, or per provider by passing the options in the provider tuple, which allows multiple Cognito providers backed by different user pools (see the README).

Additionally, there are a couple of options specifying what modules to use for some particular functions:

  • http_client
  • jwt_verifier

These are mainly used for dependency injection when testing and users of this library shouldn't have to concern themselves with them.

Summary

Functions

Returns standard Ueberauth.Auth.Credentials struct. The other key will be a map including a groups key, which is a list of any groups the user is associated with in Cognito

The raw_info key of the returned struct includes everything from the raw Cognito response in cognito_id_token.

Handle the callback step of the strategy.

Handles the cleanup step of the strategy.

Handle the request step of the strategy.

Fetches the fields to populate the info section of the Ueberauth.Auth struct.

Returns the username given in the Cognito response.

Functions

credentials(conn)

Returns standard Ueberauth.Auth.Credentials struct. The other key will be a map including a groups key, which is a list of any groups the user is associated with in Cognito

default_options()

Callback implementation for Ueberauth.Strategy.default_options/0.

extra(conn)

The raw_info key of the returned struct includes everything from the raw Cognito response in cognito_id_token.

handle_callback!(conn)

Handle the callback step of the strategy.

handle_cleanup!(conn)

Handles the cleanup step of the strategy.

handle_request!(conn)

Handle the request step of the strategy.

info(conn)

Fetches the fields to populate the info section of the Ueberauth.Auth struct.

uid(conn)

Returns the username given in the Cognito response.