Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-08-28 18:43:43 +08:00
commit 312a3c0632
2 changed files with 7 additions and 9 deletions

View File

@ -134,12 +134,11 @@ func GenerateJwtTokenUint64(AccessSecret uint64, accessExpire, nowSec int64, use
claims["exp"] = nowSec + accessExpire claims["exp"] = nowSec + accessExpire
claims["iat"] = nowSec claims["iat"] = nowSec
if userid == 0 && guestid == 0 { // if userid == 0 && guestid == 0 {
err := errors.New("userid and guestid cannot be 0 at the same time") // err := errors.New("userid and guestid cannot be 0 at the same time")
logx.Error(err) // logx.Error(err)
return "", err // return "", err
// }
}
claims["user_id"] = userid claims["user_id"] = userid
claims["guest_id"] = guestid claims["guest_id"] = guestid

View File

@ -18,12 +18,11 @@ func TestHash(t *testing.T) {
h := sha256.New() h := sha256.New()
h.Write([]byte(a)) h.Write([]byte(a))
s := "5JlPincPavgw0X/Fmj15xLId5vOEtdarc6hR1XlBx80=" s := "5JlPincPavgw0X/Fmj15xLId5vOEtdarc6hR1XlBx80="
log.Println(auth.GenerateJwtTokenUint64(auth.StringToHash(s), 999999999999999, time.Now().UTC().Unix(), 0, 0))
log.Println(auth.GenerateJwtTokenUint64(auth.StringToHash(s), 421231233, time.Now().UTC().Unix(), 39, 0))
key := auth.StringToHash(s) key := auth.StringToHash(s)
log.Println(key) log.Println(key)
// log.Println(auth.GenerateJwtTokenUint64(auth.StringToHash(s), 400000000, time.Now().UTC().Unix(), 39, 0)) // log.Println(auth.GenerateJwtTokenUint64(auth.StringToHash(s), 400000000, time.Now().UTC().Unix(), 39, 0))
authkey := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjIwOTMxOTIyMjYsImd1ZXN0X2lkIjowLCJpYXQiOjE2OTMxOTIyMjYsInVzZXJfaWQiOjM5fQ.DrvtD7gKB0gz1rAOAQHSnyBK3exTFqoLlacpZiadpB4" authkey := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjEwMDAwMDAwMDE2OTMyMTYxNDMsImd1ZXN0X2lkIjowLCJpYXQiOjE2OTMyMTYxNDQsInVzZXJfaWQiOjB9.KnesyIk9hNHlXPRkvqNmI7pf-icxmL8VB56zUm6ajxE"
log.Println(authkey) log.Println(authkey)
log.Println(auth.TParseJwtTokenHeader[auth.UserInfo](authkey)) log.Println(auth.TParseJwtTokenHeader[auth.UserInfo](authkey))
log.Println(auth.ParseJwtTokenUint64Secret(authkey, key)) log.Println(auth.ParseJwtTokenUint64Secret(authkey, key))