8000 remove identity-zones.xml by Kehrlann · Pull Request #3326 · cloudfoundry/uaa · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

remove identity-zones.xml #3326

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*******************************************************************************/
package org.cloudfoundry.identity.uaa.security;

import java.util.Map;

import com.fasterxml.jackson.core.type.TypeReference;
import org.cloudfoundry.identity.uaa.authentication.UaaPrincipal;
import org.cloudfoundry.identity.uaa.oauth.UaaOauth2Authentication;
Expand All @@ -28,8 +30,6 @@
import org.springframework.security.core.Authentication;
import org.springframework.util.StringUtils;

import java.util.Map;

public class ContextSensitiveOAuth2SecurityExpressionMethods extends OAuth2SecurityExpressionMethods {

private final IdentityZone identityZone;
Expand All @@ -52,13 +52,9 @@ private String[] replaceContext(String[] roles) {
}

public ContextSensitiveOAuth2SecurityExpressionMethods(Authentication authentication) {
this(authentication, IdentityZone.getUaa());
}

public ContextSensitiveOAuth2SecurityExpressionMethods(Authentication authentication, IdentityZone authenticationZone) {
super(authentication);
this.authentication = authentication;
this.identityZone = authenticationZone;
this.identityZone = IdentityZone.getUaa();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,18 @@


import org.cloudfoundry.identity.uaa.oauth.provider.expression.OAuth2WebSecurityExpressionHandler;
import org.cloudfoundry.identity.uaa.zone.IdentityZone;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.FilterInvocation;

public class ContextSensitiveOAuth2WebSecurityExpressionHandler extends OAuth2WebSecurityExpressionHandler {

private IdentityZone identityZone;

@Override
protected StandardEvaluationContext createEvaluationContextInternal(Authentication authentication,
protected StandardEvaluationContext createEvaluationContextInternal(
Authentication authentication,
FilterInvocation invocation) {
StandardEvaluationContext ec = super.createEvaluationContextInternal(authentication, invocation);
ec.setVariable("oauth2", new ContextSensitiveOAuth2SecurityExpressionMethods(authentication, identityZone));
ec.setVariable("oauth2", new ContextSensitiveOAuth2SecurityExpressionMethods(authentication));
return ec;
}

public void setIdentityZone(IdentityZone identityZone) {
this.identityZone = identityZone;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public boolean isAdmin() {

String zoneAdminRole = "zones." + IdentityZoneHolder.get().getId() + ".admin";
if (!result) {
ContextSensitiveOAuth2SecurityExpressionMethods eval = new ContextSensitiveOAuth2SecurityExpressionMethods(a, IdentityZone.getUaa());
ContextSensitiveOAuth2SecurityExpressionMethods eval = new ContextSensitiveOAuth2SecurityExpressionMethods(a);
result = eval.hasScopeInAuthZone(zoneAdminRole);
}
return result;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package org.cloudfoundry.identity.uaa.web;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

import org.cloudfoundry.identity.uaa.oauth.provider.expression.OAuth2ExpressionUtils;
import org.cloudfoundry.identity.uaa.security.ContextSensitiveOAuth2SecurityExpressionMethods;
import org.cloudfoundry.identity.uaa.zone.IdentityZoneHolder;
import org.springframework.security.authorization.AuthenticatedAuthorizationManager;
import org.springframework.security.authorization.AuthorizationDecision;
import org.springframework.security.authorization.AuthorizationManager;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.access.intercept.RequestAuthorizationContext;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

/**
* Utility class for creating {@link AuthorizationManager} instances.
*/
Expand Down Expand Up @@ -96,8 +95,7 @@ public AnyOfAuthorizationManager hasScope(String scope) {
public AnyOfAuthorizationManager hasScopeWithZoneId(String scope) {
delegateAuthorizationManagers.add(
(auth, ctx) -> {
var identityZone = IdentityZoneHolder.getUaaZone();
var securityMethods = new ContextSensitiveOAuth2SecurityExpressionMethods(auth.get(), identityZone);
var securityMethods = new ContextSensitiveOAuth2SecurityExpressionMethods(auth.get());
return new AuthorizationDecision(securityMethods.hasScopeInAuthZone(scope));
}
);
Expand Down
3 changes: 2 additions & 1 deletion uaa/src/main/webapp/WEB-INF/spring-servlet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@
class="org.cloudfoundry.identity.uaa.zone.ZoneAwareClientSecretPolicyValidator">
<constructor-arg ref="globalClientSecretPolicy"/>
</bean>
<bean id="oauthWebExpressionHandler"
class="org.cloudfoundry.identity.uaa.security.ContextSensitiveOAuth2WebSecurityExpressionHandler" />

<import resource="spring/oauth-clients.xml"/>
<!-- The order of these imports is important because of Spring Security filter chain rules -->
Expand All @@ -354,7 +356,6 @@
<import resource="spring/openid-endpoints.xml"/>
<import resource="spring/codestore-endpoints.xml"/>
<import resource="spring/authentication.xml"/>
<import resource="spring/identity-zones.xml"/>

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
Expand Down
11 changes: 0 additions & 11 deletions uaa/src/main/webapp/WEB-INF/spring/identity-zones.xml

This file was deleted.

Loading
0