-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Auto-configure RequestAttributeSecurityContextRepository for OAuth2 resource server #29655
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
@datagitlies thanks for the report. By sample, we mean something we can run ourselves and not code in text we'd have to copy and paste with a chance of missing something that wasn't described. Can you move that in actual project please? You can do so by attaching a zip to this issue or sharing a link to a GitHub repository. |
Sure. The error-response-body.zip file contains a full sample you can run @snicoll One more note. By changing the version of the |
Thanks for the sample @datagitlies. This commit was added to support previously authorized users to access the error page. The fix covers all scenarios except the case where the error page security rules are different from the original request (which is the case here). We discussed that case and didn't think it would be a situation that would arise very often and thought it was better to restrict access when we don't have the Can you describe in more detail why you want an unauthorized user to view the error details? In this example, it seems like a regular user shouldn't be allowed to view the error details while trying to access an admin page. We could make it easier to exclude the error security filter for users who want to revert to 2.5.x behavior. However, that would allow unauthenticated access to the error page. You can see that on the sample app with 2.5.9, a request with no credentials can view the error details. The same behavior can be achieved on 2.6.3 with a |
I think of it like this. If you have authenticated yourself with valid credentials and you are a user of my application... I owe it to you to clearly communicate error information to you. Also, in my sample there is only one Regardless, I believe the real issue here is the lost security context for |
I'm also affected by this problem: the |
@svilen-ivanov-kubit, as @mbhave described above, you should be able to restore Boot 2.5's behaviour by using |
@wilkinsona I understand what you and @mbhave provided with
|
My thinking hasn't changed, but what I said there wasn't in the context of a stateless session creation policy. It's unfortunate that Spring Security does not preserve a user's authentication across multiple dispatches for the same original request when it has been configured not to use a session. I do not fully understand why the authentication cannot be preserved even without a session when only a single request has been made by the client. We'll discuss this with the Security team. Given Spring Security's current behaviour, we can either allow access by anyone to the error page (as Boot 2.5 did) or we can secure it but require a stateful session policy (as Boot 2.6 now does). If you're using 2.6 with a stateless session policy, you can opt back into Boot 2.5's behaviour by using |
I tried the
I'll try to find out how my setup differs from the minimal reproducible project (except that I use JWT for authentication). |
@svilen-ivanov-kubit A sample would be very helpful, thank you. |
Blocked on spring-projects/spring-security#10918. |
I updated our |
For 2.6 we're going to recommend that |
Assume that means spring-boot 2.6.x will not be using spring-security 5.7.x then? |
@datagitlies Spring Boot 2.6.x uses Spring security 5.6.x, so yes it won't be using spring security 5.7.x |
We think that auto-configuring |
This appears to have broken in
2.6.X
as older versions (I tried2.5.X
) do not exhibit the behavior described below.Step 1: provide a
WebSecurityConfigurerAdapter
and configure it with theSTATELESS
session creation policy:Step 2: setup a simple controller
Step 3: run the application and send a request to a resource the user is not authorized to view
Expected Behavior: the user receives a
HTTP 403 Forbidden
response status code and a response body (such as the below):Actual Behavior: the user receives a
HTTP 403 Forbidden
response status code with no response bodyNote: if the
STATELESS
session creation policy is removed from the above configuration, it works as expected.The text was updated successfully, but these errors were encountered: