jinna/keycloakapiservices

This is for keycloak rest api services

dev-main 2023-04-18 14:45 UTC

This package is auto-updated.

Last update: 2025-07-18 20:16:21 UTC


README

iSportz iSportz

Platformization Keycloak REST API Service

Platformization Keycloak is a Laravel package that gives you access to keycloak's admin REST APIs.

For API references visit Keycloak Admin REST API, To understand Keycloak Administration refer Server Administration Guide.

Getting Started

Installation

Keycloak admin API requires

PHP >= 8.0

Laravel >= 9.0

Guzzlehttp >= 7.2

Keycloakapiservices package require below dependency packages.

    "require": {
        "php": "^8.0",
        "laravel/framework": "^9.0",
        "guzzlehttp/guzzle": "^7.2"
    },

Run the below command to install the package.

composer require jinna/keycloakapiservices

Publish the keycloakapi config file using php artisan vendor:publish --provider="KeycloakApiServices\KeycloakApiServiceProvider" --tag="config", A config file keycloakapiservices.php will be created in config folder

Add KeycloakApiServices\KeycloakApiServiceProvider::class in config/app.php file, at the end of 'providers' => [] array like below.

'providers' => [
        App\Providers\EventServiceProvider::class,
        App\Providers\RouteServiceProvider::class,
        KeycloakApiServices\KeycloakApiServiceProvider::class
    ],

Add the below code in app/Providers/RouteServiceProvider.php file inside boot() method's $this->routes(function () {}) group like below.

    public function boot()
    {
        $this->configureRateLimiting();            
        $this->routes(function () {
            Route::prefix('api')
                ->middleware('api')
                ->namespace($this->namespace)
                ->group(base_path('vendor/jinna/keycloakapiservices/src/routes/api.php'));
        });
    }

Add/config the below variables in your .env file with appropriate values.

//Keycloak Server Url
KEYCLOAK_BASE_URL="https://keycloakauth.yourdomain.com"
KEYCLOAK_REALM_ENDPOINT=/admin/realms
KEYCLOAK_CLIENTS_ENDPOINT=/clients
KEYCLOAK_ROLES_ENDPOINT=/roles
KEYCLOAK_ADMIN_CLIENT_ID=admin-cli
KEYCLOAK_ADMIN_USERNAME=keycloakadminusername
KEYCLOAK_ADMIN_PASSWORD="keycloakadminpassword"

Documentation

Basic Usage

Refer the Postman collection Platform KeyCloak API.postman_collection which you can find inside this package folder.

License

Platformization Keycloak REST API Service is owned by iSportz . Reach out LICENSE for more details.