From bb8ae87b79bdd3f384c3259b0d02eeb214e125dd Mon Sep 17 00:00:00 2001 From: nanawel Date: Wed, 20 Nov 2024 10:44:53 +0100 Subject: [PATCH 1/2] Added Authentik support --- .env.example | 9 ++++- app/Enum/OauthProvidersType.php | 1 + app/Providers/EventServiceProvider.php | 2 + composer.json | 1 + composer.lock | 52 +++++++++++++++++++++++++- config/services.php | 7 ++++ resources/js/lychee.d.ts | 2 +- resources/js/services/oauth-service.ts | 2 + 8 files changed, 72 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index 7dd9377434b..81fa9bc5e80 100644 --- a/.env.example +++ b/.env.example @@ -164,8 +164,8 @@ VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" # MICROSOFT_CLIENT_SECRET= # MICROSOFT_REDIRECT_URI=/auth/microsoft/redirect -# NEXTCLOUD_CLIENT_ID= -# NEXTCLOUD_CLIENT_SECRET= +# NEXTCLOUD_CLIENT_ID= +# NEXTCLOUD_CLIENT_SECRET= # NEXTCLOUD_REDIRECT_URI=/auth/nextcloud/redirect # NEXTCLOUD_BASE_URI= @@ -175,6 +175,11 @@ VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" # KEYCLOAK_BASE_URL= # KEYCLOAK_REALM= +# AUTHENTIK_BASE_URL= +# AUTHENTIK_CLIENT_ID= +# AUTHENTIK_CLIENT_SECRET= +# AUTHENTIK_REDIRECT_URI=/auth/authentik/redirect + # AWS support data # AWS_ACCESS_KEY_ID= diff --git a/app/Enum/OauthProvidersType.php b/app/Enum/OauthProvidersType.php index fea58a0d92f..72f6a7a490a 100644 --- a/app/Enum/OauthProvidersType.php +++ b/app/Enum/OauthProvidersType.php @@ -15,6 +15,7 @@ enum OauthProvidersType: string case AMAZON = 'amazon'; case APPLE = 'apple'; + case AUTHENTIK = 'authentik'; case FACEBOOK = 'facebook'; case GITHUB = 'github'; case GOOGLE = 'google'; diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index b550fbd5a90..704423fd1f7 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -6,6 +6,7 @@ use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use SocialiteProviders\Amazon\AmazonExtendSocialite; use SocialiteProviders\Apple\AppleExtendSocialite; +use SocialiteProviders\Authentik\AuthentikExtendSocialite; use SocialiteProviders\Facebook\FacebookExtendSocialite; use SocialiteProviders\GitHub\GitHubExtendSocialite; use SocialiteProviders\Google\GoogleExtendSocialite; @@ -28,6 +29,7 @@ class EventServiceProvider extends ServiceProvider SocialiteWasCalled::class => [ AmazonExtendSocialite::class . '@handle', AppleExtendSocialite::class . '@handle', + AuthentikExtendSocialite::class . '@handle', FacebookExtendSocialite::class . '@handle', GitHubExtendSocialite::class . '@handle', GoogleExtendSocialite::class . '@handle', diff --git a/composer.json b/composer.json index b819927f5e5..f1a147e5d39 100644 --- a/composer.json +++ b/composer.json @@ -70,6 +70,7 @@ "revolution/socialite-mastodon": "^1.4", "socialiteproviders/amazon": "^4.1", "socialiteproviders/apple": "^5.6", + "socialiteproviders/authentik": "^5.2", "socialiteproviders/facebook": "^4.1", "socialiteproviders/github": "^4.1", "socialiteproviders/google": "^4.1", diff --git a/composer.lock b/composer.lock index fc3f7e84912..fbddfbf7fce 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "944eebb86d8d8411624c23982cf8a9c4", + "content-hash": "24b4c68e469e17a8ca89078b6976dbf3", "packages": [ { "name": "amphp/amp", @@ -7633,6 +7633,56 @@ }, "time": "2023-12-06T14:43:17+00:00" }, + { + "name": "socialiteproviders/authentik", + "version": "5.2.0", + "source": { + "type": "git", + "url": "https://github.com/SocialiteProviders/Authentik.git", + "reference": "4cf129cf04728a38e0531c54454464b162f0fa66" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/SocialiteProviders/Authentik/zipball/4cf129cf04728a38e0531c54454464b162f0fa66", + "reference": "4cf129cf04728a38e0531c54454464b162f0fa66", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^8.0", + "socialiteproviders/manager": "^4.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "SocialiteProviders\\Authentik\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "rf152", + "email": "git@rf152.co.uk" + } + ], + "description": "Authentik OAuth2 Provider for Laravel Socialite", + "keywords": [ + "authentik", + "laravel", + "oauth", + "provider", + "socialite" + ], + "support": { + "docs": "https://socialiteproviders.com/authentik", + "issues": "https://github.com/socialiteproviders/providers/issues", + "source": "https://github.com/socialiteproviders/providers" + }, + "time": "2023-11-07T22:21:16+00:00" + }, { "name": "socialiteproviders/facebook", "version": "4.1.0", diff --git a/config/services.php b/config/services.php index 1d0f877a1e3..d5cb618de83 100644 --- a/config/services.php +++ b/config/services.php @@ -51,6 +51,13 @@ 'redirect' => env('APPLE_REDIRECT_URI', '/auth/apple/redirect'), ], + 'authentik' => [ + 'client_id' => env('AUTHENTIK_CLIENT_ID'), + 'client_secret' => env('AUTHENTIK_CLIENT_SECRET'), + 'redirect' => env('AUTHENTIK_REDIRECT_URI'), + 'base_url' => env('AUTHENTIK_BASE_URL'), + ], + 'facebook' => [ 'client_id' => env('FACEBOOK_CLIENT_ID'), 'client_secret' => env('FACEBOOK_CLIENT_SECRET'), diff --git a/resources/js/lychee.d.ts b/resources/js/lychee.d.ts index a9c1076ed91..46a0dec488c 100644 --- a/resources/js/lychee.d.ts +++ b/resources/js/lychee.d.ts @@ -72,7 +72,7 @@ declare namespace App.Enum { | "CC-BY-NC-SA-3.0" | "CC-BY-NC-SA-4.0"; export type MapProviders = "Wikimedia" | "OpenStreetMap.org" | "OpenStreetMap.de" | "OpenStreetMap.fr" | "RRZE"; - export type OauthProvidersType = "amazon" | "apple" | "facebook" | "github" | "google" | "mastodon" | "microsoft" | "nextcloud" | "keycloak"; + export type OauthProvidersType = "amazon" | "apple" | "authentik" | "facebook" | "github" | "google" | "mastodon" | "microsoft" | "nextcloud" | "keycloak"; export type OrderSortingType = "ASC" | "DESC"; export type PhotoLayoutType = "square" | "justified" | "unjustified" | "masonry" | "grid"; export type SeverityType = "emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug"; diff --git a/resources/js/services/oauth-service.ts b/resources/js/services/oauth-service.ts index 10c4397641c..e3073ea2116 100644 --- a/resources/js/services/oauth-service.ts +++ b/resources/js/services/oauth-service.ts @@ -12,6 +12,8 @@ const OauthService = { return "fa-brands fa-apple"; case "amazon": return "fa-brands fa-amazon"; + case "authentik": + return "fa-brands fa-key"; case "facebook": return "fa-brands fa-facebook"; case "github": From 08db13d5df45990ef8b944178fc9abd80f843fa5 Mon Sep 17 00:00:00 2001 From: ildyria Date: Wed, 20 Nov 2024 12:21:05 +0100 Subject: [PATCH 2/2] formatting --- resources/js/lychee.d.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/resources/js/lychee.d.ts b/resources/js/lychee.d.ts index 46a0dec488c..5173e4fedd0 100644 --- a/resources/js/lychee.d.ts +++ b/resources/js/lychee.d.ts @@ -72,7 +72,17 @@ declare namespace App.Enum { | "CC-BY-NC-SA-3.0" | "CC-BY-NC-SA-4.0"; export type MapProviders = "Wikimedia" | "OpenStreetMap.org" | "OpenStreetMap.de" | "OpenStreetMap.fr" | "RRZE"; - export type OauthProvidersType = "amazon" | "apple" | "authentik" | "facebook" | "github" | "google" | "mastodon" | "microsoft" | "nextcloud" | "keycloak"; + export type OauthProvidersType = + | "amazon" + | "apple" + | "authentik" + | "facebook" + | "github" + | "google" + | "mastodon" + | "microsoft" + | "nextcloud" + | "keycloak"; export type OrderSortingType = "ASC" | "DESC"; export type PhotoLayoutType = "square" | "justified" | "unjustified" | "masonry" | "grid"; export type SeverityType = "emergency" | "alert" | "critical" | "error" | "warning" | "notice" | "info" | "debug";