diff --git a/services/src/main/java/org/keycloak/services/managers/TokenManager.java b/services/src/main/java/org/keycloak/services/managers/TokenManager.java index b617bb9bd2..84a0f2647e 100755 --- a/services/src/main/java/org/keycloak/services/managers/TokenManager.java +++ b/services/src/main/java/org/keycloak/services/managers/TokenManager.java @@ -54,23 +54,6 @@ public class TokenManager { return accessCodeMap.remove(key); } - protected boolean desiresScope(AccessScope scope, String key, String roleName) { - if (scope == null || scope.isEmpty()) return true; - List val = scope.get(key); - if (val == null) return false; - return val.contains(roleName); - - } - - protected boolean desiresScopeGroup(AccessScope scope, String key) { - if (scope == null || scope.isEmpty()) return true; - return scope.containsKey(key); - } - - protected boolean isEmpty(AccessScope scope) { - return scope == null || scope.isEmpty(); - } - public static void applyScope(RoleModel role, RoleModel scope, Set visited, Set requested) { if (visited.contains(scope)) return; visited.add(scope); @@ -205,9 +188,7 @@ public class TokenManager { } public AccessToken createClientAccessToken(String scopeParam, RealmModel realm, ClientModel client, UserModel user, List realmRolesRequested, MultivaluedMap resourceRolesRequested) { - AccessScope scopeMap = null; - if (scopeParam != null) scopeMap = decodeScope(scopeParam); - + // todo scopeParam is ignored until we figure out a scheme that fits with openid connect Set roleMappings = realm.getRoleMappings(user); Set scopeMappings = realm.getScopeMappings(client); @@ -226,14 +207,11 @@ public class TokenManager { } for (RoleModel role : requestedRoles) { - if (role.getContainer() instanceof RealmModel && desiresScope(scopeMap, "realm", role.getName())) { + if (role.getContainer() instanceof RealmModel) { realmRolesRequested.add(role); } else if (role.getContainer() instanceof ApplicationModel) { ApplicationModel app = (ApplicationModel)role.getContainer(); - if (desiresScope(scopeMap, app.getName(), role.getName())) { - resourceRolesRequested.add(app.getName(), role); - - } + resourceRolesRequested.add(app.getName(), role); } } @@ -337,28 +315,6 @@ public class TokenManager { } - public String encodeScope(AccessScope scope) { - String token = null; - try { - token = JsonSerialization.writeValueAsString(scope); - } catch (Exception e) { - throw new RuntimeException(e); - } - return Base64Url.encode(token.getBytes()); - } - - public AccessScope decodeScope(String scopeParam) { - AccessScope scope = null; - byte[] bytes = Base64Url.decode(scopeParam); - try { - scope = JsonSerialization.readValue(bytes, AccessScope.class); - } catch (IOException e) { - throw new RuntimeException(e); - } - return scope; - } - - public String encodeToken(RealmModel realm, Object token) { String encodedToken = new JWSBuilder() .jsonContent(token) diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/oauth/OAuthGrantTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/oauth/OAuthGrantTest.java index d7e39a8a27..54195cfb0d 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/oauth/OAuthGrantTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/oauth/OAuthGrantTest.java @@ -89,31 +89,6 @@ public class OAuthGrantTest { Assert.assertTrue(resourceAccess.get("test-app").isUserInRole("customer-user")); } - @Test - public void oauthGrantAcceptTestWithScope() throws IOException { - oauth.addScope("test-app", "customer-user"); - oauth.clientId("third-party"); - oauth.doLoginGrant("test-user@localhost", "password"); - - grantPage.assertCurrent(); - Assert.assertTrue(driver.getPageSource().contains(ROLE_CUSTOMER)); - - grantPage.accept(); - - Assert.assertTrue(oauth.getCurrentQuery().containsKey("code")); - OAuthClient.AccessTokenResponse accessToken = oauth.doAccessTokenRequest(oauth.getCurrentQuery().get("code"), "password"); - - AccessToken token = oauth.verifyToken(accessToken.getAccessToken()); - - AccessToken.Access realmAccess = token.getRealmAccess(); - Assert.assertNull(realmAccess); - - Map resourceAccess = token.getResourceAccess(); - Assert.assertEquals(1, resourceAccess.size()); - Assert.assertEquals(1, resourceAccess.get("test-app").getRoles().size()); - Assert.assertTrue(resourceAccess.get("test-app").isUserInRole("customer-user")); - } - @Test public void oauthGrantCancelTest() throws IOException { oauth.clientId("third-party");