Search in sources :

Example 6 with ManagementPermissionReference

use of org.keycloak.representations.idm.ManagementPermissionReference in project keycloak by keycloak.

the class IdentityProviderResource method toMgmtRef.

public static ManagementPermissionReference toMgmtRef(IdentityProviderModel model, AdminPermissionManagement permissions) {
    ManagementPermissionReference ref = new ManagementPermissionReference();
    ref.setEnabled(true);
    ref.setResource(permissions.idps().resource(model).getId());
    ref.setScopePermissions(permissions.idps().getPermissions(model));
    return ref;
}
Also used : ManagementPermissionReference(org.keycloak.representations.idm.ManagementPermissionReference)

Example 7 with ManagementPermissionReference

use of org.keycloak.representations.idm.ManagementPermissionReference in project keycloak by keycloak.

the class IdentityProviderResource method setManagementPermissionsEnabled.

/**
 * Return object stating whether client Authorization permissions have been initialized or not and a reference
 *
 * @return initialized manage permissions reference
 */
@Path("management/permissions")
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@NoCache
public ManagementPermissionReference setManagementPermissionsEnabled(ManagementPermissionReference ref) {
    this.auth.realm().requireManageIdentityProviders();
    AdminPermissionManagement permissions = AdminPermissions.management(session, realm);
    permissions.idps().setPermissionsEnabled(identityProviderModel, ref.isEnabled());
    if (ref.isEnabled()) {
        return toMgmtRef(identityProviderModel, permissions);
    } else {
        return new ManagementPermissionReference();
    }
}
Also used : ManagementPermissionReference(org.keycloak.representations.idm.ManagementPermissionReference) AdminPermissionManagement(org.keycloak.services.resources.admin.permissions.AdminPermissionManagement) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) NoCache(org.jboss.resteasy.annotations.cache.NoCache) PUT(javax.ws.rs.PUT)

Example 8 with ManagementPermissionReference

use of org.keycloak.representations.idm.ManagementPermissionReference in project keycloak by keycloak.

the class RealmAdminResource method getUserMgmtPermissions.

@NoCache
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("users-management-permissions")
public ManagementPermissionReference getUserMgmtPermissions() {
    auth.realm().requireViewRealm();
    AdminPermissionManagement permissions = AdminPermissions.management(session, realm);
    if (permissions.users().isPermissionsEnabled()) {
        return toUsersMgmtRef(permissions);
    } else {
        return new ManagementPermissionReference();
    }
}
Also used : ManagementPermissionReference(org.keycloak.representations.idm.ManagementPermissionReference) AdminPermissionManagement(org.keycloak.services.resources.admin.permissions.AdminPermissionManagement) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Example 9 with ManagementPermissionReference

use of org.keycloak.representations.idm.ManagementPermissionReference in project keycloak by keycloak.

the class GroupResource method setManagementPermissionsEnabled.

/**
 * Return object stating whether client Authorization permissions have been initialized or not and a reference
 *
 * @return initialized manage permissions reference
 */
@Path("management/permissions")
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@NoCache
public ManagementPermissionReference setManagementPermissionsEnabled(ManagementPermissionReference ref) {
    auth.groups().requireManage(group);
    AdminPermissionManagement permissions = AdminPermissions.management(session, realm);
    permissions.groups().setPermissionsEnabled(group, ref.isEnabled());
    if (ref.isEnabled()) {
        return toMgmtRef(group, permissions);
    } else {
        return new ManagementPermissionReference();
    }
}
Also used : ManagementPermissionReference(org.keycloak.representations.idm.ManagementPermissionReference) AdminPermissionManagement(org.keycloak.services.resources.admin.permissions.AdminPermissionManagement) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) NoCache(org.jboss.resteasy.annotations.cache.NoCache) PUT(javax.ws.rs.PUT)

Example 10 with ManagementPermissionReference

use of org.keycloak.representations.idm.ManagementPermissionReference in project keycloak by keycloak.

the class GroupResource method getManagementPermissions.

/**
 * Return object stating whether client Authorization permissions have been initialized or not and a reference
 *
 * @return
 */
@Path("management/permissions")
@GET
@Produces(MediaType.APPLICATION_JSON)
@NoCache
public ManagementPermissionReference getManagementPermissions() {
    auth.groups().requireView(group);
    AdminPermissionManagement permissions = AdminPermissions.management(session, realm);
    if (!permissions.groups().isPermissionsEnabled(group)) {
        return new ManagementPermissionReference();
    }
    return toMgmtRef(group, permissions);
}
Also used : ManagementPermissionReference(org.keycloak.representations.idm.ManagementPermissionReference) AdminPermissionManagement(org.keycloak.services.resources.admin.permissions.AdminPermissionManagement) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) NoCache(org.jboss.resteasy.annotations.cache.NoCache)

Aggregations

ManagementPermissionReference (org.keycloak.representations.idm.ManagementPermissionReference)17 Path (javax.ws.rs.Path)12 Produces (javax.ws.rs.Produces)12 NoCache (org.jboss.resteasy.annotations.cache.NoCache)12 AdminPermissionManagement (org.keycloak.services.resources.admin.permissions.AdminPermissionManagement)12 Consumes (javax.ws.rs.Consumes)6 GET (javax.ws.rs.GET)6 PUT (javax.ws.rs.PUT)6 RoleModel (org.keycloak.models.RoleModel)4 NotFoundException (javax.ws.rs.NotFoundException)2