Skip to content

Commit 60e7671

Browse files
Permissions search and policies improvements (#37256)
* Improved creating policy and adding it to permission Signed-off-by: Agnieszka Gancarczyk <[email protected]> * Added viewing policies Signed-off-by: Agnieszka Gancarczyk <[email protected]> * Added inital version of permissions search Signed-off-by: Agnieszka Gancarczyk <[email protected]> * improvements and refactor Signed-off-by: Agnieszka Gancarczyk <[email protected]> * updated messages Signed-off-by: Agnieszka Gancarczyk <[email protected]> * refactor Signed-off-by: Agnieszka Gancarczyk <[email protected]> --------- Signed-off-by: Agnieszka Gancarczyk <[email protected]>
1 parent 41839c6 commit 60e7671

File tree

16 files changed

+313
-442
lines changed

16 files changed

+313
-442
lines changed

js/apps/admin-ui/maven-resources/theme/keycloak.v2/admin/messages/messages_en.properties

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ requiredUserActions=Required user actions
8686
noConsentsText=The consents will only be recorded when users try to access a client that is configured to require consent. In that case, users will get a consent page which asks them to grant access to the client.
8787
addStep=Add step
8888
clientAssertionAudience=Client assertion audience
89-
permissionPoliciesHelp=Specifies all the policies that must be applied to the scopes defined by this policy or permission.
89+
permissionPoliciesHelp=Specifies all the policies that must be applied to the permission permission.
9090
userInitiatedActionLifespanHelp=Maximum time before an action permit sent by a user (such as a forgot password e-mail) is expired. This value is recommended to be short because it is expected that the user would react to a self-created action quickly.
9191
clearFileExplain=Are you sure you want to clear this file?
9292
userModelAttribute=User model attribute
@@ -3332,7 +3332,7 @@ deleteConfirmUsers_one=Delete user {{name}}?
33323332
deleteConfirmUsers_other=Delete {{count}} users?
33333333
downloadThemeJar=Download theme JAR
33343334
themeColorInfo=Here you can set the patternfly color variables and create a "theme jar" file that you can download and put in your providers folder to apply the theme to your realm.
3335-
permissionsSubTitle=Fine-grained admin permissions allow assigning detailed, specific access rights, controlling which resources and actions can be managed.
3335+
permissionsSubTitle=Permissions control access to a resource or multiple resources of one type.
33363336
signatureAlgorithmIdentityProviderMetadata=Signature algorithm SAML IdP metadata
33373337
signatureAlgorithmIdentityProviderMetadataHelp=Signature algorithm to use for the SAML identity provider metadata, if none the metadata is not signed.
33383338
connectionTrace=Connection trace
@@ -3342,18 +3342,18 @@ savingAdminEventsOff=Saving admin events turned off
33423342
membershipEvents=Membership events
33433343
childGroupEvents=Child group events
33443344
titlePermissions=Permissions
3345-
emptyPermissionsInstructions=If you want to create a permission, please click the button below.
3345+
emptyPermissionsInstructions=No permissions exist in this realm.
33463346
permissionsName=Permission name
33473347
permissionsAssignedPolicy=Assigned policy
33483348
chooseAResourceType=Choose a resource type
3349-
chooseAResourceTypeInstructions=Please choose a resource type first to determine which type of resource to grant new permission to.
3350-
resourceType.Clients=Client resource type description
3351-
resourceType.Groups=Group resource type description
3352-
resourceType.IdentityProviders=Identity providers resource type description
3353-
resourceType.Organizations=Organization resource type description
3354-
resourceType.Roles=Role resource type description
3355-
resourceType.Users=User resource type description
3356-
createPermissionOfType=Create {{resourceType}} permission
3349+
chooseAResourceTypeInstructions=Choose a resource type for which you will create a permission.
3350+
resourceType.Clients=Controls access to operations that can be performed for clients in this realm
3351+
resourceType.Groups=Controls access to operations that can be performed for groups in this realm
3352+
resourceType.IdentityProviders=Controls access to operations that can be performed for identity providers in this realm
3353+
resourceType.Organizations=Controls access to operations that can be performed for organizations in this realm
3354+
resourceType.Roles=Controls access to operations that can be performed for roles in this realm
3355+
resourceType.Users=Controls access to operations that can be performed for users in this realm
3356+
createPermissionOfType=This permission will be applied to the {{resourceType}}
33573357
permissionUsersHelpText=Specifies which user(s) are allowed by this permission.
33583358
permissionNameHelpText=The name of the permission. This name is used to identify the permission in the admin console.
33593359
resourceScope=Resource scope
@@ -3364,9 +3364,9 @@ allUsers=All users
33643364
specificUsers=Specific users
33653365
assignedPolicies=Assigned policies
33663366
assignExistingPolicies=Assign existing policies
3367-
requiredAssignedPolicies=Please add at least one policy.
3367+
requiredPolicies=Please add at least one policy.
33683368
createNewPolicy=Create new policy
3369-
createAPolicy=Create policy
3369+
createPermissionPolicy=Create policy
33703370
policy=Policy
33713371
policyType=Policy type
33723372
policyTypeHelpText=Specifies the type of policy. This is used to determine the type of policy that the permission is granted to.
@@ -3379,18 +3379,40 @@ noAssignedPoliciesInstructions=There are no assigned policies for this permissio
33793379
unAssignPolicy=Unassign
33803380
assignedPolicyType.allTypes=All types
33813381
assignedPolicyType.user=User
3382-
permissionPolicyDetails=Permission policy details
33833382
authorizationScopeDetailsTitle=Authorization scope details
3384-
authorizationScopeDetailsSubtitle=Authorization scope is ...
3383+
authorizationScopeDetailsSubtitle=Authorization scope defines the actions that can be performed on a resource.
33853384
authorizationScopeDetailsName=Name
33863385
authorizationScopeDetailsDescription=Description
33873386
authorizationScopeDetailsDescriptionText=Lorem ipsum
3388-
applyPermissionTo=Apply persmission to
3389-
applyPermissionToHelpText=Apply permission to helpp text
33903387
allResources=All resources
33913388
currentRealm=Current realm
33923389
recentlyUsed=Recently used
33933390
viewAll=View all
33943391
currentRealmExplain=This realm is selected
33953392
removeInvalidUsers=Remove invalid users during searches
3396-
removeInvalidUsersHelp=Remove users from the local database if they are not available from the user storage when executing searches. If this is true, users no longer available from their corresponding user storage will be deleted from the local database whenever trying to look up users. If false, then users previously imported from the user storage will be kept in the local database, as read-only and disabled, even if that user is no longer available from the user storage. For example, user was deleted directly from LDAP or the `Users DN` is invalid. Note that this behavior will only happen when the user is not yet cached.
3393+
removeInvalidUsersHelp=Remove users from the local database if they are not available from the user storage when executing searches. If this is true, users no longer available from their corresponding user storage will be deleted from the local database whenever trying to look up users. If false, then users previously imported from the user storage will be kept in the local database, as read-only and disabled, even if that user is no longer available from the user storage. For example, user was deleted directly from LDAP or the `Users DN` is invalid. Note that this behavior will only happen when the user is not yet cached.
3394+
createPermissionPolicy=Create permission policy
3395+
applyPermissionTo=Enforce access to
3396+
applyPermissionToHelpText=Specifies the resource that the permission is applied to.
3397+
emptyPermissionPoliciesInstructions=No policies exist in this realm.
3398+
noPermissionSearchResultsInstructions=No permissions matched your filters.
3399+
deleteAdminPermissionConfirm=If you delete permission {{ permission }}, administrators cannot perform the actions on resources that were defined by the permission.
3400+
authorizationScope.Clients.configure=Performs basic management of a client
3401+
authorizationScope.Clients.manage=Fully manages a client
3402+
authorizationScope.Clients.map-roles=Map roles defined by this client to resources such as users and groups
3403+
authorizationScope.Clients.map-roles-client-scope=Applies roles defined by this client to the client scope of another client
3404+
authorizationScope.Clients.map-roles-composite=Applies roles defined by this client as a composite to another role
3405+
authorizationScope.Clients.token-exchange=Controls which clients can exchange tokens for a token that is targeted to this client
3406+
authorizationScope.Clients.view=Views this client
3407+
authorizationScope.Users.impersonate=Impersonates other users
3408+
authorizationScope.Users.manage=Manages all users in the realm
3409+
authorizationScope.Users.manage-group-membership=Manages group membership for all users in the realm (used in conjunction with a group policy)
3410+
authorizationScope.Users.map-roles=Maps roles for all users
3411+
authorizationScope.Users.user-impersonated=Controls which users can be impersonated
3412+
authorizationScope.Users.view=Views all users in the realm
3413+
authorizationScope.Groups.manage=Manages this group
3414+
authorizationScope.Groups.manage-members=Manages group members
3415+
authorizationScope.Groups.manage-membership=Adds or removes group members
3416+
authorizationScope.Groups.view=Views this group
3417+
authorizationScope.Groups.view-members=Views group members
3418+
authorizationScope.IdentityProviders.token-exchange=Allows clients to exchange tokens for tokens issued by this identity provider

js/apps/admin-ui/src/clients/authorization/Policies.tsx

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { NewPolicyDialog } from "./NewPolicyDialog";
4141
import { SearchDropdown, SearchForm } from "./SearchDropdown";
4242
import { useIsAdminPermissionsClient } from "../../utils/useIsAdminPermissionsClient";
4343
import { toCreatePermissionPolicy } from "../../permissions-configuration/routes/NewPermissionPolicy";
44+
import { toPermissionPolicyDetails } from "../../permissions-configuration/routes/PermissionPolicyDetails";
4445

4546
type PoliciesProps = {
4647
clientId: string;
@@ -184,7 +185,17 @@ export const AuthorizationPolicies = ({
184185
policyProviders={policyProviders}
185186
onSelect={(p) =>
186187
navigate(
187-
toCreatePolicy({ id: clientId, realm, policyType: p.type! }),
188+
isAdminPermissionsClient
189+
? toCreatePermissionPolicy({
190+
realm,
191+
permissionClientId: clientId,
192+
policyType: p.type!,
193+
})
194+
: toCreatePolicy({
195+
id: clientId,
196+
realm,
197+
policyType: p.type!,
198+
}),
188199
)
189200
}
190201
toggleDialog={toggleDialog}
@@ -214,20 +225,13 @@ export const AuthorizationPolicies = ({
214225
<Button
215226
data-testid="createPolicy"
216227
onClick={() => {
217-
if (!isAdminPermissionsClient) {
218-
toggleDialog();
219-
} else {
220-
navigate(
221-
toCreatePermissionPolicy({
222-
realm,
223-
permissionClientId: clientId,
224-
}),
225-
);
226-
}
228+
toggleDialog();
227229
}}
228230
isDisabled={isDisabled}
229231
>
230-
{t("createPolicy")}
232+
{isAdminPermissionsClient
233+
? t("createPermissionPolicy")
234+
: t("createPolicy")}
231235
</Button>
232236
</ToolbarItem>
233237
</>
@@ -263,7 +267,18 @@ export const AuthorizationPolicies = ({
263267
}}
264268
/>
265269
<Td data-testid={`name-column-${policy.name}`}>
266-
{!isAdminPermissionsClient ? (
270+
{isAdminPermissionsClient ? (
271+
<Link
272+
to={toPermissionPolicyDetails({
273+
realm,
274+
permissionClientId: clientId,
275+
policyId: policy.id!,
276+
policyType: policy.type!,
277+
})}
278+
>
279+
{policy.name}
280+
</Link>
281+
) : (
267282
<Link
268283
to={toPolicyDetails({
269284
realm,
@@ -274,8 +289,6 @@ export const AuthorizationPolicies = ({
274289
>
275290
{policy.name}
276291
</Link>
277-
) : (
278-
policy.name
279292
)}
280293
</Td>
281294
<Td>{toUpperCase(policy.type!)}</Td>
@@ -367,27 +380,36 @@ export const AuthorizationPolicies = ({
367380
)}
368381
onSelect={(p) =>
369382
navigate(
370-
toCreatePolicy({ id: clientId, realm, policyType: p.type! }),
383+
isAdminPermissionsClient
384+
? toCreatePermissionPolicy({
385+
realm,
386+
permissionClientId: clientId,
387+
policyType: p.type!,
388+
})
389+
: toCreatePolicy({
390+
id: clientId,
391+
realm,
392+
policyType: p.type!,
393+
}),
371394
)
372395
}
373396
toggleDialog={toggleDialog}
374397
/>
375398
)}
376399
<ListEmptyState
377400
message={t("emptyPolicies")}
378-
instructions={t("emptyPoliciesInstructions")}
401+
instructions={
402+
isAdminPermissionsClient
403+
? t("emptyPermissionPoliciesInstructions")
404+
: t("emptyPoliciesInstructions")
405+
}
379406
isDisabled={isDisabled}
380-
primaryActionText={t("createPolicy")}
381-
onPrimaryAction={() =>
382-
!isAdminPermissionsClient
383-
? toggleDialog()
384-
: navigate(
385-
toCreatePermissionPolicy({
386-
realm,
387-
permissionClientId: clientId,
388-
}),
389-
)
407+
primaryActionText={
408+
isAdminPermissionsClient
409+
? t("createPermissionPolicy")
410+
: t("createPolicy")
390411
}
412+
onPrimaryAction={() => toggleDialog()}
391413
/>
392414
</>
393415
)}

js/apps/admin-ui/src/clients/authorization/ResourcesPolicySelect.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ import { toCreatePolicy } from "../routes/NewPolicy";
3434
import { toPolicyDetails } from "../routes/PolicyDetails";
3535
import { toResourceDetails } from "../routes/Resource";
3636
import { NewPolicyDialog } from "./NewPolicyDialog";
37+
import { useIsAdminPermissionsClient } from "../../utils/useIsAdminPermissionsClient";
3738

3839
type Type = "resources" | "policies";
3940

4041
type ResourcesPolicySelectProps = {
4142
name: Type;
4243
clientId: string;
43-
isPermissionClient?: boolean;
4444
permissionId?: string;
4545
variant?: Variant;
4646
preSelected?: string;
@@ -77,7 +77,6 @@ const typeMapping: TypeMapping = {
7777
export const ResourcesPolicySelect = ({
7878
name,
7979
clientId,
80-
isPermissionClient,
8180
permissionId,
8281
variant = SelectVariant.typeaheadMulti,
8382
preSelected,
@@ -101,6 +100,7 @@ export const ResourcesPolicySelect = ({
101100
useState<PolicyProviderRepresentation[]>();
102101
const [onUnsavedChangesConfirm, setOnUnsavedChangesConfirm] =
103102
useState<() => void>();
103+
const isAdminPermissionsClient = useIsAdminPermissionsClient(clientId);
104104

105105
const functions = typeMapping[name];
106106

@@ -282,7 +282,7 @@ export const ResourcesPolicySelect = ({
282282
typeAheadAriaLabel={t(name)}
283283
chipGroupComponent={toChipGroupItems(field)}
284284
footer={
285-
name === "policies" && !isPermissionClient ? (
285+
name === "policies" && !isAdminPermissionsClient ? (
286286
<Button
287287
variant="link"
288288
isInline

0 commit comments

Comments
 (0)