Skip to main content

New answers tagged

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 ...
allofmex's user avatar
  • 607
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.*.
capibara245's user avatar
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 ...
nifoem bar's user avatar
  • 1,367
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/...
sanjay gupta's user avatar
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?
amphibient's user avatar
  • 31.8k
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?
amphibient's user avatar
  • 31.8k
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 ...
Mahdi zgolli's user avatar
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....
Rob Spoor's user avatar
  • 10.2k
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 ...
Ben's user avatar
  • 1,085
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 '...
Michael Hegner's user avatar
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, ...
igor.zh's user avatar
  • 2,934
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-...
Toerktumlare's user avatar
  • 15.1k
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....
Tuhin Shaikh's user avatar
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. ...
Sina Soheili's user avatar
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 ...
The below statement is true's user avatar
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 (...
Mohammad Awwaad's user avatar
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 ...
M. Deinum's user avatar
  • 127k
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-...
Himanshu Singhal's user avatar
-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 ...
Max's user avatar
  • 1,068
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, ...
Max's user avatar
  • 1,068
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.
Torben's user avatar
  • 3,955
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 ...
Andrey B. Panfilov's user avatar
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.
Arnaud's user avatar
  • 17.5k
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 ...
Serge Ballesta's user avatar
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..
Mayank Grover's user avatar
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.
Torben's user avatar
  • 3,955
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....
Ian Boyd's user avatar
  • 260k
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
jay91537's user avatar
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
Zeddling's user avatar

Top 50 recent answers are included