-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Please add a mechanism to maintain authentication in cluster environment during oauth-authorization-code flow #306
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
I am struggling with the same issue, wanting and needing to remain stateless in a clustered environment which cannot guarantee me stickiness. Authorization code handling is done in OAuth2AuthorizationEndpointFilter, which is part of the Spring Security filter chain (and quite early in that filter chain, by default). This seems to suggest either It seems that to work in a stateless environment, the production of the authorization code would need to act on the result of the authentication process, rather than being embedded very early in that process. |
I think the spring-session project can solve the authentication problem in the cluster environment. The key problem is that the OAuth2AuthorizationService interface has only one memory-based implementation InMemoryOAuth2AuthorizationService, which means that OAuth2Authorization cannot be obtained in the cluster. |
I have already written a simple RedisOAuth2AuthroizationService implementation, and I don't want to import a spring-session to the server project, so now I just custom a KwAuthenticationSuccessHandler , AuthenticationEntryPoint, and add a custom filter which added before OAuth2AuthorizationEndpointFilter to get back the redirectUrl. Although it seems not a good way to alternate session mechanism, I have no better idea to solve it. |
Hi @gth7754125. I believe there are two main issues you're facing:
As @pxzxj pointed out, session management can easily be distributed using the spring-session project. This solves the problem of tying things like the You should also check out recent and ongoing work for clients, authorizations and consents using JDBC instead of in-memory: #291, #304, #314. You can base additional implementations such as the redis one you mentioned on these. I'm going to close this, as I'm not seeing a specific enhancement request. If you have a more specific request, feel free to open a new issue. |
I also have this problem. oauth2 solved the session problem, but now it has reintroduced the session problem. Can you consider abstracting the action of getting the code so that people with the same problem can solve the session problem through extension. At present, this action is integrated in the Filter and is not extensible. |
Can refer to this mechanism to separate Session?
state parameters can guarantee safety ... |
Hi @lu-cheng, I'm not quite following your question. I believe the commit I referenced is what you're looking for, as it introduces the ability to plug in a custom |
Eh.... Actually, authorization code is granted after user login, session can help us find back user authentication before user grants authorization code. |
I am struggling with the same issue.
When configuring I can only use multiple configurations to solve this problem. Below is my code
( My suggestion is to configured configurer separately from |
When the authorization server and the resource server exist at the same time, the resource server generally does not need a cookie method, but is stateless, which will cause the cookie to be rewritten as stateful and stored in the browser(in the resource server request) |
@lijiajia3515, apologies but I'm having a slightly difficult time understanding your comment. Are you asking a question, or simply pointing out an example of how to accomplish your particular goal? |
If the client does not support cookies, bootstrapping authentication is still easy to solve, but how to correlate previous authorization code requests after authentication has been bugging me. According to the existing design, actions and states are coupled. I've always wanted to introduce a temporary process ID to solve this problem, but the existing code logic is not friendly to such extensions. |
Current Behavior
If the authorization server needs to deploy in cluster's environment, i need to remove session mechanism.However, when i set
spring security can not trace my authentication info between login and authorization-code grant behaviour because the info lost between two requests, so it will loop on the login behaviour forever. Is that any way to deal with it?
The text was updated successfully, but these errors were encountered: