@ -25,6 +25,7 @@ import (
"github.com/minio/minio/cmd/logger"
"github.com/minio/minio/cmd/logger"
"github.com/minio/minio/pkg/auth"
"github.com/minio/minio/pkg/auth"
"github.com/minio/minio/pkg/iam/validator"
"github.com/minio/minio/pkg/iam/validator"
"github.com/minio/minio/pkg/wildcard"
)
)
const (
const (
@ -49,13 +50,19 @@ func registerSTSRouter(router *mux.Router) {
stsRouter := router . NewRoute ( ) . PathPrefix ( "/" ) . Subrouter ( )
stsRouter := router . NewRoute ( ) . PathPrefix ( "/" ) . Subrouter ( )
// Assume roles with no JWT, handles AssumeRole.
// Assume roles with no JWT, handles AssumeRole.
stsRouter . Methods ( "POST" ) . HeadersRegexp ( "Content-Type" , "application/x-www-form-urlencoded*" ) .
stsRouter . Methods ( "POST" ) . MatcherFunc ( func ( r * http . Request , rm * mux . RouteMatch ) bool {
HeadersRegexp ( "Authorization" , "AWS4-HMAC-SHA256*" ) .
ctypeOk := wildcard . MatchSimple ( "application/x-www-form-urlencoded*" , r . Header . Get ( "Content-Type" ) )
HandlerFunc ( httpTraceAll ( sts . AssumeRole ) )
authOk := wildcard . MatchSimple ( "AWS4-HMAC-SHA256*" , r . Header . Get ( "Authorization" ) )
noQueries := len ( r . URL . Query ( ) ) == 0
return ctypeOk && authOk && noQueries
} ) . HandlerFunc ( httpTraceAll ( sts . AssumeRole ) )
// Assume roles with JWT handler, handles both ClientGrants and WebIdentity.
// Assume roles with JWT handler, handles both ClientGrants and WebIdentity.
stsRouter . Methods ( "POST" ) . HeadersRegexp ( "Content-Type" , "application/x-www-form-urlencoded*" ) .
stsRouter . Methods ( "POST" ) . MatcherFunc ( func ( r * http . Request , rm * mux . RouteMatch ) bool {
HandlerFunc ( httpTraceAll ( sts . AssumeRoleWithJWT ) )
ctypeOk := wildcard . MatchSimple ( "application/x-www-form-urlencoded*" , r . Header . Get ( "Content-Type" ) )
noQueries := len ( r . URL . Query ( ) ) == 0
return ctypeOk && noQueries
} ) . HandlerFunc ( httpTraceAll ( sts . AssumeRoleWithJWT ) )
// AssumeRoleWithClientGrants
// AssumeRoleWithClientGrants
stsRouter . Methods ( "POST" ) . HandlerFunc ( httpTraceAll ( sts . AssumeRoleWithClientGrants ) ) .
stsRouter . Methods ( "POST" ) . HandlerFunc ( httpTraceAll ( sts . AssumeRoleWithClientGrants ) ) .