Skip to content

Commit

Permalink
reject IDPs without supported response_types (#1645)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
  • Loading branch information
harshavardhana and dvaldivia committed Mar 1, 2022
1 parent a0bf2b4 commit fb99cf3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/auth/idp/oauth2/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"time"

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

"github.com/minio/console/pkg/auth/utils"
"golang.org/x/crypto/pbkdf2"
Expand Down Expand Up @@ -142,6 +143,11 @@ func getLoginCallbackURL(r *http.Request) string {
return redirectURL
}

var supportedResponseTypes = set.CreateStringSet([]string{
"code id_token",
"code token id_token",
}...)

// NewOauth2ProviderClient instantiates a new oauth2 client using the configured credentials
// it returns a *Provider object that contains the necessary configuration to initiate an
// oauth2 authentication flow
Expand All @@ -151,6 +157,18 @@ func NewOauth2ProviderClient(scopes []string, r *http.Request, httpClient *http.
return nil, err
}

var supported bool
for _, responseType := range ddoc.ResponseTypesSupported {
if supportedResponseTypes.Contains(responseType) {
supported = true
continue
}
}

if !supported {
return nil, fmt.Errorf("expected 'code id_token' response type - got %s, login not allowed", ddoc.ResponseTypesSupported)
}

// If provided scopes are empty we use a default list or the user configured list
if len(scopes) == 0 {
scopes = strings.Split(getIDPScopes(), ",")
Expand Down

0 comments on commit fb99cf3

Please sign in to comment.