Ueberauth Gitlab v0.1.0 Ueberauth.Strategy.Gitlab
Provides an Ueberauth strategy for Gitlab. This is based on the GitHub strategy.
Configuration
Create a Gitlab application, and
write down its client_id
and client_secret
values.
Include the Gitlab provider in your Ueberauth configuration:
config :ueberauth, Ueberauth,
providers: [
...
gitlab: { Ueberauth.Strategy.Gitlab, [] }
]
The configure the Gitlab strategy:
config :ueberauth, Ueberauth.Strategy.Gitlab.OAuth,
client_id: System.get_env("GITLAB_CLIENT_ID"),
client_secret: System.get_env("GITLAB_CLIENT_SECRET")
You can edit the behaviour of the Strategy by including some options when you register your provider.
To set the uid_field
config :ueberauth, Ueberauth,
providers: [
...
gitlab: { Ueberauth.Strategy.Gitlab, [uid_field: :email] }
]
Default is :username
.
To set the default ‘scopes’ (permissions):
config :ueberauth, Ueberauth,
providers: [
gitlab: { Ueberauth.Strategy.Gitlab, [default_scope: "read_user,api"] }
]
Default is “read_user”
Summary
Functions
Includes the credentials from the Gitlab response
Stores the raw information (including the token) obtained from the Gitlab callback
Called when no code is received from Gitlab
Cleans up the private area of the connection used for passing the raw Gitlab response around during the callback
Handles the initial redirect to the gitlab authentication page
Fetches the fields to populate the info section of the Ueberauth.Auth
struct
Fetches the uid field from the Gitlab response. This defaults to the option uid_field
which in-turn
defaults to username
Functions
Cleans up the private area of the connection used for passing the raw Gitlab response around during the callback.
Handles the initial redirect to the gitlab authentication page.
To customize the scope (permissions) that are requested by gitlab include them as part of your url:
"/auth/gitlab?scope=read_user,api"
You can also include a state
param that gitlab will return to you.
Fetches the fields to populate the info section of the Ueberauth.Auth
struct.