Download the PHP package colq2/laravel-keycloak without Composer
On this page you can find all versions of the php package colq2/laravel-keycloak. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-keycloak
IMPORTANT
This is going to be an easy-to-use keycloak adapter for laravel.
This is still in development and not ready for production.
Feel free to contribute to this.
To do
[ ] Allow different user storage's like Cache, Session, Eloquent, Database etc.
Installation
composer require colq2/laravel-keycloak
Publish config and migrations
php artisan vendor:publish --provider=colq2\Keycloak\KeycloakServiceProvider
This project redefines the user model and migrations. There is no need for password reset table. Furthermore we need another properties on the user (This are mostly the openid-connect defined properties):
- id
- sub
- username
- name
- picture
- roles
You can delete all migrations in your laravel project if you want to use keycloak as the only auth possibility.
Add following to your .env file:
Usage
Controller:
Routes:
Middleware
This package comes with CheckRealmAccess
and CheckResourceAccess
middleware. You can add them in the app/Http/Kernel.php
file.
Then you can use the middleware:
Realm Access Middleware
Resource Access Middleware
Custom User
The custom keycloak user saves the properties: id, sub, username, name, email and picture
To customize this you should do three things:
- Update migration
- Update User model
- Provide a custom Service
Update migrations
In the create_user_table migration you can add or remove your needed properties. By default you can use all claims that are defined in the openid-connect specs.
Update User Model
After you defined which properties you need. You have to define the same in the fillable attribute.
Provide a custom user service
The openid-connect claims have to be parsed to your custom properties. Just build a new class and extend the default User service. Then update the app binding to your user service.
In CustomUserService:
And bind this to your application in AppServiceProvider:
All versions of laravel-keycloak with dependencies
illuminate/auth Version ^5.8
illuminate/cache Version ^5.8
illuminate/contracts Version 5.8
illuminate/session Version ^5.8
illuminate/support Version ^5.8
stevenmaguire/oauth2-keycloak Version dev-master
lcobucci/jwt Version ^3.2
ext-json Version *