Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a01bafcdde |
No files matched your search
@@ -18,4 +18,16 @@ Demo User have different roles on different instances
|
||||
|
||||
Users can be invited to instances they are not member of by using their exact email address in space membership or share dialog.
|
||||
|
||||
## Master-ID Configuration
|
||||
|
||||
**Configuration:**
|
||||
- **Master-ID Value**: `11111111-1111-1111-1111-111111111111`
|
||||
- **Environment Variable**: `OCIS_MULTI_INSTANCE_MASTER_ID`
|
||||
- **User**: admin (configured in config/ldap/ldif/20_users.ldif)
|
||||
- **Purpose**: Users with this ID in their `owncloudMemberOf` or `owncloudGuestOf` claims can login to any instance
|
||||
|
||||
Users with the master-id are granted member access to all instances without maintaining instance-specific IDs. The feature is optional and disabled when `OCIS_MULTI_INSTANCE_MASTER_ID` is empty.
|
||||
|
||||
**Security Note:** Master-id grants member status only (not admin privileges). Regular users require specific instance IDs for access control.
|
||||
|
||||
|
||||
@@ -126,7 +126,6 @@ uidNumber: 20004
|
||||
gidNumber: 30000
|
||||
homeDirectory: /home/admin
|
||||
ownCloudUUID: ddc2004c-0977-11eb-9d3f-a793888cd0f8
|
||||
owncloudMemberOf: ec730a6c-1b63-4b45-b83b-9e2311afdf85
|
||||
owncloudMemberOf: 8d24cb5f-6ee6-4b98-86df-c4c268dddb46
|
||||
owncloudMemberOf: 11111111-1111-1111-1111-111111111111
|
||||
ownCloudRole: ocisAdmin
|
||||
userPassword:: e1NTSEF9UWhmaFB3dERydTUydURoWFFObDRMbzVIckI3TkI5Nmo=
|
||||
@@ -41,6 +41,11 @@ olcAttributeTypes: ( ownCloudOid:1.1.9 NAME 'ownCloudRole'
|
||||
EQUALITY caseIgnoreMatch
|
||||
SUBSTR caseIgnoreSubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
|
||||
olcAttributeTypes: ( ownCloudOid:1.1.10 NAME 'owncloudExternalID'
|
||||
DESC 'External ID for the user'
|
||||
EQUALITY caseIgnoreMatch
|
||||
SUBSTR caseIgnoreSubstringsMatch
|
||||
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
|
||||
olcObjectClasses: ( ownCloudOid:1.2.1 NAME 'ownCloud'
|
||||
DESC 'ownCloud LDAP Schema'
|
||||
AUXILIARY
|
||||
@@ -49,7 +54,7 @@ olcObjectClasses: ( ownCloudOid:1.2.2 NAME 'ownCloudUser'
|
||||
DESC 'ownCloud User LDAP Schema'
|
||||
SUP ownCloud
|
||||
AUXILIARY
|
||||
MAY ( ocExternalIdentity $ ownCloudUserEnabled $ ownCloudUserType $ ocLastSignInTimestamp $ ownCloudMemberOf $ ownCloudGuestOf $ ownCloudRole) )
|
||||
MAY ( ocExternalIdentity $ ownCloudUserEnabled $ ownCloudUserType $ ocLastSignInTimestamp $ ownCloudMemberOf $ ownCloudGuestOf $ ownCloudRole $ owncloudExternalID) )
|
||||
olcObjectClasses: ( ownCloudOid:1.2.3 NAME 'ownCloudGroup'
|
||||
DESC 'ownCloud Group LDAP Schema'
|
||||
SUP groupOfNames
|
||||
|
||||
@@ -105,7 +105,8 @@ services:
|
||||
# Multi-Instance Configuration
|
||||
OCIS_MULTI_INSTANCE_ENABLED: true
|
||||
OCIS_MULTI_INSTANCE_INSTANCEID: "ec730a6c-1b63-4b45-b83b-9e2311afdf85"
|
||||
OCIS_LDAP_USER_FILTER: "(&(objectclass=owncloud)(|(ownCloudMemberOf=ec730a6c-1b63-4b45-b83b-9e2311afdf85)(ownCloudGuestOf=ec730a6c-1b63-4b45-b83b-9e2311afdf85)))"
|
||||
OCIS_MULTI_INSTANCE_MASTER_ID: "11111111-1111-1111-1111-111111111111"
|
||||
OCIS_LDAP_USER_FILTER: "(&(objectclass=owncloud)(|(ownCloudMemberOf=ec730a6c-1b63-4b45-b83b-9e2311afdf85)(ownCloudGuestOf=ec730a6c-1b63-4b45-b83b-9e2311afdf85)(ownCloudMemberOf=11111111-1111-1111-1111-111111111111)))"
|
||||
OCIS_LDAP_GROUP_FILTER: "(&(objectclass=owncloud)(ownCloudMemberOf=ec730a6c-1b63-4b45-b83b-9e2311afdf85))"
|
||||
OCIS_LDAP_USER_MEMBER_ATTRIBUTE: "owncloudMemberOf"
|
||||
OCIS_LDAP_USER_GUEST_ATTRIBUTE: "ownCloudGuestOf"
|
||||
@@ -206,7 +207,8 @@ services:
|
||||
# Multi-Instance
|
||||
OCIS_MULTI_INSTANCE_ENABLED: true
|
||||
OCIS_MULTI_INSTANCE_INSTANCEID: "8d24cb5f-6ee6-4b98-86df-c4c268dddb46"
|
||||
OCIS_LDAP_USER_FILTER: "(&(objectclass=owncloud)(|(ownCloudMemberOf=8d24cb5f-6ee6-4b98-86df-c4c268dddb46)(ownCloudGuestOf=8d24cb5f-6ee6-4b98-86df-c4c268dddb46)))"
|
||||
OCIS_MULTI_INSTANCE_MASTER_ID: "11111111-1111-1111-1111-111111111111"
|
||||
OCIS_LDAP_USER_FILTER: "(&(objectclass=owncloud)(|(ownCloudMemberOf=8d24cb5f-6ee6-4b98-86df-c4c268dddb46)(ownCloudGuestOf=8d24cb5f-6ee6-4b98-86df-c4c268dddb46)(ownCloudMemberOf=11111111-1111-1111-1111-111111111111)))"
|
||||
OCIS_LDAP_GROUP_FILTER: "(&(objectclass=owncloud)(ownCloudMemberOf=8d24cb5f-6ee6-4b98-86df-c4c268dddb46))"
|
||||
OCIS_LDAP_USER_MEMBER_ATTRIBUTE: "owncloudMemberOf"
|
||||
OCIS_LDAP_USER_GUEST_ATTRIBUTE: "ownCloudGuestOf"
|
||||
|
||||
@@ -355,7 +355,7 @@ func loadMiddlewares(logger log.Logger, cfg *config.Config,
|
||||
middleware.UserCS3Claim(cfg.UserCS3Claim),
|
||||
middleware.AutoprovisionAccounts(cfg.AutoprovisionAccounts),
|
||||
middleware.EventsPublisher(publisher),
|
||||
middleware.MultiInstance(cfg.MultiInstance.Enabled, cfg.MultiInstance.InstanceID, cfg.MultiInstance.MemberClaim, cfg.MultiInstance.GuestClaim, cfg.MultiInstance.GuestRole),
|
||||
middleware.MultiInstance(cfg.MultiInstance.Enabled, cfg.MultiInstance.InstanceID, cfg.MultiInstance.MasterID, cfg.MultiInstance.MemberClaim, cfg.MultiInstance.GuestClaim, cfg.MultiInstance.GuestRole),
|
||||
),
|
||||
middleware.MultiFactor(cfg.MultiFactorAuthentication, middleware.Logger(logger)),
|
||||
middleware.SelectorCookie(
|
||||
|
||||
@@ -251,6 +251,7 @@ type ClaimSpaceManagement struct {
|
||||
type MultiInstanceConfig struct {
|
||||
Enabled bool `yaml:"enabled" env:"OCIS_MULTI_INSTANCE_ENABLED" desc:"Enable multiple instances of Infinite Scale." introductionVersion:"8.0.0"`
|
||||
InstanceID string `yaml:"instanceid" env:"OCIS_MULTI_INSTANCE_INSTANCEID" desc:"The unique id of this instance" introductionVersion:"8.0.0"`
|
||||
MasterID string `yaml:"master_id" env:"OCIS_MULTI_INSTANCE_MASTER_ID" desc:"The master ID that grants access to all instances. Users with this ID in their memberOf or guestOf claims can access any instance. Leave empty to disable." introductionVersion:"NEXT"`
|
||||
MemberClaim string `yaml:"member_claim" env:"OCIS_MULTI_INSTANCE_MEMBER_CLAIM" desc:"The claim name for the 'memberOf' property" introductionVersion:"8.0.0"`
|
||||
GuestClaim string `yaml:"guest_claim" env:"OCIS_MULTI_INSTANCE_GUEST_CLAIM" desc:"The claim name for the 'guestOf' property" introductionVersion:"8.0.0"`
|
||||
GuestRole string `yaml:"guest_role" env:"OCIS_MULTI_INSTANCE_GUEST_ROLE" desc:"The role that should be assigned to a guest user" introductionVersion:"8.0.0"`
|
||||
|
||||
@@ -43,6 +43,7 @@ func AccountResolver(optionSetters ...Option) func(next http.Handler) http.Handl
|
||||
eventsPublisher: options.EventsPublisher,
|
||||
multiInstance: options.MultiInstanceEnabled,
|
||||
instanceID: options.InstanceID,
|
||||
masterID: options.MasterID,
|
||||
memberClaim: options.MemberClaim,
|
||||
guestClaim: options.GuestClaim,
|
||||
guestRoleName: options.GuestRoleName,
|
||||
@@ -70,6 +71,7 @@ type accountResolver struct {
|
||||
guestClaim string
|
||||
guestRoleName string
|
||||
instanceID string
|
||||
masterID string
|
||||
}
|
||||
|
||||
// TODO do not use the context to store values: https://medium.com/@cep21/how-to-correctly-use-context-context-in-go-1-7-8f2c0fafdf39
|
||||
@@ -221,6 +223,17 @@ func (m accountResolver) resolveUserType(claims map[string]interface{}) (isMembe
|
||||
// single instance behaviour - any user is considered a member
|
||||
return true, false
|
||||
}
|
||||
|
||||
// Check for master-id first (if configured)
|
||||
if m.masterID != "" {
|
||||
for _, miid := range readClaim(m.memberClaim, claims) {
|
||||
if miid != "" && miid == m.masterID {
|
||||
return true, false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for instance-specific ID
|
||||
for _, miid := range readClaim(m.memberClaim, claims) {
|
||||
if miid != "" && miid == m.instanceID {
|
||||
return true, false
|
||||
|
||||
@@ -295,3 +295,180 @@ func mockRequest(claims map[string]interface{}) (*http.Request, *httptest.Respon
|
||||
type mockHandler struct{}
|
||||
|
||||
func (m mockHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) {}
|
||||
|
||||
func TestResolveUserType(t *testing.T) {
|
||||
const (
|
||||
instanceID1 = "ec730a6c-1b63-4b45-b83b-9e2311afdf85"
|
||||
instanceID2 = "8d24cb5f-6ee6-4b98-86df-c4c268dddb46"
|
||||
masterID = "11111111-1111-1111-1111-111111111111"
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
multiInstance bool
|
||||
instanceID string
|
||||
masterID string
|
||||
memberClaim string
|
||||
guestClaim string
|
||||
claims map[string]interface{}
|
||||
expectMember bool
|
||||
expectGuest bool
|
||||
description string
|
||||
}{
|
||||
{
|
||||
name: "single instance mode - always member",
|
||||
multiInstance: false,
|
||||
instanceID: instanceID1,
|
||||
masterID: "",
|
||||
memberClaim: "owncloudMemberOf",
|
||||
guestClaim: "owncloudGuestOf",
|
||||
claims: map[string]interface{}{},
|
||||
expectMember: true,
|
||||
expectGuest: false,
|
||||
description: "In single instance mode, any user should be considered a member",
|
||||
},
|
||||
{
|
||||
name: "multi-instance: user has matching instance ID in memberClaim",
|
||||
multiInstance: true,
|
||||
instanceID: instanceID1,
|
||||
masterID: "",
|
||||
memberClaim: "owncloudMemberOf",
|
||||
guestClaim: "owncloudGuestOf",
|
||||
claims: map[string]interface{}{
|
||||
"owncloudMemberOf": instanceID1,
|
||||
},
|
||||
expectMember: true,
|
||||
expectGuest: false,
|
||||
description: "User with matching instance ID should be granted member access",
|
||||
},
|
||||
{
|
||||
name: "multi-instance: user has matching instance ID in guestClaim",
|
||||
multiInstance: true,
|
||||
instanceID: instanceID1,
|
||||
masterID: "",
|
||||
memberClaim: "owncloudMemberOf",
|
||||
guestClaim: "owncloudGuestOf",
|
||||
claims: map[string]interface{}{
|
||||
"owncloudGuestOf": instanceID1,
|
||||
},
|
||||
expectMember: false,
|
||||
expectGuest: true,
|
||||
description: "User with matching instance ID in guestClaim should be granted guest access",
|
||||
},
|
||||
{
|
||||
name: "multi-instance: user has no matching instance ID",
|
||||
multiInstance: true,
|
||||
instanceID: instanceID1,
|
||||
masterID: "",
|
||||
memberClaim: "owncloudMemberOf",
|
||||
guestClaim: "owncloudGuestOf",
|
||||
claims: map[string]interface{}{
|
||||
"owncloudMemberOf": instanceID2,
|
||||
},
|
||||
expectMember: false,
|
||||
expectGuest: false,
|
||||
description: "User without matching instance ID should be denied access",
|
||||
},
|
||||
{
|
||||
name: "multi-instance with master-id: user has master-id in memberClaim",
|
||||
multiInstance: true,
|
||||
instanceID: instanceID1,
|
||||
masterID: masterID,
|
||||
memberClaim: "owncloudMemberOf",
|
||||
guestClaim: "owncloudGuestOf",
|
||||
claims: map[string]interface{}{
|
||||
"owncloudMemberOf": masterID,
|
||||
},
|
||||
expectMember: true,
|
||||
expectGuest: false,
|
||||
description: "User with master-id in memberClaim should be granted member access to any instance",
|
||||
},
|
||||
{
|
||||
name: "multi-instance with master-id disabled: user has master-id value but feature disabled",
|
||||
multiInstance: true,
|
||||
instanceID: instanceID1,
|
||||
masterID: "", // Empty = disabled
|
||||
memberClaim: "owncloudMemberOf",
|
||||
guestClaim: "owncloudGuestOf",
|
||||
claims: map[string]interface{}{
|
||||
"owncloudMemberOf": masterID,
|
||||
},
|
||||
expectMember: false,
|
||||
expectGuest: false,
|
||||
description: "When master-id is empty/disabled, having the master-id value should not grant access",
|
||||
},
|
||||
{
|
||||
name: "multi-instance with master-id: user has both master-id and instance-id",
|
||||
multiInstance: true,
|
||||
instanceID: instanceID1,
|
||||
masterID: masterID,
|
||||
memberClaim: "owncloudMemberOf",
|
||||
guestClaim: "owncloudGuestOf",
|
||||
claims: map[string]interface{}{
|
||||
"owncloudMemberOf": []string{masterID, instanceID1},
|
||||
},
|
||||
expectMember: true,
|
||||
expectGuest: false,
|
||||
description: "User with both master-id and instance-id should be granted access (master-id matches first)",
|
||||
},
|
||||
{
|
||||
name: "multi-instance with master-id: array with master-id in middle",
|
||||
multiInstance: true,
|
||||
instanceID: instanceID1,
|
||||
masterID: masterID,
|
||||
memberClaim: "owncloudMemberOf",
|
||||
guestClaim: "owncloudGuestOf",
|
||||
claims: map[string]interface{}{
|
||||
"owncloudMemberOf": []string{instanceID2, masterID, "other-id"},
|
||||
},
|
||||
expectMember: true,
|
||||
expectGuest: false,
|
||||
description: "Master-id should be found when it's in an array with other values",
|
||||
},
|
||||
{
|
||||
name: "multi-instance with master-id: user on wrong instance but has master-id",
|
||||
multiInstance: true,
|
||||
instanceID: instanceID2, // Different instance
|
||||
masterID: masterID,
|
||||
memberClaim: "owncloudMemberOf",
|
||||
guestClaim: "owncloudGuestOf",
|
||||
claims: map[string]interface{}{
|
||||
"owncloudMemberOf": masterID,
|
||||
},
|
||||
expectMember: true,
|
||||
expectGuest: false,
|
||||
description: "Master-id should grant access to ANY instance, regardless of which instance is checking",
|
||||
},
|
||||
{
|
||||
name: "multi-instance: empty claim values",
|
||||
multiInstance: true,
|
||||
instanceID: instanceID1,
|
||||
masterID: masterID,
|
||||
memberClaim: "owncloudMemberOf",
|
||||
guestClaim: "owncloudGuestOf",
|
||||
claims: map[string]interface{}{
|
||||
"owncloudMemberOf": "",
|
||||
},
|
||||
expectMember: false,
|
||||
expectGuest: false,
|
||||
description: "Empty string values should not grant access",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
resolver := accountResolver{
|
||||
multiInstance: tc.multiInstance,
|
||||
instanceID: tc.instanceID,
|
||||
masterID: tc.masterID,
|
||||
memberClaim: tc.memberClaim,
|
||||
guestClaim: tc.guestClaim,
|
||||
}
|
||||
|
||||
isMember, isGuest := resolver.resolveUserType(tc.claims)
|
||||
|
||||
assert.Equal(t, tc.expectMember, isMember, "isMember mismatch: %s", tc.description)
|
||||
assert.Equal(t, tc.expectGuest, isGuest, "isGuest mismatch: %s", tc.description)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,7 @@ type Options struct {
|
||||
// Multi-Instance Options
|
||||
MultiInstanceEnabled bool
|
||||
InstanceID string
|
||||
MasterID string
|
||||
MemberClaim string
|
||||
GuestClaim string
|
||||
GuestRoleName string
|
||||
@@ -273,10 +274,11 @@ func ServiceAccount(id string, secret string) Option {
|
||||
}
|
||||
|
||||
// MultiInstance sets muli-instance options
|
||||
func MultiInstance(enabled bool, iid string, memberClaim, guestClaim string, guestRole string) Option {
|
||||
func MultiInstance(enabled bool, iid string, masterID string, memberClaim, guestClaim string, guestRole string) Option {
|
||||
return func(o *Options) {
|
||||
o.MultiInstanceEnabled = enabled
|
||||
o.InstanceID = iid
|
||||
o.MasterID = masterID
|
||||
o.MemberClaim = memberClaim
|
||||
o.GuestClaim = guestClaim
|
||||
o.GuestRoleName = guestRole
|
||||
|
||||
Reference in new issue
Block a user