-
Notifications
You must be signed in to change notification settings - Fork 6k
java.lang.IllegalStateException: permitAll only works with HttpSecurity.authorizeRequests() #7870
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
Comments
@akuma8 sorry to hear about the difficulty you are having, thank you for reaching out. I see that you had this same conversation with @eleftherias over on StackOverflow. It would probably be more appropriate to continue the conversation over there - I've added my own comment to Ria's answer about your question as to why Btw, I'm wondering why you are using the Keycloak adapter in this case? Since Keycloak's authorization server is compliant with several OAuth 2.0 RFCs, I'd imagine that using Spring Security native would do the trick for you. As far as I understand it, I've addressed your main question (over in StackOverflow), so I'm going to close this ticket. If you have further questions, please continue to post to StackOverflow as we usually have a team member watching out for questions there. If you have a bug or feature request, feel free to open another ticket. |
@akuma8 sorry, I might have been unclear. Please feel free to address my question
by adding a comment here in the issue, in order to make that conversation easier to follow for the community in the future. |
@jzheaux I am currently considering using only Spring Security (S.S.) without the KC adapter with the advantage to not beeing tied to KC but I have other issues. I reviewed my configurations and removed all KC concerns above all this class:
As stated in the documentation, I only define this porperty on
I still have my 2 filter chains:
And
To test, I ask my access token to KC with a user having the
When I disable
I use Spring Boot 2.2.4.RELEASE, security dependencies:
I am seriously thinking about contributing to Spring Security, I think that will be the only way to well understand how it works. If you have issues for beginners please let me know. |
@akuma8 I believe what is primarily missing is any kind of authentication mechanism in your configuration. For example, a typical @Configuration
@Order( 99 )
public class SelfResourceProtection extends WebSecurityConfigurerAdapter {
@Override
public void configure( HttpSecurity http ) throws Exception {
http.requestMatchers().antMatchers( "/self/**" )
.and()
.authorizeRequests()
.antMatchers( HttpMethod.GET, "/self/update" ).hasRole( "ADMIN" )
.antMatchers( HttpMethod.GET, "/self/accept").permitAll()
.and()
.oauth2ResourceServer()
.jwt();
}
} Spring Boot declares You might consider posting a minimal sample GitHub project with your code, if you aren't able to make further progress. We love new contributors! You can have a look at our |
@jzheaux I added
But S.S. doesn't have acces to the user roles defined in KC, only client scopes are available. I would like to not set scopes to users and use them only for clients. Is it possible to have access to user roles with this configuration? Regarding contribution, I would like to start with this issue: #7824 |
@jzheaux Thanks for the link, I finally managed to find a working solution. A question, do you think is it possible to add the Jwt converters at the
in each class. |
Hi,
I am migrating from Spring Security OAuth to Keycloak but I have some issue that should not occured if we follow the DSL api provided by Spring Security.
I simply have this configuration :
I didn't override
protected void configure( HttpSecurity http )
method and when I run my app this exception is thrown:After turning arround a moment, it sounds like the configuration from keycloak cause that exception, here's the configuration of
KeycloakWebSecurityConfigurerAdapter#configure(HttpSecurity http)
:What I don't understand is why
.logoutUrl("/sso/logout").permitAll()
throws an exception since the configuration DSL is planned to be used like that? I don't think the issue comes from Keycloak, they use the Api as provided by Spring Security.To solve the problem I tried to override
configure(HttpSecurity http)
like this:And I defined other filters:
And
And use token introspection:
The application starts but I am getting a 403 Forbidden error. When I change the order of my custom filters to:
Any security rules is applied.
What I would like is to define all Keycloak configurations in:
without overriding the
configure( HttpSecurity http )
then defining other classes extendingWebSecurityConfigurerAdapter
to declare http security rules. But with that exception I can't.The text was updated successfully, but these errors were encountered: