|
@@ -15,13 +15,13 @@
|
|
package httpd
|
|
package httpd
|
|
|
|
|
|
import (
|
|
import (
|
|
|
|
+ "crypto/sha256"
|
|
|
|
+ "encoding/hex"
|
|
"encoding/json"
|
|
"encoding/json"
|
|
"errors"
|
|
"errors"
|
|
"sync"
|
|
"sync"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
- "github.com/rs/xid"
|
|
|
|
-
|
|
|
|
"github.com/drakkan/sftpgo/v2/internal/dataprovider"
|
|
"github.com/drakkan/sftpgo/v2/internal/dataprovider"
|
|
"github.com/drakkan/sftpgo/v2/internal/kms"
|
|
"github.com/drakkan/sftpgo/v2/internal/kms"
|
|
"github.com/drakkan/sftpgo/v2/internal/logger"
|
|
"github.com/drakkan/sftpgo/v2/internal/logger"
|
|
@@ -53,8 +53,10 @@ type oauth2PendingAuth struct {
|
|
}
|
|
}
|
|
|
|
|
|
func newOAuth2PendingAuth(provider int, redirectURL, clientID string, clientSecret *kms.Secret) oauth2PendingAuth {
|
|
func newOAuth2PendingAuth(provider int, redirectURL, clientID string, clientSecret *kms.Secret) oauth2PendingAuth {
|
|
|
|
+ state := sha256.Sum256(util.GenerateRandomBytes(32))
|
|
|
|
+
|
|
return oauth2PendingAuth{
|
|
return oauth2PendingAuth{
|
|
- State: xid.New().String(),
|
|
|
|
|
|
+ State: hex.EncodeToString(state[:]),
|
|
Provider: provider,
|
|
Provider: provider,
|
|
ClientID: clientID,
|
|
ClientID: clientID,
|
|
ClientSecret: clientSecret,
|
|
ClientSecret: clientSecret,
|