mirror of
https://github.com/minio/minio.git
synced 2025-02-03 01:46:00 -05:00
fix: hot-reloading STS credential policy documents (#20012)
* fix: hot-reloading STS credential policy documents * Support Role ARNs hot load policies (#28) --------- Co-authored-by: Anis Eleuch <vadmeste@users.noreply.github.com>
This commit is contained in:
parent
47bbc272df
commit
f365a98029
52
cmd/iam.go
52
cmd/iam.go
@ -315,6 +315,24 @@ func (sys *IAMSys) Init(ctx context.Context, objAPI ObjectLayer, etcdClient *etc
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cache := sys.store.lock()
|
||||||
|
setDefaultCannedPolicies(cache.iamPolicyDocsMap)
|
||||||
|
sys.store.unlock()
|
||||||
|
|
||||||
|
// Load RoleARNs
|
||||||
|
sys.rolesMap = make(map[arn.ARN]string)
|
||||||
|
|
||||||
|
// From OpenID
|
||||||
|
if riMap := sys.OpenIDConfig.GetRoleInfo(); riMap != nil {
|
||||||
|
sys.validateAndAddRolePolicyMappings(ctx, riMap)
|
||||||
|
}
|
||||||
|
|
||||||
|
// From AuthN plugin if enabled.
|
||||||
|
if authn := newGlobalAuthNPluginFn(); authn != nil {
|
||||||
|
riMap := authn.GetRoleInfo()
|
||||||
|
sys.validateAndAddRolePolicyMappings(ctx, riMap)
|
||||||
|
}
|
||||||
|
|
||||||
// Load IAM data from storage.
|
// Load IAM data from storage.
|
||||||
for {
|
for {
|
||||||
if err := sys.Load(retryCtx, true); err != nil {
|
if err := sys.Load(retryCtx, true); err != nil {
|
||||||
@ -334,20 +352,6 @@ func (sys *IAMSys) Init(ctx context.Context, objAPI ObjectLayer, etcdClient *etc
|
|||||||
|
|
||||||
go sys.periodicRoutines(ctx, refreshInterval)
|
go sys.periodicRoutines(ctx, refreshInterval)
|
||||||
|
|
||||||
// Load RoleARNs
|
|
||||||
sys.rolesMap = make(map[arn.ARN]string)
|
|
||||||
|
|
||||||
// From OpenID
|
|
||||||
if riMap := sys.OpenIDConfig.GetRoleInfo(); riMap != nil {
|
|
||||||
sys.validateAndAddRolePolicyMappings(ctx, riMap)
|
|
||||||
}
|
|
||||||
|
|
||||||
// From AuthN plugin if enabled.
|
|
||||||
if authn := newGlobalAuthNPluginFn(); authn != nil {
|
|
||||||
riMap := authn.GetRoleInfo()
|
|
||||||
sys.validateAndAddRolePolicyMappings(ctx, riMap)
|
|
||||||
}
|
|
||||||
|
|
||||||
sys.printIAMRoles()
|
sys.printIAMRoles()
|
||||||
|
|
||||||
bootstrapTraceMsg("finishing IAM loading")
|
bootstrapTraceMsg("finishing IAM loading")
|
||||||
@ -2214,22 +2218,16 @@ func (sys *IAMSys) IsAllowedSTS(args policy.Args, parentUser string) bool {
|
|||||||
// 2. Combine the mapped policies into a single combined policy.
|
// 2. Combine the mapped policies into a single combined policy.
|
||||||
|
|
||||||
var combinedPolicy policy.Policy
|
var combinedPolicy policy.Policy
|
||||||
|
// Policies were found, evaluate all of them.
|
||||||
if !isOwnerDerived {
|
if !isOwnerDerived {
|
||||||
var err error
|
availablePoliciesStr, c := sys.store.MergePolicies(strings.Join(policies, ","))
|
||||||
combinedPolicy, err = sys.store.GetPolicy(strings.Join(policies, ","))
|
if availablePoliciesStr == "" {
|
||||||
if errors.Is(err, errNoSuchPolicy) {
|
|
||||||
for _, pname := range policies {
|
|
||||||
_, err := sys.store.GetPolicy(pname)
|
|
||||||
if errors.Is(err, errNoSuchPolicy) {
|
|
||||||
// all policies presented in the claim should exist
|
// all policies presented in the claim should exist
|
||||||
iamLogIf(GlobalContext, fmt.Errorf("expected policy (%s) missing from the JWT claim %s, rejecting the request", pname, iamPolicyClaimNameOpenID()))
|
iamLogIf(GlobalContext, fmt.Errorf("expected policy (%s) missing from the JWT claim %s, rejecting the request", policies, iamPolicyClaimNameOpenID()))
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
iamLogIf(GlobalContext, fmt.Errorf("all policies were unexpectedly present!"))
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
combinedPolicy = c
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. If an inline session-policy is present, evaluate it.
|
// 3. If an inline session-policy is present, evaluate it.
|
||||||
|
@ -24,6 +24,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/minio/minio/internal/config"
|
"github.com/minio/minio/internal/config"
|
||||||
|
"github.com/minio/minio/internal/fips"
|
||||||
"github.com/minio/pkg/v3/env"
|
"github.com/minio/pkg/v3/env"
|
||||||
xnet "github.com/minio/pkg/v3/net"
|
xnet "github.com/minio/pkg/v3/net"
|
||||||
clientv3 "go.etcd.io/etcd/client/v3"
|
clientv3 "go.etcd.io/etcd/client/v3"
|
||||||
@ -160,6 +161,12 @@ func LookupConfig(kvs config.KVS, rootCAs *x509.CertPool) (Config, error) {
|
|||||||
if etcdSecure {
|
if etcdSecure {
|
||||||
cfg.TLS = &tls.Config{
|
cfg.TLS = &tls.Config{
|
||||||
RootCAs: rootCAs,
|
RootCAs: rootCAs,
|
||||||
|
PreferServerCipherSuites: true,
|
||||||
|
MinVersion: tls.VersionTLS12,
|
||||||
|
NextProtos: []string{"http/1.1", "h2"},
|
||||||
|
ClientSessionCache: tls.NewLRUClientSessionCache(64),
|
||||||
|
CipherSuites: fips.TLSCiphersBackwardCompatible(),
|
||||||
|
CurvePreferences: fips.TLSCurveIDs(),
|
||||||
}
|
}
|
||||||
// This is only to support client side certificate authentication
|
// This is only to support client side certificate authentication
|
||||||
// https://coreos.com/etcd/docs/latest/op-guide/security.html
|
// https://coreos.com/etcd/docs/latest/op-guide/security.html
|
||||||
|
Loading…
x
Reference in New Issue
Block a user