Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitLab OAuth provider #264

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,24 @@ Accent provides a default value for every required environment variable. This me

Various login providers are included in Accent using Ueberauth to abstract services.

| Variable | Default | Description |
| -------------------------- | ------- | --------------------------------------------------------------------------------------- |
| `DUMMY_LOGIN_ENABLED` | _none_ | If specified, the password-less authentication (with only the email) will be available. |
| `GITHUB_CLIENT_ID` | _none_ | |
| `GITHUB_CLIENT_SECRET` | _none_ | |
| `GOOGLE_API_CLIENT_ID` | _none_ | |
| `GOOGLE_API_CLIENT_SECRET` | _none_ | |
| `SLACK_CLIENT_ID` | _none_ | |
| `SLACK_CLIENT_SECRET` | _none_ | |
| `SLACK_TEAM_ID` | _none_ | |
| `DISCORD_CLIENT_ID` | _none_ | |
| `DISCORD_CLIENT_SECRET` | _none_ | |
| `MICROSOFT_CLIENT_ID` | _none_ | |
| `MICROSOFT_CLIENT_SECRET` | _none_ | |
| `MICROSOFT_TENANT_ID` | _none_ | |
| Variable | Default | Description |
| -------------------------- | -------------------- | --------------------------------------------------------------------------------------- |
| `DUMMY_LOGIN_ENABLED` | _none_ | If specified, the password-less authentication (with only the email) will be available. |
| `GITHUB_CLIENT_ID` | _none_ | |
| `GITHUB_CLIENT_SECRET` | _none_ | |
| `GITLAB_CLIENT_ID` | _none_ | |
| `GITLAB_CLIENT_SECRET` | _none_ | |
| `GITLAB_SITE_URL` | _https://gitlab.com_ | |
| `GOOGLE_API_CLIENT_ID` | _none_ | |
| `GOOGLE_API_CLIENT_SECRET` | _none_ | |
| `SLACK_CLIENT_ID` | _none_ | |
| `SLACK_CLIENT_SECRET` | _none_ | |
| `SLACK_TEAM_ID` | _none_ | |
| `DISCORD_CLIENT_ID` | _none_ | |
| `DISCORD_CLIENT_SECRET` | _none_ | |
| `MICROSOFT_CLIENT_ID` | _none_ | |
| `MICROSOFT_CLIENT_SECRET` | _none_ | |
| `MICROSOFT_TENANT_ID` | _none_ | |

### Email setup

Expand Down
9 changes: 9 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ providers = []
providers = if System.get_env("GOOGLE_API_CLIENT_ID"), do: [{:google, {Ueberauth.Strategy.Google, [scope: "email openid"]}} | providers], else: providers
providers = if System.get_env("SLACK_CLIENT_ID"), do: [{:slack, {Ueberauth.Strategy.Slack, [team: System.get_env("SLACK_TEAM_ID")]}} | providers], else: providers
providers = if System.get_env("GITHUB_CLIENT_ID"), do: [{:github, {Ueberauth.Strategy.Github, [default_scope: "user"]}} | providers], else: providers
providers = if System.get_env("GITLAB_CLIENT_ID"), do: [{:gitlab, {Ueberauth.Strategy.Gitlab, [default_scope: "read_user"]}} | providers], else: providers
providers = if System.get_env("DISCORD_CLIENT_ID"), do: [{:discord, {Ueberauth.Strategy.Discord, [default_scope: "identify email"]}} | providers], else: providers
providers = if System.get_env("MICROSOFT_CLIENT_ID"), do: [{:microsoft, {Ueberauth.Strategy.Microsoft, []}} | providers], else: providers
providers = if System.get_env("DUMMY_LOGIN_ENABLED"), do: [{:dummy, {Accent.Auth.Ueberauth.DummyStrategy, []}} | providers], else: providers
Expand All @@ -81,6 +82,14 @@ config :ueberauth, Ueberauth.Strategy.Github.OAuth,
client_id: System.get_env("GITHUB_CLIENT_ID"),
client_secret: System.get_env("GITHUB_CLIENT_SECRET")

config :ueberauth, Ueberauth.Strategy.Gitlab.OAuth,
client_id: System.get_env("GITLAB_CLIENT_ID"),
client_secret: System.get_env("GITLAB_CLIENT_SECRET"),
redirect_uri: "#{canonical_url}/auth/gitlab/callback",
site: System.get_env("GITLAB_SITE_URL") || "https://gitlab.com",
authorize_url: "#{System.get_env("GITLAB_SITE_URL") || "https://gitlab.com"}/oauth/authorize",
token_url: "#{System.get_env("GITLAB_SITE_URL") || "https://gitlab.com"}/oauth/token"

config :ueberauth, Ueberauth.Strategy.Slack.OAuth,
client_id: System.get_env("SLACK_CLIENT_ID"),
client_secret: System.get_env("SLACK_CLIENT_SECRET")
Expand Down
1 change: 1 addition & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ defmodule Accent.Mixfile do
{:ueberauth, "~> 0.6"},
{:ueberauth_google, "~> 0.6"},
{:ueberauth_github, "~> 0.7"},
{:ueberauth_gitlab_strategy, "~> 0.3"},
{:ueberauth_slack, github: "ueberauth/ueberauth_slack", ref: "525594c870f959ab"},
{:ueberauth_discord, "~> 0.5"},
{:ueberauth_microsoft, "~> 0.7"},
Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"ueberauth": {:hex, :ueberauth, "0.6.3", "d42ace28b870e8072cf30e32e385579c57b9cc96ec74fa1f30f30da9c14f3cc0", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "afc293d8a1140d6591b53e3eaf415ca92842cb1d32fad3c450c6f045f7f91b60"},
"ueberauth_discord": {:hex, :ueberauth_discord, "0.6.0", "d6ec040e4195c4138b9a959c79024ab4c213ba1aed9fc08099ecff141a6486da", [:mix], [{:oauth2, "~> 1.0 or ~> 2.0", [hex: :oauth2, repo: "hexpm", optional: false]}, {:ueberauth, "~> 0.6.3", [hex: :ueberauth, repo: "hexpm", optional: false]}], "hexpm", "c5ea960191c1d6c3a974947cae4d57efa565a9a0796b8e82bee45fac7ae2fabc"},
"ueberauth_github": {:hex, :ueberauth_github, "0.8.0", "2216c8cdacee0de6245b422fb397921b64a29416526985304e345dab6a799d17", [:mix], [{:oauth2, "~> 1.0 or ~> 2.0", [hex: :oauth2, repo: "hexpm", optional: false]}, {:ueberauth, "~> 0.6.0", [hex: :ueberauth, repo: "hexpm", optional: false]}], "hexpm", "b65ccc001a7b0719ba069452f3333d68891f4613ae787a340cce31e2a43307a3"},
"ueberauth_gitlab_strategy": {:hex, :ueberauth_gitlab_strategy, "0.3.0", "87bf475a749f135ace3ab1bca71c17f761edb38b977fcdb851b84cc4e96dbd97", [:mix], [{:oauth2, "~> 2.0", [hex: :oauth2, repo: "hexpm", optional: false]}, {:ueberauth, "~> 0.4", [hex: :ueberauth, repo: "hexpm", optional: false]}], "hexpm", "4853d8868718e2d3373d179f8a8b1831d973a5d95fa45791ae64715426aa30fb"},
"ueberauth_google": {:hex, :ueberauth_google, "0.10.0", "ae00e7228207be977d5cdd0a562e39961851cea74f513aab6446cb51468f283c", [:mix], [{:oauth2, "~> 1.0 or ~> 2.0", [hex: :oauth2, repo: "hexpm", optional: false]}, {:ueberauth, "~> 0.6.3", [hex: :ueberauth, repo: "hexpm", optional: false]}], "hexpm", "148e2575fd24a29b8bcaa44f9d3d1a38550a74ceed645f5059d4516b93992650"},
"ueberauth_microsoft": {:hex, :ueberauth_microsoft, "0.10.0", "5c6cbf7ee59ee2e34a5d6a3738c6a136acc64f4077618c271bf24e11357af038", [:mix], [{:oauth2, "~> 1.0 or ~> 2.0", [hex: :oauth2, repo: "hexpm", optional: false]}, {:ueberauth, "~> 0.6", [hex: :ueberauth, repo: "hexpm", optional: false]}], "hexpm", "51b39750e2d119a8b5a7d63e1ce686fb3c29061838ba62cba84dcd2760d2a66f"},
"ueberauth_slack": {:git, "https://github.com/ueberauth/ueberauth_slack.git", "525594c870f959aba67acc759d5c1a588ee75e9e", [ref: "525594c870f959ab"]},
Expand Down
1 change: 1 addition & 0 deletions webapp/app/locales/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
},
"login_forms": {
"github": "Login with GitHub →",
"gitlab": "Login with GitLab →",
"google": "Login with Google →",
"slack": "Login with Slack →",
"discord": "Login with Discord →",
Expand Down
1 change: 1 addition & 0 deletions webapp/app/locales/fr-ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
},
"login_forms": {
"github": "Connectez-vous avec GitHub →",
"gitlab": "Connectez-vous avec GitLab →",
"google": "Connectez-vous avec Google →",
"slack": "Connectez-vous avec Slack →",
"discord": "Connectez-vous avec Discord →",
Expand Down
5 changes: 5 additions & 0 deletions webapp/app/pods/components/login-forms/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class LoginForms extends Component<Args> {

googleUrl = `${config.API.AUTHENTICATION_PATH}/google`;
githubUrl = `${config.API.AUTHENTICATION_PATH}/github`;
gitlabUrl = `${config.API.AUTHENTICATION_PATH}/gitlab`;
slackUrl = `${config.API.AUTHENTICATION_PATH}/slack`;
discordUrl = `${config.API.AUTHENTICATION_PATH}/discord`;
microsoftUrl = `${config.API.AUTHENTICATION_PATH}/microsoft`;
Expand All @@ -36,6 +37,10 @@ export default class LoginForms extends Component<Args> {
return this.providerIds.includes('github');
}

get gitlabLoginEnabled() {
return this.providerIds.includes('gitlab');
}

get slackLoginEnabled() {
return this.providerIds.includes('slack');
}
Expand Down
11 changes: 11 additions & 0 deletions webapp/app/pods/components/login-forms/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ a.loginButton {
}
}

&.loginButton--gitlab {
border: 2px solid #fc6d26;
text-shadow: none;
color: #fc6d26;

&:focus,
&:hover {
background: lighten(#fc6d26, 40%);
}
}

&.loginButton--slack {
border: 2px solid #3f0f3f;
text-shadow: none;
Expand Down
11 changes: 11 additions & 0 deletions webapp/app/pods/components/login-forms/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@
</a>
{{/if}}

{{#if this.gitlabLoginEnabled}}
<a
href={{this.gitlabUrl}}
class="button button--filled"
local-class="loginButton loginButton--gitlab"
>
<img src="assets/auth_providers/gitlab.svg" local-class="loginButton-logo">
{{t "components.login_forms.gitlab"}}
</a>
{{/if}}

{{#if this.slackLoginEnabled}}
<a
href={{this.slackUrl}}
Expand Down
34 changes: 34 additions & 0 deletions webapp/public/assets/auth_providers/gitlab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.