New answers tagged spring-security
0 votes
Dynamic route for LoginPage in security configuration
This may work for your case: Use a custom LoginUrlAuthenticationEntryPoint instance: public class LocaleLoginUrlAuthenticationEntryPoint extends LoginUrlAuthenticationEntryPoint { private final ...
Advice
0 votes
0 replies
0 views
Is Spring framework 6.x compatible with Spring Security 7.x?
But, in the docs (reference), it says that: Spring Security builds against Spring Framework 7.0.6 but should generally work with any newer version of Spring Framework 5.x.*.
Advice
0 votes
0 replies
0 views
Is Spring framework 6.x compatible with Spring Security 7.x?
Spring Framework 7 and Spring Security 7 both require Jakarta EE 11, which depends on Servlet 6.1 and updated APIs (like JPA 3.2). Spring Framework 6.x, on the other hand, is based on Jakarta EE 9/10 ...
Advice
0 votes
0 replies
0 views
Is Spring framework 6.x compatible with Spring Security 7.x?
Spring Framework 7 and Spring Security 7 require Jakarta EE 11. This means they rely on Servlet 6.1 (and other updated APIs like JPA 3.2). Spring Framework 6.x is based on Jakarta EE 9/10 (Servlet 5.0/...
Best practices
0 votes
0 replies
0 views
Working around spaghetti lambdas and builder in Spring Security v6
do you think there is any way around the spaghetti-like builder pattern?
Best practices
0 votes
0 replies
0 views
Working around spaghetti lambdas and builder in Spring Security v6
do you think there is any way around the spaghetti-like builder pattern?
Best practices
1 vote
0 replies
0 views
Working around spaghetti lambdas and builder in Spring Security v6
I totally feel your pain on this the Spring Security 6 'lambda spaghetti' is a nightmare. It feels like you're writing a 100-line run-on sentence just to set up a login page. The good news is you're ...
Best practices
3 votes
0 replies
0 views
Working around spaghetti lambdas and builder in Spring Security v6
Instead of creating local variables, I'd split it off to separate methods and use method references: @Bean public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { return http....
0 votes
Spring Security OAuth2 Authorization Server to support Device Authorization Flow with public clients using ClientAuthenticationMethod.NONE
There was a ticket about adding a sample for this exact use-case. The ticket is closed, and the result is to be seen in the demo-authorizationserver sample directory. Long story short, There is a ...
0 votes
Spring Boot 4 / Spring Security 6 – @WithMockUser returns 401 Unauthorized in MockMvc test
With Spring Boot 4 you need to change the dependency since mostly you need a starter dependency. Change testImplementation 'org.springframework.security:spring-security-test' with testImplementation '...
2 votes
MDC and SecurityContext propagation failing when using Virtual Threads (Executor)
Native MDC and Spring Security solution is @Bean public ExecutorService virtualThreadExecutor() { return Executors.newThreadPerTaskExecutor(r -> { final Map<String, ...
0 votes
Spring Boot + Auth0: Health endpoint returns 401 on Azure App Service but works locally even though path is excluded from SecurityFilterChain
when looking in the response from your curl call we can see the following: WWW-Authenticate: Bearer resource_metadata="https://example.westeurope-01.azurewebsites.net/.well-known/oauth-protected-...
4 votes
MDC and SecurityContext propagation failing when using Virtual Threads (Executor)
Have you tried using Micrometer Context Propagation and wrap the executor with ContextExecutorService so MDC and SecurityContext ThreadLocals are captured and restored automatically. import io....
Best practices
0 votes
0 replies
0 views
Is it safe to reuse UserDetails from SecurityContext instead of querying the database again?
It is safe to reuse the UserDetails from the SecurityContext because the user information has already been loaded from the database and is considered valid for the duration of the request. ...
Advice
0 votes
0 replies
0 views
Spring Security help needed
.requestMatchers("/users/register").authenticated() you're allowing only those who are logged in to register an account, essentially forbidding account creation. By the way, it's better for ...
0 votes
Spring Cloud Gateway cannot authorize jwt token when request sends by Browser
To forward the OAuth2 access token from the Gateway to your downstream services, you need to configure the TokenRelay filter in Spring Cloud Gateway. When your Gateway acts as an OAuth2 Login client (...
0 votes
@WebMvcTest behaviour related to security is different in Spring Boot 4.x compared to Spring Boot 3.x
Including spring-boot-starter-security-test will eventually pull in the spring-boot-security-test module. This module contains all test auto-configuration for the security part. Specifically for ...
0 votes
spring boot starter security not generating default password in logs
In my case I have already added <!-- <dependency>--> <!-- <groupId>org.springframework.boot</groupId>--> <!-- <artifactId>spring-...
-1 votes
@WebMvcTest behaviour related to security is different in Spring Boot 4.x compared to Spring Boot 3.x
The issue occurs because @WebMvcTest is a sliced test that scans for Spring MVC infrastructure but does not automatically pull in your custom @Configuration classes where security rules (like ...
1 vote
@Pattern and @NotBlank on password field still triggered even when password is null, validation groups cause MapStruct mapping issues
Force the validator to stop after the first failure. By using @GroupSequence, if @NotBlank fails, the validation engine won't even look at the @Pattern. @GroupSequence({Required.class, Format.class, ...
Best practices
0 votes
0 replies
0 views
Should I implement UserDetails directly in my User entity or create a separate UserPrincipal class in Spring Security?
Nope. I am suggesting to not use plurals in database table names. Also, trying to label a discussion as "off-topic" in order to suppress it because you don't like the subject is pretty lame.
Best practices
1 vote
0 replies
0 views
Should I implement UserDetails directly in my User entity or create a separate UserPrincipal class in Spring Security?
at first, this is off-topic; at second, user is a reserved keyword for the most DB engines I'm familiar with, technically, you are suggesting to name related table as "user" (note double ...
Best practices
1 vote
0 replies
0 views
Should I implement UserDetails directly in my User entity or create a separate UserPrincipal class in Spring Security?
It is a convention with DBs, to name a table after the object represented by one record.
Best practices
0 votes
0 replies
0 views
Should I implement UserDetails directly in my User entity or create a separate UserPrincipal class in Spring Security?
This is a general design question, and both approaches are valid. Which one is better depends on your real context. If the User class has few attributes and is a rather simple model, having it to ...
Best practices
0 votes
0 replies
0 views
Should I implement UserDetails directly in my User entity or create a separate UserPrincipal class in Spring Security?
why? i think it's a collections of users thats why doing that..
Best practices
3 votes
0 replies
0 views
Should I implement UserDetails directly in my User entity or create a separate UserPrincipal class in Spring Security?
Before it's too late, stop naming database tables in plural.
0 votes
BCrypt vs Argon2 and their hashing algorithms
It should be noted that Argon2 is weaker than bcrypt for run times less than 1 second. (i.e. for authentication) Actually, bcrypt is stronger than Argon2 for authentication (target runtime < 500ms....
Best practices
0 votes
0 replies
0 views
Spring Boot 3.3.0 → 3.3.11 upgrade: Spring Security behavior changes
Thanks!! I hope l could get some Infos from there
Best practices
0 votes
0 replies
0 views
Spring Boot 3.3.0 → 3.3.11 upgrade: Spring Security behavior changes
This might be related to this: https://github.com/spring-projects/spring-security/issues/15769?utm_source=chatgpt.com
Top 50 recent answers are included
Related Tags
spring-security × 29132spring × 15102
java × 11851
spring-boot × 9634
spring-mvc × 5262
spring-security-oauth2 × 1870
grails × 1801
oauth-2.0 × 1596
authentication × 1416
jwt × 1067
rest × 719
security × 675
keycloak × 490
spring-oauth2 × 455
hibernate × 450
spring-webflux × 436
oauth × 418
ldap × 416
csrf × 416
thymeleaf × 413
spring-saml × 393
angular × 376
angularjs × 372
tomcat × 346
session × 331