File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
src/main/java/com/hawk/keycloak/resources/service Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change 9
9
import org .keycloak .authorization .store .PermissionTicketStore ;
10
10
import org .keycloak .authorization .store .ScopeStore ;
11
11
import org .keycloak .events .admin .OperationType ;
12
- import org .keycloak .models .KeycloakSession ;
13
12
import org .keycloak .models .KeycloakUriInfo ;
14
13
import org .keycloak .models .UserModel ;
15
14
import org .keycloak .services .resources .admin .AdminEventBuilder ;
@@ -38,6 +37,13 @@ public void setPermissions(
38
37
}
39
38
40
39
List <String > knownScopesOfResource = resource .getScopes ().stream ().map (Scope ::getName ).toList ();
40
+
41
+ for (String scope : scopes ) {
42
+ if (!knownScopesOfResource .contains (scope )){
43
+ throw new BadRequestException ("The scope \" " + scope + "\" is not allowed for the resource" );
44
+ }
45
+ }
46
+
41
47
List <PermissionTicket > tickets = findTickets (resource , user );
42
48
43
49
boolean triggerEvent = false ;
@@ -58,9 +64,6 @@ public void setPermissions(
58
64
if (scope == null ){
59
65
throw new BadRequestException ("The scope \" " + scopeName + "\" does not exist" );
60
66
}
61
- if (!knownScopesOfResource .contains (scope .getName ())){
62
- throw new BadRequestException ("The scope \" " + scopeName + "\" is not allowed for the resource" );
63
- }
64
67
65
68
Iterator <PermissionTicket > ticketIterator = tickets .iterator ();
66
69
You can’t perform that action at this time.
0 commit comments