KEYCLOAK-4109 Ability to disable impersonation
This commit is contained in:
1 parent
faeff029fa
commit
eb7ad07e31
14 files changed
+114
-54
No files matched your search
+1
-1
@@ -153,6 +153,6 @@ public class ScriptBasedAuthenticatorFactory implements AuthenticatorFactory, En
|
||||
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
return Profile.isPreviewEnabled();
|
||||
return Profile.isFeatureEnabled(Profile.Feature.SCRIPTS);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import org.jboss.resteasy.spi.ResteasyProviderFactory;
|
||||
import org.keycloak.authorization.AuthorizationProvider;
|
||||
import org.keycloak.authorization.AuthorizationService;
|
||||
import org.keycloak.common.ClientConnection;
|
||||
import org.keycloak.common.Profile;
|
||||
import org.keycloak.common.util.KeycloakUriBuilder;
|
||||
import org.keycloak.events.EventBuilder;
|
||||
import org.keycloak.models.ClientModel;
|
||||
@@ -264,7 +265,7 @@ public class RealmsResource {
|
||||
|
||||
@Path("{realm}/authz")
|
||||
public Object getAuthorizationService(@PathParam("realm") String name) {
|
||||
ProfileHelper.requirePreview();
|
||||
ProfileHelper.requireFeature(Profile.Feature.AUTHORIZATION);
|
||||
|
||||
init(name);
|
||||
AuthorizationProvider authorization = this.session.getProvider(AuthorizationProvider.class);
|
||||
|
||||
@@ -164,7 +164,7 @@ public class ClientResource {
|
||||
|
||||
RepresentationToModel.updateClient(rep, client);
|
||||
|
||||
if (Profile.isPreviewEnabled()) {
|
||||
if (Profile.isFeatureEnabled(Profile.Feature.AUTHORIZATION)) {
|
||||
if (TRUE.equals(rep.getAuthorizationServicesEnabled())) {
|
||||
authorization().enable();
|
||||
} else {
|
||||
@@ -190,7 +190,7 @@ public class ClientResource {
|
||||
|
||||
ClientRepresentation representation = ModelToRepresentation.toRepresentation(client);
|
||||
|
||||
if (Profile.isPreviewEnabled()) {
|
||||
if (Profile.isFeatureEnabled(Profile.Feature.AUTHORIZATION)) {
|
||||
representation.setAuthorizationServicesEnabled(authorization().isEnabled());
|
||||
}
|
||||
|
||||
@@ -577,7 +577,7 @@ public class ClientResource {
|
||||
|
||||
@Path("/authz")
|
||||
public AuthorizationService authorization() {
|
||||
ProfileHelper.requirePreview();
|
||||
ProfileHelper.requireFeature(Profile.Feature.AUTHORIZATION);
|
||||
|
||||
AuthorizationService resource = new AuthorizationService(this.session, this.client, this.auth);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jboss.resteasy.spi.NotFoundException;
|
||||
import org.jboss.resteasy.spi.ResteasyProviderFactory;
|
||||
import org.keycloak.authentication.RequiredActionProvider;
|
||||
import org.keycloak.common.ClientConnection;
|
||||
import org.keycloak.common.Profile;
|
||||
import org.keycloak.common.util.Time;
|
||||
import org.keycloak.credential.CredentialModel;
|
||||
import org.keycloak.email.EmailException;
|
||||
@@ -70,6 +71,7 @@ import org.keycloak.models.UserManager;
|
||||
import org.keycloak.services.managers.UserSessionManager;
|
||||
import org.keycloak.services.resources.AccountService;
|
||||
import org.keycloak.services.validation.Validation;
|
||||
import org.keycloak.utils.ProfileHelper;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
@@ -318,6 +320,8 @@ public class UsersResource {
|
||||
@NoCache
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Map<String, Object> impersonate(final @PathParam("id") String id) {
|
||||
ProfileHelper.requireFeature(Profile.Feature.IMPERSONATION);
|
||||
|
||||
auth.init(RealmAuth.Resource.IMPERSONATION);
|
||||
auth.requireManage();
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ import javax.ws.rs.core.Response;
|
||||
*/
|
||||
public class ProfileHelper {
|
||||
|
||||
public static void requirePreview() {
|
||||
if (!Profile.isPreviewEnabled()) {
|
||||
throw new WebApplicationException("Feature not available in current profile", Response.Status.NOT_IMPLEMENTED);
|
||||
public static void requireFeature(Profile.Feature feature) {
|
||||
if (!Profile.isFeatureEnabled(feature)) {
|
||||
throw new WebApplicationException("Feature not enabled", Response.Status.NOT_IMPLEMENTED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user