bala/keycloak-roles-permission

此项目用于keycloak权限管理

v1.1.0 2023-03-22 17:33 UTC

This package is auto-updated.

Last update: 2024-09-22 20:33:23 UTC


README

基于用户角色的基础API授权

安装

使用composer安装包

composer require bala/Keycloak-roles-permission

将中间件添加到你的kernal.php

protected $routeMiddleware = [
    ...
    'keycloak.role' => \Bala\Middleware\KeycloakRoleMiddleware::class
];

将变量添加到.env文件中

KEYCLOAK_ROLE_CLIENT="KEYCLOAK CLIENT ID"

用法

使用角色授权API

Route::get('example-protected-api', [ExampleController::class, 'index'])->middleware('keycloak.role:role name')

使用任何角色授权API

Route::get('example-protected-api', [ExampleController::class, 'index'])->middleware('keycloak.role:role1|role2')