Add Authentik and Keycloak OAuth providers

This commit is contained in:
brufdev
2025-01-23 00:29:38 +00:00
parent a99c3c91cb
commit 4cb006d514
6 changed files with 223 additions and 11 deletions

View File

@@ -123,9 +123,9 @@ environment:
### Enable OAuth providers
Many Notes supports a convenient way to authenticate with OAuth providers. Typically, these credentials may be retrieved by creating a "developer application" within the dashboard of the service you wish to use. Many Notes currently supports authentication via Facebook, Twitter, LinkedIn, Google, GitHub, GitLab, Bitbucket, and Slack.
Many Notes supports a convenient way to authenticate with OAuth providers. Typically, these credentials may be retrieved by creating a "developer application" within the dashboard of the service you wish to use. Many Notes currently supports authentication via Facebook, Twitter, LinkedIn, Google, GitHub, GitLab, Bitbucket, Slack, Authentik, and Keycloak. You can enable multiple providers simultaneously by adding the corresponding environment variables.
For example, to enable GitHub OAuth, add:
For example, to enable GitHub OAuth, add:
```yaml
environment:
@@ -134,16 +134,27 @@ environment:
- GITHUB_REDIRECT=http://localhost/oauth/github/callback # change url
```
For example, to enable GitHub and Google OAuth, add:
**Authentik and Keycloak providers require additional configuration.**
To enable GitHub OAuth, add:
```yaml
environment:
- GITHUB_CLIENT_ID=CLIENT_ID # change id
- GITHUB_CLIENT_SECRET=CLIENT_SECRET # change secret
- GITHUB_REDIRECT=http://localhost/oauth/github/callback # change url
- GOOGLE_CLIENT_ID=CLIENT_ID # change id
- GOOGLE_CLIENT_SECRET=CLIENT_SECRET # change secret
- GOOGLE_REDIRECT=http://localhost/oauth/google/callback # change url
- AUTHENTIK_CLIENT_ID=CLIENT_ID # change id
- AUTHENTIK_CLIENT_SECRET=CLIENT_SECRET # change secret
- AUTHENTIK_REDIRECT=http://localhost/oauth/authentik/callback # change url
- AUTHENTIK_BASE_URL=http://your-authentik-domain # change url
```
To enable Keycloak OAuth, add:
```yaml
environment:
- KEYCLOAK_CLIENT_ID=CLIENT_ID # change id
- KEYCLOAK_CLIENT_SECRET=CLIENT_SECRET # change secret
- KEYCLOAK_REDIRECT=http://localhost/oauth/keycloak/callback # change url
- KEYCLOAK_BASE_URL=http://your-keycloak-domain # change url
- KEYCLOAK_REALM=YOUR_REALM # change realm
```
### Custom email service

View File

@@ -4,11 +4,13 @@ namespace App\Enums;
Enum OAuthProviders: string
{
case Authentik = 'authentik';
case Bitbucket = 'bitbucket';
case Facebook = 'facebook';
case GitHub = 'github';
case GitLab = 'gitlab';
case Google = 'google';
case Keycloak = 'keycloak';
case LinkedIn = 'linkedin';
case Slack = 'slack';
case Twitter = 'twitter';

View File

@@ -2,7 +2,10 @@
namespace App\Providers;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\ServiceProvider;
use SocialiteProviders\Authentik\Provider;
use SocialiteProviders\Manager\SocialiteWasCalled;
class AppServiceProvider extends ServiceProvider
{
@@ -19,6 +22,11 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot(): void
{
//
Event::listen(function (SocialiteWasCalled $event) {
$event->extendSocialite('authentik', Provider::class);
});
Event::listen(function (SocialiteWasCalled $event) {
$event->extendSocialite('keycloak', Provider::class);
});
}
}

View File

@@ -12,6 +12,8 @@
"laravel/socialite": "^5.16",
"laravel/tinker": "^2.9",
"livewire/livewire": "^3.5",
"socialiteproviders/authentik": "^5.2",
"socialiteproviders/keycloak": "^5.3",
"staudenmeir/laravel-adjacency-list": "^1.0"
},
"require-dev": {

176
composer.lock generated
View File

@@ -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": "a226053475881c565f700f9c0876a235",
"content-hash": "08facf171c5004da880c2bb86e9ba07b",
"packages": [
{
"name": "brick/math",
@@ -3812,6 +3812,180 @@
],
"time": "2024-04-27T21:32:50+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/keycloak",
"version": "5.3.0",
"source": {
"type": "git",
"url": "https://github.com/SocialiteProviders/Keycloak.git",
"reference": "87d13f8a411a6f8f5010ecbaff9aedd4494863e4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/SocialiteProviders/Keycloak/zipball/87d13f8a411a6f8f5010ecbaff9aedd4494863e4",
"reference": "87d13f8a411a6f8f5010ecbaff9aedd4494863e4",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": "^7.4 || ^8.0",
"socialiteproviders/manager": "~4.0"
},
"type": "library",
"autoload": {
"psr-4": {
"SocialiteProviders\\Keycloak\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Oleg Kuchumov",
"email": "voenniy@gmail.com"
}
],
"description": "Keycloak OAuth2 Provider for Laravel Socialite",
"keywords": [
"keycloak",
"laravel",
"oauth",
"provider",
"socialite"
],
"support": {
"docs": "https://socialiteproviders.com/keycloak",
"issues": "https://github.com/socialiteproviders/providers/issues",
"source": "https://github.com/socialiteproviders/providers"
},
"time": "2023-04-10T05:50:49+00:00"
},
{
"name": "socialiteproviders/manager",
"version": "v4.8.0",
"source": {
"type": "git",
"url": "https://github.com/SocialiteProviders/Manager.git",
"reference": "e93acc38f8464cc775a2b8bf09df311d1fdfefcb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/SocialiteProviders/Manager/zipball/e93acc38f8464cc775a2b8bf09df311d1fdfefcb",
"reference": "e93acc38f8464cc775a2b8bf09df311d1fdfefcb",
"shasum": ""
},
"require": {
"illuminate/support": "^8.0 || ^9.0 || ^10.0 || ^11.0",
"laravel/socialite": "^5.5",
"php": "^8.1"
},
"require-dev": {
"mockery/mockery": "^1.2",
"phpunit/phpunit": "^9.0"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"SocialiteProviders\\Manager\\ServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"SocialiteProviders\\Manager\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andy Wendt",
"email": "andy@awendt.com"
},
{
"name": "Anton Komarev",
"email": "a.komarev@cybercog.su"
},
{
"name": "Miguel Piedrafita",
"email": "soy@miguelpiedrafita.com"
},
{
"name": "atymic",
"email": "atymicq@gmail.com",
"homepage": "https://atymic.dev"
}
],
"description": "Easily add new or override built-in providers in Laravel Socialite.",
"homepage": "https://socialiteproviders.com",
"keywords": [
"laravel",
"manager",
"oauth",
"providers",
"socialite"
],
"support": {
"issues": "https://github.com/socialiteproviders/manager/issues",
"source": "https://github.com/socialiteproviders/manager"
},
"time": "2025-01-03T09:40:37+00:00"
},
{
"name": "staudenmeir/eloquent-has-many-deep-contracts",
"version": "v1.2.1",

View File

@@ -28,6 +28,13 @@ return [
'key' => env('RESEND_KEY'),
],
'authentik' => [
'base_url' => env('AUTHENTIK_BASE_URL'),
'client_id' => env('AUTHENTIK_CLIENT_ID'),
'client_secret' => env('AUTHENTIK_CLIENT_SECRET'),
'redirect' => env('AUTHENTIK_REDIRECT'),
],
'bitbucket' => [
'client_id' => env('BITBUCKET_CLIENT_ID'),
'client_secret' => env('BITBUCKET_CLIENT_SECRET'),
@@ -58,6 +65,14 @@ return [
'redirect' => env('GOOGLE_REDIRECT'),
],
'keycloak' => [
'client_id' => env('KEYCLOAK_CLIENT_ID'),
'client_secret' => env('KEYCLOAK_CLIENT_SECRET'),
'redirect' => env('KEYCLOAK_REDIRECT'),
'base_url' => env('KEYCLOAK_BASE_URL'),
'realms' => env('KEYCLOAK_REALM'),
],
'linkedin' => [
'client_id' => env('LINKEDIN_CLIENT_ID'),
'client_secret' => env('LINKEDIN_CLIENT_SECRET'),