Add KID in tokens

This commit is contained in:
Tracker-Friendly 2024-05-04 16:32:49 +01:00
parent 94662329e1
commit 606a0f18cc
1 changed files with 7 additions and 2 deletions

View File

@ -775,13 +775,18 @@ func main() {
"nonce": genSalt(512), "nonce": genSalt(512),
} }
jwt_token, err := jwt.NewWithClaims(jwt.SigningMethodRS256, datatemplate).SignedString(privateKey) tokentemp := jwt.NewWithClaims(jwt.SigningMethodRS256, datatemplate)
tokentemp.Header["kid"] = "burgerauth"
jwt_token, err := tokentemp.SignedString(privateKey)
if err != nil { if err != nil {
log.Println("[ERROR] Unknown in /api/auth jwt_token at", strconv.FormatInt(time.Now().Unix(), 10)+":", err) log.Println("[ERROR] Unknown in /api/auth jwt_token at", strconv.FormatInt(time.Now().Unix(), 10)+":", err)
c.String(500, "Something went wrong on our end. Please report this bug at https://centrifuge.hectabit.org/hectabit/burgerauth and refer to the docs for more detail. Include this error code: jwt_token_cannotsign.") c.String(500, "Something went wrong on our end. Please report this bug at https://centrifuge.hectabit.org/hectabit/burgerauth and refer to the docs for more detail. Include this error code: jwt_token_cannotsign.")
return return
} }
secret_token, err := jwt.NewWithClaims(jwt.SigningMethodRS256, datatemplate2).SignedString(privateKey)
secrettemp := jwt.NewWithClaims(jwt.SigningMethodRS256, datatemplate2)
secrettemp.Header["kid"] = "burgerauth"
secret_token, err := secrettemp.SignedString(privateKey)
if err != nil { if err != nil {
log.Println("[ERROR] Unknown in /api/auth secret_token at", strconv.FormatInt(time.Now().Unix(), 10)+":", err) log.Println("[ERROR] Unknown in /api/auth secret_token at", strconv.FormatInt(time.Now().Unix(), 10)+":", err)
c.String(500, "Something went wrong on our end. Please report this bug at https://centrifuge.hectabit.org/hectabit/burgerauth and refer to the docs for more detail. Include this error code: jwt_token_cannotsign_secret.") c.String(500, "Something went wrong on our end. Please report this bug at https://centrifuge.hectabit.org/hectabit/burgerauth and refer to the docs for more detail. Include this error code: jwt_token_cannotsign_secret.")