mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 20:37:21 +00:00
Enhance authentication and authorization components
- Refactored `AppAuth` to introduce `getGuardContextSchema` for improved user context handling. - Updated `Authenticator` to utilize `pickKeys` for user data extraction in JWT generation. - Enhanced `Guard` class to improve permission checks and error handling. - Modified `SystemController` to return context schema alongside permissions in API responses. - Added new `permissions` method in `SystemApi` for fetching permissions. - Improved UI components with additional props and tooltip support for better user experience.
This commit is contained in:
@@ -125,7 +125,7 @@ export class Guard {
|
||||
return this.config?.enabled === true;
|
||||
}
|
||||
|
||||
private collect(permission: Permission, c: GuardContext, context: any) {
|
||||
private collect(permission: Permission, c: GuardContext | undefined, context: any) {
|
||||
const user = c && "get" in c ? c.get("auth")?.user : c;
|
||||
const ctx = {
|
||||
...((context ?? {}) as any),
|
||||
@@ -181,15 +181,15 @@ export class Guard {
|
||||
}
|
||||
|
||||
if (!role) {
|
||||
$console.debug("guard: user has no role, denying");
|
||||
throw new GuardPermissionsException(permission, undefined, "User has no role");
|
||||
} else if (role.implicit_allow === true) {
|
||||
$console.debug(`guard: role "${role.name}" has implicit allow, allowing`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!rolePermission) {
|
||||
$console.debug("guard: rolePermission not found, denying");
|
||||
if (role.implicit_allow === true) {
|
||||
$console.debug(`guard: role "${role.name}" has implicit allow, allowing`);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new GuardPermissionsException(
|
||||
permission,
|
||||
undefined,
|
||||
|
||||
Reference in New Issue
Block a user