-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Spring Security Configuraion Issue : Permit All Not working #14011
Comments
I got the same issue |
Hi, @dv0892. Have you enabled TRACE logging to check where the authentication error is happening? Have you enabled the FORWARD dispatcher type? |
yes. Please look at the simple code below. You can reproduce it easily.
|
I don't see you allowing FORWARD and neither you provided any logs that can help to know what is happening. Please, try what I recommended, and, if you really believe that there is a bug in Spring Security, please create a minimal, reproducible sample and write your findings. |
@dv0892 has created a sample project that can reproduce this issue: https://github.com/dv0892/Security-Sample/tree/master Can you provide the code to do the FORWARD like you mention? Thanks |
Even I have enabled the FORWARD Dispatcher Type, it's still not working. Enter
|
I think it's not a good idea to mix springboot and jsp together.This is also the main problem in this issue besides forward. |
Finally, I found the solution here: https://stackoverflow.com/questions/77331852/how-do-i-set-a-home-page-can-be-opened-by-anyone-in-spring-security The problem is that my application file is not placed at the root package. |
Hi, @dv0892. Your configuration should look like this: @Bean
public SecurityFilterChain filterChain( HttpSecurity http , MvcRequestMatcher.Builder mvc) throws Exception {
http.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(auth ->
auth
.dispatcherTypeMatchers(DispatcherType.FORWARD).permitAll()
.requestMatchers(mvc.pattern("/"), mvc.pattern("/welcome")).permitAll()
.anyRequest().authenticated()
)
.formLogin(Customizer.withDefaults())
.httpBasic(Customizer.withDefaults());
return http.build();
}
@Scope("prototype")
@Bean
MvcRequestMatcher.Builder mvc(HandlerMappingIntrospector introspector) {
return new MvcRequestMatcher.Builder(introspector);
} Note that I removed the
In 6.2, that behavior has been fixed by #13850 where you can use Then, you must allow I'll close this since this is a configuration issue and not a bug, however I'll keep this updated if we can somehow improve the misleading error message. |
I am facing the same issue. Cannot access any of permitAll endpoints. My Security configuration:
TRACE log: 2024-03-06T17:07:06.378Z DEBUG 15416 --- [nio-8080-exec-2] s.w.a.DelegatingAuthenticationEntryPoint : Trying to match using RequestHeaderRequestMatcher [expectedHeaderName=X-Requested-With, expectedHeaderValue=XMLHttpRequest] org.springframework.security.access.AccessDeniedException: Access Denied |
I have the same problem. There is a specific type of configuration that causes the error to occur. Although if it remains closed it is less work to do. This option sounds better. By the way, with error 999. Like looking for a pin. |
I got the same problem with this code then i just added the
Another solution is, add the spring security dependency when you are creating the project not after creating the project |
I am configuring a bean of type SecurityFilterChain in a very simple spring boot application with jsp .
URI's like
/
or/welcome
should be accessible by anyoneBut URI
/authenticate
or any other request should require authenticationHere is Security Config
But it is asking me to login to every URI pattern including / and /welcome.
I have attached my sample repository on which I am facing this issue
https://github.com/dv0892/Security-Sample/tree/master
Seems like permitAll() is not working.
Please let me know if anything else is required
The text was updated successfully, but these errors were encountered: