|
|
@ -5,8 +5,8 @@ import ( |
|
|
"testing" |
|
|
"testing" |
|
|
"time" |
|
|
"time" |
|
|
|
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/iam/oidc" |
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/iam/ldap" |
|
|
"github.com/seaweedfs/seaweedfs/weed/iam/ldap" |
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/iam/oidc" |
|
|
"github.com/seaweedfs/seaweedfs/weed/iam/policy" |
|
|
"github.com/seaweedfs/seaweedfs/weed/iam/policy" |
|
|
"github.com/seaweedfs/seaweedfs/weed/iam/sts" |
|
|
"github.com/seaweedfs/seaweedfs/weed/iam/sts" |
|
|
"github.com/stretchr/testify/assert" |
|
|
"github.com/stretchr/testify/assert" |
|
|
@ -185,11 +185,11 @@ func TestPolicyEnforcement(t *testing.T) { |
|
|
principal := response.AssumedRoleUser.Arn |
|
|
principal := response.AssumedRoleUser.Arn |
|
|
|
|
|
|
|
|
tests := []struct { |
|
|
tests := []struct { |
|
|
name string |
|
|
|
|
|
action string |
|
|
|
|
|
resource string |
|
|
|
|
|
|
|
|
name string |
|
|
|
|
|
action string |
|
|
|
|
|
resource string |
|
|
shouldAllow bool |
|
|
shouldAllow bool |
|
|
reason string |
|
|
|
|
|
|
|
|
reason string |
|
|
}{ |
|
|
}{ |
|
|
{ |
|
|
{ |
|
|
name: "allow read access", |
|
|
name: "allow read access", |
|
|
@ -350,11 +350,10 @@ func setupIntegratedIAMSystem(t *testing.T) *IAMManager { |
|
|
// Configure and initialize
|
|
|
// Configure and initialize
|
|
|
config := &IAMConfig{ |
|
|
config := &IAMConfig{ |
|
|
STS: &sts.STSConfig{ |
|
|
STS: &sts.STSConfig{ |
|
|
TokenDuration: time.Hour, |
|
|
|
|
|
MaxSessionLength: time.Hour * 12, |
|
|
|
|
|
Issuer: "test-sts", |
|
|
|
|
|
SigningKey: []byte("test-signing-key-32-characters-long"), |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TokenDuration: time.Hour, |
|
|
|
|
|
MaxSessionLength: time.Hour * 12, |
|
|
|
|
|
Issuer: "test-sts", |
|
|
|
|
|
SigningKey: []byte("test-signing-key-32-characters-long"), |
|
|
}, |
|
|
}, |
|
|
Policy: &policy.PolicyEngineConfig{ |
|
|
Policy: &policy.PolicyEngineConfig{ |
|
|
DefaultEffect: "Deny", |
|
|
DefaultEffect: "Deny", |
|
|
@ -424,7 +423,7 @@ func setupTestPoliciesAndRoles(t *testing.T, manager *IAMManager) { |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
err := manager.CreatePolicy(ctx, "S3ReadOnlyPolicy", s3ReadPolicy) |
|
|
|
|
|
|
|
|
err := manager.CreatePolicy(ctx, "", "S3ReadOnlyPolicy", s3ReadPolicy) |
|
|
require.NoError(t, err) |
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
// Create LDAP user policy
|
|
|
// Create LDAP user policy
|
|
|
@ -442,11 +441,11 @@ func setupTestPoliciesAndRoles(t *testing.T, manager *IAMManager) { |
|
|
}, |
|
|
}, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
err = manager.CreatePolicy(ctx, "LDAPUserPolicy", ldapUserPolicy) |
|
|
|
|
|
|
|
|
err = manager.CreatePolicy(ctx, "", "LDAPUserPolicy", ldapUserPolicy) |
|
|
require.NoError(t, err) |
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
// Create roles with trust policies
|
|
|
// Create roles with trust policies
|
|
|
err = manager.CreateRole(ctx, "S3ReadOnlyRole", &RoleDefinition{ |
|
|
|
|
|
|
|
|
err = manager.CreateRole(ctx, "", "S3ReadOnlyRole", &RoleDefinition{ |
|
|
RoleName: "S3ReadOnlyRole", |
|
|
RoleName: "S3ReadOnlyRole", |
|
|
TrustPolicy: &policy.PolicyDocument{ |
|
|
TrustPolicy: &policy.PolicyDocument{ |
|
|
Version: "2012-10-17", |
|
|
Version: "2012-10-17", |
|
|
@ -464,7 +463,7 @@ func setupTestPoliciesAndRoles(t *testing.T, manager *IAMManager) { |
|
|
}) |
|
|
}) |
|
|
require.NoError(t, err) |
|
|
require.NoError(t, err) |
|
|
|
|
|
|
|
|
err = manager.CreateRole(ctx, "LDAPUserRole", &RoleDefinition{ |
|
|
|
|
|
|
|
|
err = manager.CreateRole(ctx, "", "LDAPUserRole", &RoleDefinition{ |
|
|
RoleName: "LDAPUserRole", |
|
|
RoleName: "LDAPUserRole", |
|
|
TrustPolicy: &policy.PolicyDocument{ |
|
|
TrustPolicy: &policy.PolicyDocument{ |
|
|
Version: "2012-10-17", |
|
|
Version: "2012-10-17", |
|
|
|