-
Notifications
You must be signed in to change notification settings - Fork 209
feat: Document VaadinSecurityConfigurer #4420
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
Conversation
articles/flow/security/advanced-topics/navigation-access-control.adoc
Outdated
Show resolved
Hide resolved
Introducing tabs and keeping VaadinWebSecurity examples.
Updating more examples to use tabs to keep old VaadinWebSecurity examples.
Updated for VaadinSecurityConfigurer.
Updated for VaadinSecurityConfigurer.
Updated deprecated antMatchers.
I've updated all remaining pages for VaadinSecurityConfigurer. Code examples are split in two tabs, one for new This PR assumes that |
articles/flow/security/advanced-topics/navigation-access-control.adoc
Outdated
Show resolved
Hide resolved
articles/flow/security/advanced-topics/navigation-access-control.adoc
Outdated
Show resolved
Hide resolved
articles/flow/security/advanced-topics/navigation-access-control.adoc
Outdated
Show resolved
Hide resolved
Co-authored-by: Marco Collovati <[email protected]>
Co-authored-by: Marco Collovati <[email protected]>
Co-authored-by: Marco Collovati <[email protected]>
Keeping VaadinWebSecurity note and added more notes for VaadinSecurityConfigurer.
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.
Suggestion: Update for Spring 6.5+ compatibility
@Bean | ||
SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { | ||
// Configure your static resources with public access | ||
http.authorizeHttpRequests(auth -> auth.requestMatchers(new AntPathRequestMatcher("/public/**")) |
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.
Suggestion: Update for Spring 6.5+ compatibility
As of Spring Security 6.5, AntPathRequestMatcher is deprecated. It is recommended to use the new path matching mechanism based on PathPatternParser, which offers better integration with Spring’s routing system.
Instead of:
http.authorizeHttpRequests(auth -> auth
.requestMatchers(new AntPathRequestMatcher("/public/**"))
.permitAll());
It’s better to update to:
http.authorizeHttpRequests(auth -> auth
.requestMatchers("/public/**")
.permitAll());
Here’s a more advanced example using the recommended syntax:
http.authorizeHttpRequests(authorize -> authorize
.requestMatchers("/images/*.png", "/icons/**")
.permitAll()
.requestMatchers("/public/**")
.anonymous()
.requestMatchers("/admin/**")
.hasRole("ADMIN"));
This not only simplifies the code but also ensures future compatibility and removes deprecation warnings in newer Spring versions.
.`SecurityConfig.java` | ||
[source,java] | ||
---- | ||
<source-info group="VaadinWebSecurity (deprecated since V24.8)"></source-info> |
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.
Most likely the VaadinWebSecurity
example should be updated in the same way
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.
We discussed this topic and concluded that AuthenticationManagerBuilder
is still supported with newer Spring, but it's not recommended way anymore. Therefore using it in old examples is acceptable.
However, it may seem a bit weird that the two side-by-side example configure a non-Vaadin related bean in different ways.
But in other hand, keeping old example as is may work as a nicer transition to newer API for old users. New users probably just ignore deprecated example anyway. Deprecated example will be removed in Vaadin 25 docs.
This change leaves still all examples using VaadinWebSecurity class untouched.
Upgrades the Navigation Access Control docs to use VaadinSecurityConfigurer.
Adds API description for VaadinSecurityConfigurer and examples (perhaps deserves a separate chapter).
Upgrades Enable Security chapter to use VSC.
Upgrades other articles where VaadinWebSecurity was used.
Splits all related code examples into two tabs: one for VaadinSecurityConfigurer and other for deprecated VaadinWebSecurity.
Part-of #4298