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

spring gateway can not pass the same session id it received from frontend to backend service #1920

Closed
xinghen110 opened this issue Aug 28, 2020 · 3 comments

Comments

@xinghen110
Copy link

Describe
I use spring gateway as a rou::ter for microservice system build by spring cloud, and spring session redis as shared session. I found that the session id frontend pass to gateway and gateway pass to backend service is different , so that the backend service can not get the right user session.

Gateway config
routes:
- id : user-service
uri: lb://user-service
predicates:
- Method=GET,POST
filters:
- SaveSession
- StripPrefix=1
- MapRequestHeader=cookie, cookie
- DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin Set-Cookie
- RemoveResponseHeader=Set-Cookie

version
spring-cloud.version: Greenwich.SR6
spring-boot.version: 2.1.16.RELEASE
spring-cloud-alibaba.version: 2.1.2.RELEASE
spring-session-data-redis: 2.1.12.RELEASE

@catBigcat
Copy link

I advise you debug in ReactiveRedisSessionRepository.

@Override
public Mono<RedisSession> findById(String id) {
	String sessionKey = getSessionKey(id);

	// @formatter:off
	return this.sessionRedisOperations.opsForHash().entries(sessionKey). 

in redis ,sessionKey is spring:session:sessions:expires:45b4ebb1-2a29-4a75-bbca-eee75b9a54de.
but sessionKey is spring:session:sessions:expires:NDViNGViYjEtMmEyOS00YTc1LWJiY2EtZWVlNzViOWE1NGRl in gateway.

this cookie what'name is SESSION , encoded by base64 and not decoded in Netty.
Hope to help you。

@spring-cloud-issues
Copy link

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-cloud-issues
Copy link

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

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

4 participants