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

Rewrite WebSecurityConfig to use the lambda DSL. #134

Merged
merged 1 commit into from
Sep 26, 2024
Merged

Conversation

plietar
Copy link
Member

@plietar plietar commented Sep 25, 2024

Spring Security has two forms of DSLs for configuring the HttpSecurity object, one based on method chaining and one based on lambdas. The latter is generally more readable, as it makes it clear the scope of each configuration block. In fact the method chaining syntax is deprecated in Spring Security 6.2, and will be removed in 7.0.

We were using an inconsistent mix of the two. This cleans it up and uses the lambda DSL throughout. The only exception to this is the AuthenticationManager configuration, which for some reason doesn't have a lambda DSL

Spring Security has two forms of DSLs for configuring the HttpSecurity
object, one based on method chaining and [one based on lambdas][lambda-dsl].
The latter is generally more readable, as it makes it clear the scope of each
configuration block. In fact the method chaining syntax is deprecated in Spring
Security 6.2, and [will be removed in 7.0][migration].

We were using an inconsistent mix of the two. This cleans it up and uses
the lambda DSL throughout. The only exception to this is the
`AuthenticationManager` configuration, which [for some reason doesn't
have a lambda DSL][sec13003]

[lambda-dsl]: https://spring.io/blog/2019/11/21/spring-security-lambda-dsl
[migration]: https://docs.spring.io/spring-security/reference/migration-7/configuration.html
[sec13003]:  spring-projects/spring-security#13003
@plietar plietar requested a review from absternator September 25, 2024 14:57
Copy link

codecov bot commented Sep 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.91%. Comparing base (dab80be) to head (9158687).
Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #134   +/-   ##
=======================================
  Coverage   96.91%   96.91%           
=======================================
  Files         125      125           
  Lines        1166     1166           
  Branches      319      319           
=======================================
  Hits         1130     1130           
  Misses         34       34           
  Partials        2        2           
Flag Coverage Δ
96.91% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@absternator absternator left a comment

Choose a reason for hiding this comment

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

Nice cleanups!!! lgtm

@plietar plietar merged commit e656755 into main Sep 26, 2024
6 checks passed
@plietar plietar deleted the lambda-api branch September 26, 2024 10:12
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.

2 participants