Skip to content

Commit

Permalink
Merge branch 'main' into web/replace-rollup-with-esbuild
Browse files Browse the repository at this point in the history
* main:
  web: bump API Client version (#8753)
  sources/oauth: add gitlab type [AUTH-323] (#8195)
  web: bump the babel group in /web with 4 updates (#8744)
  web: bump @types/grecaptcha from 3.0.7 to 3.0.8 in /web (#8745)
  web: bump chart.js from 4.4.1 to 4.4.2 in /web (#8746)
  web: bump chromedriver from 122.0.3 to 122.0.4 in /tests/wdio (#8747)
  core, web: update translations (#8743)
  ci: fix missing output on composite action (#8741)
  • Loading branch information
kensternberg-authentik committed Feb 29, 2024
2 parents 5ab00fc + 60a16aa commit 079d1d4
Show file tree
Hide file tree
Showing 14 changed files with 6,873 additions and 4,915 deletions.
4 changes: 4 additions & 0 deletions .github/actions/docker-push-variables/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ inputs:
description: "Docker image arch"

outputs:
shouldBuild:
description: "Whether to build image or not"
value: ${{ steps.ev.outputs.shouldBuild }}

sha:
description: "sha"
value: ${{ steps.ev.outputs.sha }}
Expand Down
1 change: 1 addition & 0 deletions authentik/sources/oauth/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"authentik.sources.oauth.types.discord",
"authentik.sources.oauth.types.facebook",
"authentik.sources.oauth.types.github",
"authentik.sources.oauth.types.gitlab",
"authentik.sources.oauth.types.google",
"authentik.sources.oauth.types.mailcow",
"authentik.sources.oauth.types.oidc",
Expand Down
9 changes: 9 additions & 0 deletions authentik/sources/oauth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,15 @@ class Meta:
verbose_name_plural = _("GitHub OAuth Sources")


class GitLabOAuthSource(OAuthSource):
"""Social Login using GitLab.com or a GitLab Instance."""

class Meta:
abstract = True
verbose_name = _("GitLab OAuth Source")
verbose_name_plural = _("GitLab OAuth Sources")


class TwitchOAuthSource(OAuthSource):
"""Social Login using Twitch."""

Expand Down
30 changes: 30 additions & 0 deletions authentik/sources/oauth/tests/test_type_gitlab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""GitLab Type tests"""

from django.test import TestCase

from authentik.sources.oauth.models import OAuthSource
from authentik.sources.oauth.types.gitlab import GitLabOAuthCallback

GITLAB_USER = {
"preferred_username": "dev_gitlab",
"email": "dev@gitlab.com",
"name": "Dev",
}


class TestTypeGitLab(TestCase):
"""OAuth Source tests for GitLab"""

def setUp(self):
self.source = OAuthSource.objects.create(
name="gitlab_test",
slug="gitlab_test",
provider_type="gitlab",
)

def test_enroll_context(self):
"""Test GitLab Enrollment context"""
ak_context = GitLabOAuthCallback().get_user_enroll_context(GITLAB_USER)
self.assertEqual(ak_context["username"], GITLAB_USER["preferred_username"])
self.assertEqual(ak_context["email"], GITLAB_USER["email"])
self.assertEqual(ak_context["name"], GITLAB_USER["name"])
54 changes: 54 additions & 0 deletions authentik/sources/oauth/types/gitlab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""
GitLab OAuth Views
See https://docs.gitlab.com/ee/integration/oauth_provider.html
and https://docs.gitlab.com/ee/integration/openid_connect_provider.html
"""

from typing import Any

from authentik.sources.oauth.models import OAuthSource
from authentik.sources.oauth.types.registry import SourceType, registry
from authentik.sources.oauth.views.callback import OAuthCallback
from authentik.sources.oauth.views.redirect import OAuthRedirect


class GitLabOAuthRedirect(OAuthRedirect):
"""GitLab OAuth2 Redirect"""

def get_additional_parameters(self, source: OAuthSource):
return {
"scope": ["read_user", "openid", "profile", "email"],
}


class GitLabOAuthCallback(OAuthCallback):
"""GitLab OAuth2 Callback"""

def get_user_enroll_context(
self,
info: dict[str, Any],
) -> dict[str, Any]:
return {
"username": info.get("preferred_username"),
"email": info.get("email"),
"name": info.get("name"),
}


@registry.register()
class GitLabType(SourceType):
"""GitLab Type definition"""

callback_view = GitLabOAuthCallback
redirect_view = GitLabOAuthRedirect
verbose_name = "GitLab"
name = "gitlab"

urls_customizable = True

authorization_url = "https://gitlab.com/oauth/authorize"
access_token_url = "https://gitlab.com/oauth/token" # nosec
profile_url = "https://gitlab.com/oauth/userinfo"
oidc_well_known_url = "https://gitlab.com/.well-known/openid-configuration"
oidc_jwks_url = "https://gitlab.com/oauth/discovery/keys"
1 change: 1 addition & 0 deletions blueprints/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4444,6 +4444,7 @@
"discord",
"facebook",
"github",
"gitlab",
"google",
"mailcow",
"okta",
Expand Down
4 changes: 3 additions & 1 deletion schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29699,7 +29699,7 @@ components:
* `authentik.events` - authentik Events
AppleChallengeResponseRequest:
type: object
description: Pseudo class for plex response
description: Pseudo class for apple response
properties:
component:
type: string
Expand Down Expand Up @@ -41406,6 +41406,7 @@ components:
- discord
- facebook
- github
- gitlab
- google
- mailcow
- okta
Expand All @@ -41421,6 +41422,7 @@ components:
* `discord` - Discord
* `facebook` - Facebook
* `github` - GitHub
* `gitlab` - GitLab
* `google` - Google
* `mailcow` - Mailcow
* `okta` - Okta
Expand Down
8 changes: 4 additions & 4 deletions tests/wdio/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/wdio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"node": ">=20"
},
"dependencies": {
"chromedriver": "^122.0.3"
"chromedriver": "^122.0.4"
}
}
Loading

0 comments on commit 079d1d4

Please sign in to comment.