[OCISDEV-1407] Homogenize defaults (#12982)

* fix: use "ownCloudUUID" as attribute name everywhere

* fix: use "displayName" as LDAP attribute

* fix: ensure the WopiFolderURLBaseURL always ends with "/"

* fix: restore wrong substitution

* Revert "fix: use "displayName" as LDAP attribute"

This reverts commit 02de7a2db7.

Note that the default values outside of the graph service still remains
This commit is contained in:
Juan Pablo Villafañez authored and GitHub committed 2026-09-28 13:27:05 +02:00
1 parent 018df1c0f5
commit 9e984d5ef3
11 files changed
+42 -40

No files matched your search

@@ -36,7 +36,7 @@ func DefaultConfig() *config.Config {
Driver: "",
Drivers: config.Drivers{
WOPI: config.WOPIDriver{
WopiFolderURLBaseURL: "https://localhost:9200/",
WopiFolderURLBaseURL: "https://localhost:9200",
WopiFolderURLPathTemplate: "/f/{{.ResourceID}}",
},
},
@@ -2,6 +2,8 @@
package revaconfig
import (
"strings"
"github.com/owncloud/ocis/v2/services/app-provider/pkg/config"
)
@@ -38,7 +40,7 @@ func AppProviderConfigFromStruct(cfg *config.Config) map[string]interface{} {
"iop_secret": cfg.Drivers.WOPI.IopSecret,
"jwt_secret": cfg.TokenManager.JWTSecret,
"wopi_url": cfg.Drivers.WOPI.WopiURL,
"wopi_folder_url_base_url": cfg.Drivers.WOPI.WopiFolderURLBaseURL,
"wopi_folder_url_base_url": strings.TrimRight(cfg.Drivers.WOPI.WopiFolderURLBaseURL, "/") + "/", // ensure it ends with "/"
"wopi_folder_url_path_template": cfg.Drivers.WOPI.WopiFolderURLPathTemplate,
},
},
@@ -61,14 +61,14 @@ func DefaultConfig() *config.Config {
PoolSize: 5,
PoolCheckoutTimeout: 30 * time.Second,
UserSchema: config.LDAPUserSchema{
ID: "ownclouduuid",
ID: "ownCloudUUID",
Mail: "mail",
DisplayName: "displayname",
DisplayName: "displayName",
Username: "uid",
Enabled: "ownCloudUserEnabled",
},
GroupSchema: config.LDAPGroupSchema{
ID: "ownclouduuid",
ID: "ownCloudUUID",
Mail: "mail",
DisplayName: "cn",
Groupname: "cn",
@@ -105,7 +105,7 @@ func DefaultConfig() *config.Config {
UserNameAttribute: "uid",
// FIXME: switch this to some more widely available attribute by default
// ideally this needs to be constant for the lifetime of a users
UserIDAttribute: "owncloudUUID",
UserIDAttribute: "ownCloudUUID",
UserTypeAttribute: "ownCloudUserType",
UserEnabledAttribute: "ownCloudUserEnabled",
ExternalIDAttribute: "owncloudExternalID",
@@ -117,7 +117,7 @@ func DefaultConfig() *config.Config {
GroupObjectClass: "groupOfNames",
GroupNameAttribute: "cn",
GroupMemberAttribute: "member",
GroupIDAttribute: "owncloudUUID",
GroupIDAttribute: "ownCloudUUID",
EducationResourcesEnabled: false,
// 1 minute
InstanceMapperCacheTTL: 60,
@@ -105,7 +105,7 @@ func newSchoolAttributeMap() schoolAttributeMap {
return schoolAttributeMap{
displayName: "ou",
schoolNumber: "ocEducationSchoolNumber",
id: "owncloudUUID",
id: "ownCloudUUID",
terminationDate: "ocEducationSchoolTerminationTimestamp",
}
}
@@ -45,21 +45,21 @@ var schoolEntry = ldap.NewEntry("ou=Test School",
map[string][]string{
"ou": {"Test School"},
"ocEducationSchoolNumber": {"0123"},
"owncloudUUID": {"abcd-defg"},
"ownCloudUUID": {"abcd-defg"},
})
var schoolEntry1 = ldap.NewEntry("ou=Test School1",
map[string][]string{
"ou": {"Test School1"},
"ocEducationSchoolNumber": {"0042"},
"owncloudUUID": {"hijk-defg"},
"ownCloudUUID": {"hijk-defg"},
})
var (
filterSchoolSearchByIdExisting = "(&(objectClass=ocEducationSchool)(|(owncloudUUID=abcd-defg)(ocEducationSchoolNumber=abcd-defg)))"
filterSchoolSearchByIdNonexistant = "(&(objectClass=ocEducationSchool)(|(owncloudUUID=xxxx-xxxx)(ocEducationSchoolNumber=xxxx-xxxx)))"
filterSchoolSearchByNumberExisting = "(&(objectClass=ocEducationSchool)(|(owncloudUUID=0123)(ocEducationSchoolNumber=0123)))"
filterSchoolSearchByNumberNonexistant = "(&(objectClass=ocEducationSchool)(|(owncloudUUID=3210)(ocEducationSchoolNumber=3210)))"
filterSchoolSearchByIdExisting = "(&(objectClass=ocEducationSchool)(|(ownCloudUUID=abcd-defg)(ocEducationSchoolNumber=abcd-defg)))"
filterSchoolSearchByIdNonexistant = "(&(objectClass=ocEducationSchool)(|(ownCloudUUID=xxxx-xxxx)(ocEducationSchoolNumber=xxxx-xxxx)))"
filterSchoolSearchByNumberExisting = "(&(objectClass=ocEducationSchool)(|(ownCloudUUID=0123)(ocEducationSchoolNumber=0123)))"
filterSchoolSearchByNumberNonexistant = "(&(objectClass=ocEducationSchool)(|(ownCloudUUID=3210)(ocEducationSchoolNumber=3210)))"
)
func TestCreateEducationSchool(t *testing.T) {
@@ -119,7 +119,7 @@ func TestCreateEducationSchool(t *testing.T) {
Scope: 2,
SizeLimit: 1,
Filter: "(&(objectClass=ocEducationSchool)(ocEducationSchoolNumber=0123))",
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
lm.On("Search", schoolNumberSearchRequest).
@@ -133,7 +133,7 @@ func TestCreateEducationSchool(t *testing.T) {
Scope: 2,
SizeLimit: 1,
Filter: "(&(objectClass=ocEducationSchool)(ocEducationSchoolNumber=0666))",
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
lm.On("Search", existingSchoolNumberSearchRequest).
@@ -147,7 +147,7 @@ func TestCreateEducationSchool(t *testing.T) {
Scope: 2,
SizeLimit: 1,
Filter: "(&(objectClass=ocEducationSchool)(ocEducationSchoolNumber=1111))",
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
lm.On("Search", schoolNumberSearchRequestError).
@@ -161,7 +161,7 @@ func TestCreateEducationSchool(t *testing.T) {
Scope: 0,
SizeLimit: 1,
Filter: "(objectClass=ocEducationSchool)",
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
lm.On("Search", schoolLookupAfterCreate).
@@ -347,7 +347,7 @@ func TestDeleteEducationSchool(t *testing.T) {
Scope: 2,
SizeLimit: 1,
Filter: tt.filter,
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
if tt.expectedItemNotFound {
@@ -416,7 +416,7 @@ func TestGetEducationSchool(t *testing.T) {
Scope: 2,
SizeLimit: 1,
Filter: tt.filter,
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
if tt.expectedItemNotFound {
@@ -450,7 +450,7 @@ func TestGetEducationSchools(t *testing.T) {
Scope: 2,
SizeLimit: 0,
Filter: "(objectClass=ocEducationSchool)",
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
lm.On("Search", sr1).Return(&ldap.SearchResult{Entries: []*ldap.Entry{schoolEntry, schoolEntry1}}, nil)
@@ -467,7 +467,7 @@ var schoolByIDSearch1 *ldap.SearchRequest = &ldap.SearchRequest{
Scope: 2,
SizeLimit: 1,
Filter: filterSchoolSearchByIdExisting,
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
@@ -476,7 +476,7 @@ var schoolByNumberSearch *ldap.SearchRequest = &ldap.SearchRequest{
Scope: 2,
SizeLimit: 1,
Filter: filterSchoolSearchByNumberExisting,
Attributes: []string{"ou", "owncloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Attributes: []string{"ou", "ownCloudUUID", "ocEducationSchoolNumber", "ocEducationSchoolTerminationTimestamp"},
Controls: []ldap.Control(nil),
}
@@ -377,7 +377,7 @@ func TestCreateGroupSynthesizesWhenNotServerUUID(t *testing.T) {
// synthesized entry must carry the id under that attribute for the model builder.
c := lconfig
c.UseServerUUID = false
c.GroupIDAttribute = "owncloudUUID"
c.GroupIDAttribute = "ownCloudUUID"
var written *ldap.AddRequest
l := &mocks.Client{}
@@ -446,7 +446,7 @@ func TestCreateEducationClassSynthesizesWhenNotServerUUID(t *testing.T) {
c := eduConfig
c.UseServerUUID = false
c.GroupIDAttribute = "owncloudUUID"
c.GroupIDAttribute = "ownCloudUUID"
var written *ldap.AddRequest
l := &mocks.Client{}
@@ -603,7 +603,7 @@ func TestUpdateEducationSchoolFoldsNoReadBack(t *testing.T) {
preRead := ldap.NewEntry("ou=Test School", map[string][]string{
"ou": {"Test School"},
"ocEducationSchoolNumber": {"0123"},
"owncloudUUID": {"abcd-defg"},
"ownCloudUUID": {"abcd-defg"},
})
l := &mocks.Client{}
@@ -668,7 +668,7 @@ func TestUpdateEducationClassFoldPreservesClassificationAndExternalID(t *testing
}
// TestCreateGroupSynthesizesWithNonDefaultIDAttribute guards the fix for the
// hardcoded "owncloudUUID" id write: the generated id must be stored under the
// hardcoded "ownCloudUUID" id write: the generated id must be stored under the
// configured GroupIDAttribute, otherwise the synthesized model has no id and
// createGroupModelFromLDAP returns nil (CreateGroup would return (nil, nil)).
func TestCreateGroupSynthesizesWithNonDefaultIDAttribute(t *testing.T) {
@@ -676,7 +676,7 @@ func TestCreateGroupSynthesizesWithNonDefaultIDAttribute(t *testing.T) {
c := lconfig
c.UseServerUUID = false
c.GroupIDAttribute = "entryUUID" // non-default: previously the id was written to owncloudUUID only
c.GroupIDAttribute = "entryUUID" // non-default: previously the id was written to ownCloudUUID only
var written *ldap.AddRequest
l := &mocks.Client{}
@@ -697,7 +697,7 @@ func TestCreateGroupSynthesizesWithNonDefaultIDAttribute(t *testing.T) {
// the id was written under the configured attribute and survives synthesis
assert.NotEmpty(t, newGroup.GetId())
assert.NotEmpty(t, written.Attributes)
// the AddRequest carries the id under the configured attribute, not "owncloudUUID"
// the AddRequest carries the id under the configured attribute, not "ownCloudUUID"
var idFromConfigured, idFromHardcoded string
for _, a := range written.Attributes {
switch a.Type {
@@ -705,14 +705,14 @@ func TestCreateGroupSynthesizesWithNonDefaultIDAttribute(t *testing.T) {
if len(a.Vals) > 0 {
idFromConfigured = a.Vals[0]
}
case "owncloudUUID":
case "ownCloudUUID":
if len(a.Vals) > 0 {
idFromHardcoded = a.Vals[0]
}
}
}
assert.NotEmpty(t, idFromConfigured, "id must be written under the configured GroupIDAttribute")
assert.Empty(t, idFromHardcoded, "id must not be written under a hardcoded owncloudUUID")
assert.Empty(t, idFromHardcoded, "id must not be written under a hardcoded ownCloudUUID")
assert.Equal(t, idFromConfigured, newGroup.GetId())
l.AssertNotCalled(t, "Search", mock.Anything)
}
@@ -68,10 +68,10 @@ var _ = Describe("Users changing their own password", func() {
UserDisplayNameAttribute: "displayName",
UserNameAttribute: "uid",
UserEmailAttribute: "mail",
UserIDAttribute: "ownclouduuid",
UserIDAttribute: "ownCloudUUID",
UserSearchScope: "sub",
GroupNameAttribute: "cn",
GroupIDAttribute: "ownclouduuid",
GroupIDAttribute: "ownCloudUUID",
GroupSearchScope: "sub",
}
loggger := log.NewLogger()
@@ -59,13 +59,13 @@ func DefaultConfig() *config.Config {
PoolSize: 5,
PoolCheckoutTimeout: 30 * time.Second,
UserSchema: config.LDAPUserSchema{
ID: "ownclouduuid",
ID: "ownCloudUUID",
Mail: "mail",
DisplayName: "displayname",
DisplayName: "displayName",
Username: "uid",
},
GroupSchema: config.LDAPGroupSchema{
ID: "ownclouduuid",
ID: "ownCloudUUID",
Mail: "mail",
DisplayName: "cn",
Groupname: "cn",
@@ -210,7 +210,7 @@ func (b *CS3Backend) DestroySession(_ context.Context, sessionRef *string) error
// for the user specified by the userID.
func (b *CS3Backend) UserClaims(_ string, _ map[string]bool) map[string]interface{} {
return nil
// TODO should we return the "ownclouduuid" as a claim? there is also "LibgreGraph.UUID" / lico.ScopeUniqueUserID
// TODO should we return the "ownCloudUUID" as a claim? there is also "LibgreGraph.UUID" / lico.ScopeUniqueUserID
}
// ScopesSupported implements the Backend interface, providing supported scopes
@@ -62,14 +62,14 @@ func DefaultConfig() *config.Config {
PoolSize: 5,
PoolCheckoutTimeout: 30 * time.Second,
UserSchema: config.LDAPUserSchema{
ID: "ownclouduuid",
ID: "ownCloudUUID",
Mail: "mail",
DisplayName: "displayname",
DisplayName: "displayName",
Username: "uid",
Enabled: "ownCloudUserEnabled",
},
GroupSchema: config.LDAPGroupSchema{
ID: "ownclouduuid",
ID: "ownCloudUUID",
Mail: "mail",
DisplayName: "cn",
Groupname: "cn",