Fix OAuth2 multitenancy sample
Allowing requests with valid tokens, and fixed documentation. Fixes: gh-6834
This commit is contained in:
committed by
Josh Cummings
parent
5aa50500cf
commit
c4b6cdea3f
@@ -65,8 +65,10 @@ public class OAuth2ResourceServerSecurityConfiguration extends WebSecurityConfig
|
||||
authenticationManagers.put("tenantOne", jwt());
|
||||
authenticationManagers.put("tenantTwo", opaque());
|
||||
return request -> {
|
||||
String tenantId = request.getPathInfo().split("/")[1];
|
||||
return Optional.ofNullable(authenticationManagers.get(tenantId))
|
||||
String[] pathParts = request.getRequestURI().split("/");
|
||||
String tenantId = pathParts.length > 0 ? pathParts[1] : null;
|
||||
return Optional.ofNullable(tenantId)
|
||||
.map(authenticationManagers::get)
|
||||
.orElseThrow(() -> new IllegalArgumentException("unknown tenant"));
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user