Go to file
Alexander Gabriel ce72d28912
Some checks failed
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, ubuntu-latest, 8.1, prefer-lowest, 8.*) (push) Has been cancelled
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, ubuntu-latest, 8.1, prefer-stable, 8.*) (push) Has been cancelled
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, ubuntu-latest, 8.2, prefer-lowest, 8.*) (push) Has been cancelled
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, ubuntu-latest, 8.2, prefer-stable, 8.*) (push) Has been cancelled
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, windows-latest, 8.1, prefer-lowest, 8.*) (push) Has been cancelled
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, windows-latest, 8.1, prefer-stable, 8.*) (push) Has been cancelled
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, windows-latest, 8.2, prefer-lowest, 8.*) (push) Has been cancelled
run-tests / P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} (2.*, 10.*, windows-latest, 8.2, prefer-stable, 8.*) (push) Has been cancelled
updated readme
2025-11-11 22:45:47 +00:00
.github configured plugin 2025-11-09 19:18:07 +00:00
bin configured plugin 2025-11-09 19:18:07 +00:00
config Typo in config 2025-11-11 18:25:31 +00:00
database/factories Login Logic 2025-11-10 19:29:35 +00:00
resources delete unneeded files 2025-11-10 19:37:04 +00:00
routes upgradet to filamentphp 4 2025-11-11 22:28:38 +00:00
src upgradet to filamentphp 4 2025-11-11 22:28:38 +00:00
tests configured plugin 2025-11-09 19:18:07 +00:00
.editorconfig Initial commit 2025-11-09 20:10:34 +01:00
.gitattributes Initial commit 2025-11-09 20:10:34 +01:00
.gitignore Initial commit 2025-11-09 20:10:34 +01:00
.prettierrc Initial commit 2025-11-09 20:10:34 +01:00
CHANGELOG.md configured plugin 2025-11-09 19:18:07 +00:00
composer.json updated package description 2025-11-11 22:45:40 +00:00
LICENSE.md configured plugin 2025-11-09 19:18:07 +00:00
package-lock.json updated plugin by documentation 2025-11-09 19:50:15 +00:00
package.json updated plugin by documentation 2025-11-09 19:50:15 +00:00
phpstan-baseline.neon Initial commit 2025-11-09 20:10:34 +01:00
phpstan.neon.dist Initial commit 2025-11-09 20:10:34 +01:00
phpunit.xml.dist configured plugin 2025-11-09 19:18:07 +00:00
pint.json Initial commit 2025-11-09 20:10:34 +01:00
postcss.config.cjs Initial commit 2025-11-09 20:10:34 +01:00
README_original.md made a copy of original readme 2025-11-11 18:36:26 +00:00
README.md updated readme 2025-11-11 22:45:47 +00:00
tailwind.config.js Initial commit 2025-11-09 20:10:34 +01:00

This is my package filament-oauth2

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

!!!
This Plugin is still under development and only tested with Keycloak.
This is my first FilamentPHP-Plugin.
Did not write any tests, not published to packagist yet...
Feedback welcome.
!!!

To be able to install you have to add/change this to/in your composer.json:

{
    "minimum-stability": "dev",
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/AlexanderGabriel/filament-oauth2"
        }
    ]
}

This Plugin enables OAuth2-Login for FilamentPHP Panels.
Login and logout is done by OAuth2-Server.
If the OAuth2-Server provides roles for your client, they will be mapped to the App\Models\Role-Model
Non-existing Roles will be created. Users will be detached to roles not in the access token any more.

Installation

You can install the package via composer:

composer require alexandergabriel/filament-oauth2

You can publish the config file with:

php artisan vendor:publish --tag="filament-oauth2-config"

This is the contents of the published config file:

return [
    'clientId' => env("OAUTH2_CLIENT_ID"),
    'clientSecret' => env("OAUTH2_CLIENT_SECRET"),
    'baseUrl' => env("OAUTH2_BASE_URL"), // https://DOMAIN/realms/REALM/protocol/openid-connect
    'urlAuthorize' => env("OAUTH2_URL_AUTHORIZE", env("OAUTH2_BASE_URL")."/auth"),
    'urlAccessToken' => env("OAUTH2_URL_ACCESS_TOKEN", env("OAUTH2_BASE_URL")."/token"),
    'urlResourceOwnerDetails' => env("OAUTH2_URL_RESOURCE_OWNER_DETAILS", env("OAUTH2_BASE_URL")."/userinfo"),
    'urlLogout' => env("OAUTH2_URL_LOGOUT", env("OAUTH2_BASE_URL")."/logout"),
    'urlAfterlogout' => env("OAUTH2_URL_AFTER_LOGOUT", url('/')),
    'scopes' => env("OAUTH2_SCOPES", "profile email openid"),
    'updateRoles' => env("OAUTH2_UPDATE_ROLES", false)
];

Usage

Load Plugin in your PanelProvider under filament-oauth2-demo/app/Providers/Filament:

class YOURPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->plugin(
                new FilamentOauth2Plugin()
            )

To configure, add some config to your .env:

  • OAUTH2_CLIENT_ID*
    • OAuth2 client id, mandatory
  • OAUTH2_CLIENT_SECRET*
    • OAuth2 client secret, mandatory
  • OAUTH2_BASE_URL*
  • OAUTH2_URL_AUTHORIZE
    • authorization url
    • defaults to OAUTH2_BASE_URL+/auth
  • OAUTH2_URL_ACCESS_TOKEN
    • token url
    • defaults to OAUTH2_BASE_URL+/token
  • OAUTH2_URL_RESOURCE_OWNER_DETAILS
    • resource owner details url
    • defaults to OAUTH2_BASE_URL+/userinfo
    • todo: needed?
  • OAUTH2_URL_LOGOUT
    • logout url
    • defaults to OAUTH2_BASE_URL+/logout
  • OAUTH2_URL_AFTER_LOGOUT
    • post_logout_redirect_uri
    • defaults to base url of Laravel app (without panel)
  • OAUTH2_SCOPES
    • scopes
    • defaults to "profile email openid"
  • OAUTH2_UPDATE_ROLES
    • look for roles in token and update/create and map them
    • defaults to false

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.