Skip to content
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

OAK-10466: Allow to configure anonymous user disablement #1882

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

Amoratinos
Copy link
Contributor

Created a configuration value that allows to prevent anonymous user to be disabled.

To support backward compatibility be default anonymous user can still be disabled


UserImpl(String id, Tree tree, UserManagerImpl userManager) throws RepositoryException {
super(id, tree, userManager);

isAdmin = UserUtil.isAdmin(userManager.getConfig(), id);
isAnonymous = UserUtil.getAnonymousId(userManager.getConfig()).equals(id);
allowDisableAnonymous = userManager.getConfig().getConfigValue(UserConstants.PARAM_ALLOW_DISABLE_ANONYMOUS, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having this in the constructor will impose a small performance penalty on every construction of a user object. Is it possible to move this code down into the canDisableUser method, so it is executed only when it is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also considered it but in that case I'd have to keep a reference to the configuration parameters on each UserImpl instance. Not sure if this could have a performance impact as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Amoratinos , it should be possible to retrieve the configuration params on the fly.... the usermanager field stored with the base class is an instance of UserManagerImpl, which comes with a method getConfig(), which are the config params obtained from UserConfiguration afaik.

so, i believe it's possible to move the evaluation to the validateDisableUser method and avoiding story isAnonymous and avoiding storing the config params again as they are already attached to the user manager

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, changed to use getUserManager and removed those fields in favor of online evaluation.

Configuration check moved to be performed when the disable method is called
Copy link
Contributor

@anchela anchela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @Amoratinos , lgtm. thank you

@anchela
Copy link
Contributor

anchela commented Dec 3, 2024

@joerghoh , can you take another look to see if your concerns are addressed? ty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants