-
-
Notifications
You must be signed in to change notification settings - Fork 254
feat: add generic oidc schema #2012
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,107 @@ | ||||||||||||||||||||||||||||||||||
| <?php | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| namespace App\Extensions\OAuth\Schemas; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| use Filament\Forms\Components\ColorPicker; | ||||||||||||||||||||||||||||||||||
| use Filament\Forms\Components\TextInput; | ||||||||||||||||||||||||||||||||||
| use Filament\Infolists\Components\TextEntry; | ||||||||||||||||||||||||||||||||||
| use Filament\Schemas\Components\Wizard\Step; | ||||||||||||||||||||||||||||||||||
| use Illuminate\Support\Facades\Blade; | ||||||||||||||||||||||||||||||||||
| use Illuminate\Support\HtmlString; | ||||||||||||||||||||||||||||||||||
| use Kovah\LaravelSocialiteOidc\OidcProvider; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| final class GenericOidcSchema extends OAuthSchema | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| public function getId(): string | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| return 'oidc'; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| public function getSocialiteProvider(): string | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| return OidcProvider::class; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| public function getServiceConfig(): array | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| $config = array_merge(parent::getServiceConfig(), [ | ||||||||||||||||||||||||||||||||||
| 'base_url' => env('OAUTH_OIDC_BASE_URL'), | ||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| $realm = env('OAUTH_OIDC_REALM'); | ||||||||||||||||||||||||||||||||||
| if ($realm) { | ||||||||||||||||||||||||||||||||||
| $config['realm'] = $realm; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| return $config; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| public function getSetupSteps(): array | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| return array_merge([ | ||||||||||||||||||||||||||||||||||
| Step::make('Configure OIDC Provider') | ||||||||||||||||||||||||||||||||||
| ->schema([ | ||||||||||||||||||||||||||||||||||
| TextEntry::make('setup_instructions') | ||||||||||||||||||||||||||||||||||
| ->hiddenLabel() | ||||||||||||||||||||||||||||||||||
| ->state(new HtmlString(Blade::render('<p>Configure your OIDC provider (e.g., Keycloak, Auth0, Okta) with the following settings:</p><ul><li>Create an OAuth2/OpenID Connect application</li><li>Set the <b>Redirect URI</b> to the value below</li><li>Copy the <b>Client ID</b> and <b>Client Secret</b> for use in the configuration step</li></ul>'))), | ||||||||||||||||||||||||||||||||||
| TextInput::make('_noenv_callback') | ||||||||||||||||||||||||||||||||||
| ->label('Callback URL') | ||||||||||||||||||||||||||||||||||
| ->dehydrated() | ||||||||||||||||||||||||||||||||||
| ->disabled() | ||||||||||||||||||||||||||||||||||
| ->hintCopy() | ||||||||||||||||||||||||||||||||||
| ->default(fn () => url('/auth/oauth/callback/oidc')), | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+47
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use The TextInput::make('_noenv_callback')
->label('Callback URL')
- ->dehydrated()
+ ->dehydrated(false)
->disabled()
->hintCopy()
->default(fn () => url('/auth/oauth/callback/oidc')),🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| TextEntry::make('keycloak_note') | ||||||||||||||||||||||||||||||||||
| ->hiddenLabel() | ||||||||||||||||||||||||||||||||||
| ->state(new HtmlString('<p><b>For Keycloak:</b> The Base URL should point to your realm (e.g., <code>https://keycloak.example.com/realms/my-realm</code>). Optionally, you can specify the realm name separately.</p>')), | ||||||||||||||||||||||||||||||||||
| ]), | ||||||||||||||||||||||||||||||||||
| ], parent::getSetupSteps()); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
|
Comment on lines
+55
to
+59
|
||||||||||||||||||||||||||||||||||
| ->state(new HtmlString('<p><b>For Keycloak:</b> The Base URL should point to your realm (e.g., <code>https://keycloak.example.com/realms/my-realm</code>). Optionally, you can specify the realm name separately.</p>')), | |
| ]), | |
| ], parent::getSetupSteps()); | |
| } | |
| ->state($this->getKeycloakNoteHtml()), | |
| ]), | |
| ], parent::getSetupSteps()); | |
| } | |
| private function getKeycloakNoteHtml(): HtmlString | |
| { | |
| return new HtmlString(<<<'HTML' | |
| <p><b>For Keycloak:</b> The Base URL should point to your realm (e.g., <code>https://keycloak.example.com/realms/my-realm</code>). Optionally, you can specify the realm name separately.</p> | |
| HTML | |
| ); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setup instructions HTML string is too long and hard to maintain inline. Consider extracting this to a Blade component or view file for better readability and maintainability.