-
Notifications
You must be signed in to change notification settings - Fork 730
feat(auth): switch legacy IAuthorizationPolicy to IAuthorizationService impl [PPUC-318] #6027
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
Open
dcleao
wants to merge
14
commits into
pentaho:master
Choose a base branch
from
dcleao:PPUC-122-6-TheSwitch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c706c57
feat(auth): switch legacy IAuthorizationPolicy to IAuthorizationServi…
dcleao d328f79
feat(auth): caching support for AuthorizationService [PPUC-318]
dcleao 1559070
fix(auth): SecurityHelper.runAsAnonymous not destroying StandaloneSes…
dcleao c0e9246
fix: CacheManager onLogout not properly clearing the session cache [P…
dcleao 3eff703
feat(auth): add default log configuration for authorization classes […
dcleao 96d6533
feat(auth): caching support for PentahoSystemAuthorizationActionServi…
dcleao 33b0934
feat(auth): invalidate authorization cache from JcrRoleAuthorizationP…
dcleao bf67acf
feat(auth): invalidate authorization cache from JcrUserRoleDao [PPUC-…
dcleao 341e44e
chore(auth): performance of default authorization options [PPUC-318]
dcleao 5e16ab7
chore(auth): performance of authorization related hash code and equal…
dcleao f721b60
feat(auth): endpoint and old PUC menu item to invalidate authorizatio…
dcleao 93ee37f
review: keep stats of removed session caches
dcleao 86597e8
review: refactorings and notes added to caching service and memory cache
dcleao cf868b6
review: SessionCacheSweeper
dcleao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...ntaho/platform/api/engine/security/authorization/caching/IAuthorizationDecisionCache.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/*! ****************************************************************************** | ||
* | ||
* Pentaho | ||
* | ||
* Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com | ||
* | ||
* Use of this software is governed by the Business Source License included | ||
* in the LICENSE.TXT file. | ||
* | ||
* Change Date: 2029-07-20 | ||
******************************************************************************/ | ||
|
||
package org.pentaho.platform.api.engine.security.authorization.caching; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import org.pentaho.platform.api.engine.security.authorization.IAuthorizationOptions; | ||
import org.pentaho.platform.api.engine.security.authorization.IAuthorizationRequest; | ||
import org.pentaho.platform.api.engine.security.authorization.decisions.IAuthorizationDecision; | ||
|
||
import java.util.Optional; | ||
import java.util.function.Function; | ||
import java.util.function.Predicate; | ||
|
||
/** | ||
* The {@code IAuthorizationDecisionCache} interface represents a cache for authorization decisions, | ||
* and which follows the "loading cache" pattern. | ||
*/ | ||
public interface IAuthorizationDecisionCache { | ||
/** | ||
* Gets a cached authorization decision for a specific authorization request and options, if available. | ||
* | ||
* @param request The authorization request. | ||
* @param options The authorization options. | ||
* @return An optional with the cached decision, if found; an empty optional, if not found. | ||
*/ | ||
@NonNull | ||
Optional<IAuthorizationDecision> get( @NonNull IAuthorizationRequest request, | ||
@NonNull IAuthorizationOptions options ); | ||
|
||
/** | ||
* Gets a cached authorization decision for a specific authorization request and options, | ||
* loading it from the given loader function and storing it in the cache, if not available. | ||
* | ||
* @param request The authorization request. | ||
* @param options The authorization options. | ||
* @param loader A function that computes the authorization decision if it is not found in the cache. | ||
* @return The authorization decision. | ||
*/ | ||
@NonNull | ||
IAuthorizationDecision get( @NonNull IAuthorizationRequest request, | ||
@NonNull IAuthorizationOptions options, | ||
@NonNull Function<IAuthorizationDecisionCacheKey, IAuthorizationDecision> loader ); | ||
|
||
/** | ||
* Caches an authorization decision for a specific authorization request and options. | ||
* <p> | ||
* This operation is a no-op if the cache is disabled. | ||
* | ||
* @param request The authorization request. | ||
* @param options The authorization options. | ||
* @param decision The authorization decision to cache. | ||
*/ | ||
void put( @NonNull IAuthorizationRequest request, | ||
@NonNull IAuthorizationOptions options, | ||
@NonNull IAuthorizationDecision decision ); | ||
|
||
/** | ||
* Clears the cached authorization decision for a specific authorization request and options, if any. | ||
* | ||
* @param request The authorization request. | ||
* @param options The authorization options. | ||
*/ | ||
void invalidate( @NonNull IAuthorizationRequest request, @NonNull IAuthorizationOptions options ); | ||
|
||
/** | ||
* Clears all cached authorization decisions for requests and options that match the given predicate. | ||
* | ||
* @param predicate A predicate that matches authorization requests and options to clear from the cache. | ||
*/ | ||
void invalidateAll( @NonNull Predicate<IAuthorizationDecisionCacheKey> predicate ); | ||
|
||
/** | ||
* Clears all cached authorization decisions. | ||
* <p> | ||
* This operation is a no-op if the cache is disabled. | ||
*/ | ||
void invalidateAll(); | ||
} |
31 changes: 31 additions & 0 deletions
31
...ho/platform/api/engine/security/authorization/caching/IAuthorizationDecisionCacheKey.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/*! ****************************************************************************** | ||
* | ||
* Pentaho | ||
* | ||
* Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com | ||
* | ||
* Use of this software is governed by the Business Source License included | ||
* in the LICENSE.TXT file. | ||
* | ||
* Change Date: 2029-07-20 | ||
******************************************************************************/ | ||
|
||
package org.pentaho.platform.api.engine.security.authorization.caching; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import org.pentaho.platform.api.engine.security.authorization.IAuthorizationOptions; | ||
import org.pentaho.platform.api.engine.security.authorization.IAuthorizationRequest; | ||
|
||
/** | ||
* The {@code IAuthorizationDecisionCacheKey} interface represents the key for cached authorization decision. | ||
* It is constituted by an authorization request and options. | ||
* <p> | ||
* Implementations must implement proper {@code equals()} and {@code hashCode()} methods. | ||
*/ | ||
public interface IAuthorizationDecisionCacheKey { | ||
@NonNull | ||
IAuthorizationRequest getRequest(); | ||
|
||
@NonNull | ||
IAuthorizationOptions getOptions(); | ||
} |
64 changes: 64 additions & 0 deletions
64
.../pentaho/platform/api/engine/security/authorization/impl/DefaultAuthorizationOptions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/*! ****************************************************************************** | ||
* | ||
* Pentaho | ||
* | ||
* Copyright (C) 2024 by Hitachi Vantara, LLC : http://www.pentaho.com | ||
* | ||
* Use of this software is governed by the Business Source License included | ||
* in the LICENSE.TXT file. | ||
* | ||
* Change Date: 2029-07-20 | ||
******************************************************************************/ | ||
|
||
package org.pentaho.platform.api.engine.security.authorization.impl; | ||
|
||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import org.pentaho.platform.api.engine.security.authorization.AuthorizationDecisionReportingMode; | ||
import org.pentaho.platform.api.engine.security.authorization.IAuthorizationOptions; | ||
|
||
/** | ||
* The {@code DefaultAuthorizationOptions} class provides an implementation of {@link IAuthorizationOptions} with the | ||
* default option values. | ||
* <p> | ||
* This class is intended for internal use. | ||
* It supports the implementation of the {@link IAuthorizationOptions#getDefault()} method. | ||
*/ | ||
public class DefaultAuthorizationOptions implements IAuthorizationOptions { | ||
Check notice on line 26 in api/src/main/java/org/pentaho/platform/api/engine/security/authorization/impl/DefaultAuthorizationOptions.java
|
||
|
||
public static final DefaultAuthorizationOptions INSTANCE = new DefaultAuthorizationOptions(); | ||
|
||
private DefaultAuthorizationOptions() { | ||
// Prevent external instantiation. | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public AuthorizationDecisionReportingMode getDecisionReportingMode() { | ||
return AuthorizationDecisionReportingMode.SETTLED; | ||
} | ||
|
||
@Override | ||
public boolean equals( Object obj ) { | ||
if ( this == obj ) { | ||
return true; | ||
} | ||
|
||
if ( !( obj instanceof IAuthorizationOptions other ) ) { | ||
return false; | ||
} | ||
|
||
return getDecisionReportingMode() == other.getDecisionReportingMode(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return getDecisionReportingMode().hashCode(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format( | ||
"IAuthorizationOptions{decisionReportingMode=%s}", | ||
getDecisionReportingMode() ); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.