Skip to content

docs: refactor impersonation example #4294

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
wants to merge 2 commits into
base: latest
Choose a base branch
from

Conversation

mcollovati
Copy link
Contributor

Refactors impersonation example to get the correct security context holder as a parameter, to avoid wiring the dependency by name.

Refactors impersonation example to get the correct security context holder as a parameter, to avoid wiring the dependency by name.
@mcollovati mcollovati requested review from heruan and mshabarov May 8, 2025 06:22
Copy link

github-actions bot commented May 8, 2025

AI Language Review

  • In the "Spring Impersonation with Vaadin" section, the updated instruction for creating the SwitchUserFilter bean introduces complexity by injecting the VaadinAwareSecurityContextHolderStrategy directly. Clarify if this adjustment affects existing configurations, and consider whether this inclusion is necessary in the context of projects not using VaadinWebSecurity as a base class.
  • The note about adding @Import(VaadinAwareSecurityContextHolderStrategyConfiguration.class) lacks grounding. Provide more context or scenarios where this import is critical, assisting readers in understanding why this step could be necessary.

@@ -587,7 +587,7 @@ To add impersonation for a Vaadin application, create the [classname]`SwitchUser
----

[NOTE]
The bean should depend on `VaadinSecurityContextHolderStrategy` bean. If the [classname]`SwitchUserFilter` is initialized first, the wrong security holder is used and the feature won't work.
The bean should use `VaadinSecurityContextHolderStrategy` bean to work properly. If the [classname]`SwitchUserFilter` is initialized differently, the wrong security holder is used and the feature won't work.
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest to inject the strategy as the interface SecurityContextHolderStrategy, in case the user provides their own strategy bean.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The filter needs VaadinSecurityContextHolderStrategy to work properly with Vaadin. A different strategy (e.g. ThreadLocal) will potentially fail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a note suggesting to add @Import(VaadinAwareSecurityContextHolderStrategyConfiguration.class) if application is not using VaadinWebSecurity as a base configuration class.

@mcollovati mcollovati added the flow label May 8, 2025
@mcollovati mcollovati requested a review from mshabarov May 8, 2025 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants