mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 23:00:55 +03:00
oidc/oauth2: use an opaque state
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -16,6 +16,7 @@ package httpd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -203,9 +204,12 @@ type oidcPendingAuth struct {
|
||||
}
|
||||
|
||||
func newOIDCPendingAuth(audience tokenAudience) oidcPendingAuth {
|
||||
state := sha256.Sum256(util.GenerateRandomBytes(32))
|
||||
nonce := util.GenerateUniqueID()
|
||||
|
||||
return oidcPendingAuth{
|
||||
State: xid.New().String(),
|
||||
Nonce: hex.EncodeToString(util.GenerateRandomBytes(20)),
|
||||
State: hex.EncodeToString(state[:]),
|
||||
Nonce: nonce,
|
||||
Audience: audience,
|
||||
IssuedAt: util.GetTimeAsMsSinceEpoch(time.Now()),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user