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

All requests to /graphql always result in 401 unauthorized status (Spring boot 3.0.0 and WebMvc) #576

Closed
ohapegor opened this issue Dec 10, 2022 · 4 comments

Comments

@ohapegor
Copy link

Proof example app with details in README.md: https://github.com/ohapegor/spring-graphql-security-bug

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 10, 2022
@sbegaudeau
Copy link

I have the same issue, this may be related to this

@giovannymassuia
Copy link

I was staring a new project using spring boot 3.0.0 and was getting the same issue when protecting all endpoints and using JWT with AWS Cognito

@Configuration
public class SecurityConfig {

  @Bean
  public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
    return http
        .csrf(CsrfConfigurer::disable)
        .authorizeHttpRequests(auth -> auth
            .anyRequest().authenticated())
        .securityContext(context -> context.requireExplicitSave(false)) // <<<---------
        .oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt)
        .sessionManagement(session -> session
            .sessionCreationPolicy(SessionCreationPolicy.STATELESS))
        .build();
  }
}

What solved the issue for me, at least for now (keep in mind this is a brand new project), was to add this line:

 .securityContext(context -> context.requireExplicitSave(false))

I'm not sure yet why it worked setting this to false though.

Here is my repo with the project example.

@m-thirumal
Copy link

Had the same issue, and upgraded to 3.0.1 to fix it.

I think it's fixed in 3.0.1.

@giovannymassuia
Copy link

Awesome, just tested here upgrading to 3.0.1 and it worked like a charm. Thanks @m-thirumal for the tip 🙌

@ohapegor ohapegor closed this as completed Jan 1, 2023
@rstoyanchev rstoyanchev removed the status: waiting-for-triage An issue we've not yet triaged label Jan 4, 2023
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

No branches or pull requests

6 participants