diff --git a/authentik/sources/oauth/tests/test_type_apple.py b/authentik/sources/oauth/tests/test_type_apple.py new file mode 100644 index 0000000000..bfe88d07f0 --- /dev/null +++ b/authentik/sources/oauth/tests/test_type_apple.py @@ -0,0 +1,37 @@ +"""Apple Type tests""" + +from django.test import RequestFactory, TestCase +from guardian.shortcuts import get_anonymous_user + +from authentik.lib.generators import generate_id +from authentik.lib.tests.utils import dummy_get_response +from authentik.root.middleware import SessionMiddleware +from authentik.sources.oauth.models import OAuthSource +from authentik.sources.oauth.types.registry import registry + + +class TestTypeApple(TestCase): + """OAuth Source tests""" + + def setUp(self): + self.source = OAuthSource.objects.create( + name="test", + slug="test", + provider_type="apple", + authorization_url="", + profile_url="", + consumer_key=generate_id(), + ) + self.factory = RequestFactory() + + def test_login_challenge(self): + """Test login_challenge""" + request = self.factory.get("/") + request.user = get_anonymous_user() + + middleware = SessionMiddleware(dummy_get_response) + middleware.process_request(request) + request.session.save() + oauth_type = registry.find_type("apple") + challenge = oauth_type().login_challenge(self.source, request) + self.assertTrue(challenge.is_valid(raise_exception=True)) diff --git a/authentik/sources/oauth/types/apple.py b/authentik/sources/oauth/types/apple.py index b8a9c0f912..08f3968a94 100644 --- a/authentik/sources/oauth/types/apple.py +++ b/authentik/sources/oauth/types/apple.py @@ -125,7 +125,7 @@ class AppleType(SourceType): ) args = apple_client.get_redirect_args() return AppleLoginChallenge( - instance={ + data={ "client_id": apple_client.get_client_id(), "scope": "name email", "redirect_uri": args["redirect_uri"], diff --git a/authentik/sources/plex/models.py b/authentik/sources/plex/models.py index 6f4e7def99..1e70d93dc1 100644 --- a/authentik/sources/plex/models.py +++ b/authentik/sources/plex/models.py @@ -66,7 +66,7 @@ class PlexSource(Source): icon = static("authentik/sources/plex.svg") return UILoginButton( challenge=PlexAuthenticationChallenge( - { + data={ "type": ChallengeTypes.NATIVE.value, "component": "ak-source-plex", "client_id": self.client_id, diff --git a/authentik/sources/plex/tests.py b/authentik/sources/plex/tests.py index 9e5eedefac..3b78e714cf 100644 --- a/authentik/sources/plex/tests.py +++ b/authentik/sources/plex/tests.py @@ -40,6 +40,11 @@ class TestPlexSource(TestCase): slug="test", ) + def test_login_challenge(self): + """Test login_challenge""" + ui_login_button = self.source.ui_login_button(None) + self.assertTrue(ui_login_button.challenge.is_valid(raise_exception=True)) + def test_get_user_info(self): """Test get_user_info""" token = generate_key() diff --git a/authentik/stages/identification/stage.py b/authentik/stages/identification/stage.py index 8be41825d5..ed61e8adad 100644 --- a/authentik/stages/identification/stage.py +++ b/authentik/stages/identification/stage.py @@ -237,6 +237,8 @@ class IdentificationStageView(ChallengeStageView): ) for source in sources: ui_login_button = source.ui_login_button(self.request) + if source.component == "": + continue if ui_login_button: button = asdict(ui_login_button) source_challenge = ui_login_button.challenge diff --git a/web/src/admin/stages/identification/IdentificationStageForm.ts b/web/src/admin/stages/identification/IdentificationStageForm.ts index 6201a453a4..75db877160 100644 --- a/web/src/admin/stages/identification/IdentificationStageForm.ts +++ b/web/src/admin/stages/identification/IdentificationStageForm.ts @@ -214,28 +214,23 @@ export class IdentificationStageForm extends BaseStageForm name="sources" >

${msg(