Exception after changing IdentityKey
- Dominant language
- Go
- Stars
- 3k
- Forks
- 387
- Avg merge
- 4h 16m
- Merged PRs (30d)
- 1
Description
Suppose I set my auth IdentityKey to "uid", call `login`, and get a token and it works for the `auth` group. Now I change my auth IdentityKey to "userid", restart server, and try to call `auth` group again.
Expected behavior should be invalid token or some other 4xx errors, but instead I got 500:
```
interface conversion: interface {} is nil, not string
/usr/local/Cellar/go/1.11/libexec/src/runtime/panic.go:513 (0x102bbc8)
gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))
/usr/local/Cellar/go/1.11/libexec/src/runtime/iface.go:248 (0x100ac45)
panicdottypeE: panic(&TypeAssertionError{iface, have, want, ""})
/Users/leo/prj/web/go/src/hindsight/auth/auth.go:31 (0x15cd078)
GetMiddleware.func2: username := claims[user.IdentityKey].(string)
/Users/leo/prj/web/go/src/github.com/appleboy/gin-jwt/auth_jwt.go:340 (0x1545378)
(*GinJWTMiddleware).middlewareImpl: identity := mw.IdentityHandler(c)
/Users/leo/prj/web/go/src/github.com/appleboy/gin-jwt/auth_jwt.go:328 (0x15480c3)
(*GinJWTMiddleware).MiddlewareFunc.func1: mw.middlewareImpl(c)
/Users/leo/prj/web/go/src/github.com/gin-gonic/gin/context.go:108 (0x152b7a2)
(*Context).Next: c.handlers[c.index](c)
/Users/leo/prj/web/go/src/github.com/gin-gonic/gin/recovery.go:48 (0x153cb89)
RecoveryWithWriter.func1: c.Next()
/Users/leo/prj/web/go/src/github.com/gin-gonic/gin/context.go:108 (0x152b7a2)
(*Context).Next: c.handlers[c.index](c)
/Users/leo/prj/web/go/src/github.com/gin-gonic/gin/logger.go:84 (0x153be91)
LoggerWithWriter.func1: c.Next()
/Users/leo/prj/web/go/src/github.com/gin-gonic/gin/context.go:108 (0x152b7a2)
(*Context).Next: c.handlers[c.index](c)
/Users/leo/prj/web/go/src/github.com/gin-gonic/gin/gin.go:367 (0x153415a)
(*Engine).handleHTTPRequest: c.Next()
/Users/leo/prj/web/go/src/github.com/gin-gonic/gin/gin.go:332 (0x1533981)
(*Engine).ServeHTTP: engine.handleHTTPRequest(c)
/usr/local/Cellar/go/1.11/libexec/src/net/http/server.go:2741 (0x127fefa)
serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/local/Cellar/go/1.11/libexec/src/net/http/server.go:1847 (0x127c165)
(*conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/local/Cellar/go/1.11/libexec/src/runtime/asm_amd64.s:1333 (0x1058c80)
goexit: BYTE $0x90 // NOP
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.