-
Notifications
You must be signed in to change notification settings - Fork 10
Add Client resource type and scopes to authorization schema #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature-clients-authz-baseline
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |||||||||||
| */ | ||||||||||||
| package org.keycloak.services.resources.admin.permissions; | ||||||||||||
|
|
||||||||||||
| import org.keycloak.models.AdminRoles; | ||||||||||||
| import org.keycloak.models.ClientModel; | ||||||||||||
| import org.keycloak.models.ClientScopeModel; | ||||||||||||
|
|
||||||||||||
|
|
@@ -31,54 +32,161 @@ public interface ClientPermissionEvaluator { | |||||||||||
|
|
||||||||||||
| void setPermissionsEnabled(ClientModel client, boolean enable); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Throws ForbiddenException if {@link #canListClientScopes()} returns {@code false}. | ||||||||||||
| */ | ||||||||||||
| void requireListClientScopes(); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if the caller has {@link org.keycloak.models.AdminRoles#MANAGE_CLIENTS} role. | ||||||||||||
| * <p/> | ||||||||||||
| * For V2 only: Also if it has permission to {@link org.keycloak.authorization.AdminPermissionsSchema#MANAGE}. | ||||||||||||
| */ | ||||||||||||
| boolean canManage(); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Throws ForbiddenException if {@link #canManage()} returns {@code false}. | ||||||||||||
| */ | ||||||||||||
| void requireManage(); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if the caller has {@link org.keycloak.models.AdminRoles#MANAGE_CLIENTS} role. | ||||||||||||
| * <p/> | ||||||||||||
| * For V2 only: Also if it has permission to {@link org.keycloak.authorization.AdminPermissionsSchema#MANAGE}. | ||||||||||||
| */ | ||||||||||||
| boolean canManageClientScopes(); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Throws ForbiddenException if {@link #canManageClientScopes()} returns {@code false}. | ||||||||||||
| */ | ||||||||||||
| void requireManageClientScopes(); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if the caller has at least one of the {@link org.keycloak.models.AdminRoles#MANAGE_CLIENTS} or {@link org.keycloak.models.AdminRoles#VIEW_CLIENTS} roles. | ||||||||||||
| * <p/> | ||||||||||||
| * For V2 only: Also if it has permission to {@link org.keycloak.authorization.AdminPermissionsSchema#VIEW}. | ||||||||||||
| */ | ||||||||||||
| boolean canView(); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if {@link #canView()} returns {@code true}. | ||||||||||||
| * <p/> | ||||||||||||
| * Or if the caller has at least one of the {@link AdminRoles#QUERY_CLIENTS} or {@link AdminRoles#QUERY_USERS} roles. | ||||||||||||
| */ | ||||||||||||
| boolean canList(); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if {@link #canView()} returns {@code true}. | ||||||||||||
| */ | ||||||||||||
| boolean canViewClientScopes(); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Throws ForbiddenException if {@link #canList()} returns {@code false}. | ||||||||||||
| */ | ||||||||||||
| void requireList(); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if {@link #canView()} returns {@code true}. | ||||||||||||
| * <p/> | ||||||||||||
| * Or if the caller has {@link AdminRoles#QUERY_CLIENTS} role. | ||||||||||||
| */ | ||||||||||||
| boolean canListClientScopes(); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if {@link #canView()} returns {@code true}. | ||||||||||||
| */ | ||||||||||||
| void requireView(); | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. syntax: Method signature indicates it should return boolean but documentation says it returns true
Suggested change
|
||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if {@link #canViewClientScopes()} returns {@code true}. | ||||||||||||
| */ | ||||||||||||
| void requireViewClientScopes(); | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. syntax: Method signature indicates it should return void but documentation says it returns true
Suggested change
|
||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if the caller has {@link org.keycloak.models.AdminRoles#MANAGE_CLIENTS} role. | ||||||||||||
| * <p/> | ||||||||||||
| * Or if the caller has a permission to {@link AdminPermissionManagement#MANAGE_SCOPE} the client. | ||||||||||||
| * <p/> | ||||||||||||
| * For V2 only: Also if the caller has a permission to {@link org.keycloak.authorization.AdminPermissionsSchema#MANAGE} all clients. | ||||||||||||
| */ | ||||||||||||
| boolean canManage(ClientModel client); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if {@link #canManage(ClientModel)} returns {@code true}. | ||||||||||||
| * <p/> | ||||||||||||
| * Or if the caller has a permission to {@link ClientPermissionManagement#CONFIGURE_SCOPE} the client. | ||||||||||||
| * <p/> | ||||||||||||
| * For V2 only: Also if the caller has a permission to {@link org.keycloak.authorization.AdminPermissionsSchema#CONFIGURE} all clients. | ||||||||||||
| */ | ||||||||||||
| boolean canConfigure(ClientModel client); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Throws ForbiddenException if {@link #canConfigure(ClientModel)} returns {@code false}. | ||||||||||||
| */ | ||||||||||||
| void requireConfigure(ClientModel client); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Throws ForbiddenException if {@link #canManage(ClientModel)} returns {@code false}. | ||||||||||||
| */ | ||||||||||||
| void requireManage(ClientModel client); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if {@link #canView()} or {@link #canConfigure(ClientModel)} returns {@code true}. | ||||||||||||
| * <p/> | ||||||||||||
| * Or if the caller has a permission to {@link AdminPermissionManagement#VIEW_SCOPE} the client. | ||||||||||||
| * <p/> | ||||||||||||
| * For V2 only: Also if the caller has a permission to {@link org.keycloak.authorization.AdminPermissionsSchema#VIEW} all clients. | ||||||||||||
| */ | ||||||||||||
| boolean canView(ClientModel client); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Throws ForbiddenException if {@link #canView(ClientModel)} returns {@code false}. | ||||||||||||
| */ | ||||||||||||
| void requireView(ClientModel client); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if the caller has {@link org.keycloak.models.AdminRoles#MANAGE_CLIENTS} role. | ||||||||||||
| * <p/> | ||||||||||||
| * For V2 only: Also if it has permission to {@link org.keycloak.authorization.AdminPermissionsSchema#MANAGE}. | ||||||||||||
| */ | ||||||||||||
| boolean canManage(ClientScopeModel clientScope); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Throws ForbiddenException if {@link #canManage(ClientScopeModel)} returns {@code false}. | ||||||||||||
| */ | ||||||||||||
| void requireManage(ClientScopeModel clientScope); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if the caller has at least one of the {@link org.keycloak.models.AdminRoles#VIEW_CLIENTS} or {@link org.keycloak.models.AdminRoles#MANAGE_CLIENTS} roles. | ||||||||||||
| * <p/> | ||||||||||||
| * For V2 only: Also if it has permission to {@link org.keycloak.authorization.AdminPermissionsSchema#VIEW} or {@link org.keycloak.authorization.AdminPermissionsSchema#MANAGE}. | ||||||||||||
| */ | ||||||||||||
| boolean canView(ClientScopeModel clientScope); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Throws ForbiddenException if {@link #canView(ClientScopeModel)} returns {@code false}. | ||||||||||||
| */ | ||||||||||||
| void requireView(ClientScopeModel clientScope); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if the caller has a permission to {@link ClientPermissionManagement#MAP_ROLES_SCOPE} for the client. | ||||||||||||
| * <p/> | ||||||||||||
| * For V2 only: Also if the caller has a permission to {@link org.keycloak.authorization.AdminPermissionsSchema#MAP_ROLES} for all clients. | ||||||||||||
| */ | ||||||||||||
| boolean canMapRoles(ClientModel client); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if the caller has a permission to {@link ClientPermissionManagement#MAP_ROLES_COMPOSITE_SCOPE} for the client. | ||||||||||||
| * <p/> | ||||||||||||
| * For V2 only: Also if the caller has a permission to {@link org.keycloak.authorization.AdminPermissionsSchema#MAP_ROLES_COMPOSITE} for all clients. | ||||||||||||
| */ | ||||||||||||
| boolean canMapCompositeRoles(ClientModel client); | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Returns {@code true} if the caller has a permission to {@link ClientPermissionManagement#MAP_ROLES_CLIENT_SCOPE} for the client. | ||||||||||||
| * <p/> | ||||||||||||
| * For V2 only: Also if the caller has a permission to {@link org.keycloak.authorization.AdminPermissionsSchema#MAP_ROLES_CLIENT_SCOPE} for all clients. | ||||||||||||
| */ | ||||||||||||
| boolean canMapClientScopeRoles(ClientModel client); | ||||||||||||
|
|
||||||||||||
| Map<String, Boolean> getAccess(ClientModel client); | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Flag mismatch: using ADMIN_FINE_GRAINED_AUTHZ here while other methods use *_V2; if only V2 is enabled this listener will not run and permissions won’t be cleaned up