diff --git a/server/auth/simple_token.go b/server/auth/simple_token.go index be706522a..5f66b56d1 100644 --- a/server/auth/simple_token.go +++ b/server/auth/simple_token.go @@ -20,6 +20,7 @@ package auth import ( "context" "crypto/rand" + "errors" "fmt" "math/big" "strconv" @@ -212,7 +213,11 @@ func (t *tokenSimple) info(ctx context.Context, token string, revision uint64) ( func (t *tokenSimple) assign(ctx context.Context, username string, rev uint64) (string, error) { // rev isn't used in simple token, it is only used in JWT - index := ctx.Value(AuthenticateParamIndex{}).(uint64) + var index uint64 + var ok bool + if index, ok = ctx.Value(AuthenticateParamIndex{}).(uint64); !ok { + return "", errors.New("failed to assign") + } simpleTokenPrefix := ctx.Value(AuthenticateParamSimpleTokenPrefix{}).(string) token := fmt.Sprintf("%s.%d", simpleTokenPrefix, index) t.assignSimpleTokenToUser(username, token)