services/src/main/java/org/keycloak/services/resources/admin/UserClientRoleMappingsResource.java
/**
     * Add client-level roles to the user role mapping.
     *
      * @param roles
     */
Add client-level roles to the user role mapping.

@param roles
Add client - level roles to the user role mapping . @param roles
@POST
    @Consumes(MediaType.APPLICATION_JSON)
    public void addClientRoleMapping(List<RoleRepresentation> roles) {
        auth.requireManage();
        for (RoleRepresentation role : roles) {
            RoleModel roleModel = client.getRole(role.getName());
            if (roleModel == null || !roleModel.getId().equals(role.getId())) {
                throw new NotFoundException("Role not found");
            }
            user.grantRole(roleModel);
        }
        adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo).representation(roles).success();
    }
@ POST @ Consumes ( MediaType . APPLICATION_JSON ) public void addClientRoleMapping ( List < RoleRepresentation > roles ) { auth . requireManage ( ) ; for ( RoleRepresentation role : roles ) { RoleModel roleModel = client . getRole ( role . getName ( ) ) ; if ( roleModel == null || ! roleModel . getId ( ) . equals ( role . getId ( ) ) ) { throw new NotFoundException ( "Role not found" ) ; } user . grantRole ( roleModel ) ; } adminEvent . operation ( OperationType . CREATE ) . resourcePath ( uriInfo ) . representation ( roles ) . success ( ) ; }
Add client-level roles to the user role mapping.
Add client - level roles to the user role mapping .