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

redis-database session bug #726

Closed
sy264115809 opened this issue Aug 21, 2017 · 2 comments
Closed

redis-database session bug #726

sy264115809 opened this issue Aug 21, 2017 · 2 comments

Comments

@sy264115809
Copy link
Contributor

sy264115809 commented Aug 21, 2017

Hi @kataras , i found that there is another bug in this line:

// ...
storeMaybe, err := db.redis.Get(sid)
if err != nil {
	golog.Errorf("error while trying to load session values(%s) from redis: %v", sid, err)
	return
}

storeDB, ok := storeMaybe.(sessions.RemoteStore) // <- here
if !ok {
	golog.Errorf(`error while trying to load session values(%s) from redis:
	the retrieved value is not a sessions.RemoteStore type, please report that as bug, it should never occur`,sid)
	return
}
// ...

Since the value store of session had already been serialized before setting:

func (db *Database) sync(p sessions.SyncPayload) {
	// ...
	storeB, err := p.Store.Serialize()
	if err != nil {
		golog.Error("error while encoding the remote session store")
		return
	}
        // ...
}

they should be decoded after read from redis:

// bad: storeDB, ok := storeMaybe.(sessions.RemoteStore)
storeDB, err = sessions.DecodeRemoteStore(storeMaybe.([]byte))
if err != nil {
// ...
@kataras
Copy link
Owner

kataras commented Aug 21, 2017

@sy264115809 Correct, this should be left as it was because in the first place we tried to use another of redis feature to store the remote store as it is without custom encoding/decoding. I'll fix it right now but you can also make pull requests in the future, your bug reports are valid and welcomed, thank you for your contribution.

@sy264115809
Copy link
Contributor Author

👍🏻

github-actions bot pushed a commit to goproxies/github.com-kataras-iris that referenced this issue Jul 27, 2020
My second mistake on redis session db because I'm not personally use redis, so I'm waiting for redis users to find these type of errors inside it, such as @sy264115809


Former-commit-id: df84348df7509c0f863f41f01de6ed6db6e8133e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants