Repository navigation
Optimize composite role evaluation #13146
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,6 +144,10 @@ public Stream<String> getAttributeStream(String name) { | |
| return getAttributes().getOrDefault(name, Collections.EMPTY_LIST).stream(); | ||
| } | ||
|
|
||
| public RealmModel getRealm() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method could be probably introduced in @hmlnarik I'm not sure whether this can be postponed too much as the |
||
| return realm; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return String.format("%s@%08x", getName(), System.identityHashCode(this)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||
| /* | ||||||
| * Copyright 2022 Red Hat, Inc. and/or its affiliates | ||||||
| * and other contributors as indicated by the @author tags. | ||||||
| * | ||||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
| * you may not use this file except in compliance with the License. | ||||||
| * You may obtain a copy of the License at | ||||||
| * | ||||||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||||||
| * | ||||||
| * Unless required by applicable law or agreed to in writing, software | ||||||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||
| * See the License for the specific language governing permissions and | ||||||
| * limitations under the License. | ||||||
| */ | ||||||
|
|
||||||
| package org.keycloak.models.map.storage; | ||||||
|
|
||||||
| import org.keycloak.models.map.role.MapRoleEntity; | ||||||
|
|
||||||
| import java.util.Set; | ||||||
|
|
||||||
| /** | ||||||
| * A map store transaction that can check if a role is part of another role. | ||||||
| * This must only be used if this store contains all the role information for the given realm. | ||||||
| * @author Alexander Schwartz | ||||||
| */ | ||||||
| public interface MapKeycloakTransactionWithHasRole<V extends MapRoleEntity, M> extends MapKeycloakTransaction<V, M> { | ||||||
|
|
||||||
|
|
||||||
| boolean hasRole(String realmId, Set<String> roleIds, Set<String> targetRoleIds); | ||||||
|
|
||||||
| Set<V> expandCompositeRoles(String realmId, Set<String> targetRoles); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the
Suggested change
|
||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to use
criteria()instead of for loops?note: if it'll be decided to return
Stream, then return statement could loo like:return read(withCriteria(mcb));