sessions
sessions copied to clipboard
gob: decoding into local type *string, received remote type map[interface]interface
I've hit a wall with this error after attempting to load a key from the session. I create a Redis Store using a pre-existing pool and then utilize the session when handling authentication:
session.Set("AUTH_STATE", state)
session.Save()
In an OAuth callback handler I attempt to load the AUTH_STATE
from the session (source):
v := session.Get("AUTH_STATE")
if v == nil {
c.Error(errAuth.WithDetail("Auth state is nil"))
c.Abort()
return
}
The AUTH_STATE
value is always nil
and this error is reported to stderr:
gob: decoding into local type *string, received remote type map[interface]interface
Though it seems the error also occurs whenever the session is loaded at the beginning of every handler after the session is created. I noticed @boj encountered this error while creating redistore, but has since resolved the problem.
I've been banging my head on the table for days over this. I'd greatly appreciate any assistance.
Did you manage to work this one out? Sounds a bit like a race condition
@nazwa No, I'm still experiencing this issue. How do you figure? The session access always happens in a subsequent request after the initial request that set the AUTH_STATE
in the first place.
It's simply a string value for use with an OAuth Authorization Grant:
- Login request handler in my application. Sets
AUTH_STATE
to randomly generated UUID - Login request responds with a redirect to the OAuth service provider, passing along the generated state UUID as a query parameter.
- After the OAuth service provider authenticates the user it redirects back to my application. My complete handler accepts the state provided by the OAuth service provider in a query parameter and verifies that it matches the
AUTH_STATE
stored in the session.
Ok. I'm away all week so can't test this myself, but could you try two things:
- Change the storage to memcache and cookie and see if the same problem occurs
- Try to use redis directly, so not through the session middleware, but yourself set redis value and then read it
If both of these work fine, then we'll have to look in more depth at this.
@nazwa
- The problem does not occur with cookie storage. I have not tried with memcache
- Redis works wonderfully when used directly via garyburd/redigo
I'm working around this issue by using my own homegrown session store
That's probably the best thing to do for now. I'll see if I can play with it over the next week to try and track it down.
I've had the same problem recently.
But it doesn't happen every time.