Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions pkg/auth/idp/oauth2/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ package oauth2

import (
"crypto/sha1"
"strconv"
"strings"
"time"

"github.com/minio/console/pkg/auth/token"
"github.com/minio/pkg/v2/env"
Expand Down Expand Up @@ -106,15 +104,3 @@ func getSaltForIDPHmac() string {
func getIDPScopes() string {
return env.Get(ConsoleIDPScopes, "openid,profile,email")
}

// getIDPTokenExpiration return default token expiration for access token
func getIDPTokenExpiration() time.Duration {
expiration := 12 * 3600
if expStr := env.Get(ConsoleIDPTokenExpiration, ""); expStr != "" {
if exp, err := strconv.Atoi(expStr); err == nil {
expiration = exp
}
}

return time.Duration(expiration) * time.Second
}
24 changes: 14 additions & 10 deletions pkg/auth/idp/oauth2/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import (
"strings"
"time"

"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/minio/minio-go/v7/pkg/set"

"github.com/minio/console/pkg/auth/token"
"github.com/minio/console/pkg/auth/utils"
"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/minio/minio-go/v7/pkg/set"
"github.com/minio/pkg/v2/env"
"golang.org/x/crypto/pbkdf2"
"golang.org/x/oauth2"
xoauth2 "golang.org/x/oauth2"
Expand Down Expand Up @@ -331,14 +331,18 @@ func (client *Provider) VerifyIdentity(ctx context.Context, code, state, roleARN
}
client.RefreshToken = oauth2Token.RefreshToken

expiration := token.GetConsoleSTSDuration()
if exp := getIDPTokenExpiration(); exp > 0 {
expiration = exp
}
envStsDuration := env.Get(token.ConsoleSTSDuration, "")
stsDuration, err := time.ParseDuration(envStsDuration)

expiration := 12 * time.Hour

// Use the expiration configured in the token itself if it is closer than the configured value
if exp := oauth2Token.Expiry.Sub(time.Now().UTC()); exp < expiration {
expiration = exp
if err == nil && stsDuration > 0 {
expiration = stsDuration
} else {
// Use the expiration configured in the token itself if it is closer than the configured value
if exp := oauth2Token.Expiry.Sub(time.Now().UTC()); exp < expiration {
expiration = exp
}
}

// Minimum duration in S3 spec is 15 minutes, do not bother returning
Expand Down