Merge pull request #13682 from AdamKorcz/fuzz6

server/auth: fix oss-fuzz issue 44478
This commit is contained in:
Marek Siarkowicz 2022-02-13 17:43:43 +01:00 committed by GitHub
commit 489b30828d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)