diff --git a/changelog/unreleased/add-passwod-policies.md b/changelog/unreleased/add-passwod-policies.md index ece2306e56d..6abaa7a1312 100644 --- a/changelog/unreleased/add-passwod-policies.md +++ b/changelog/unreleased/add-passwod-policies.md @@ -2,5 +2,6 @@ Enhancement: Add the password policies Add the password policies OCIS-3767 +https://github.com/owncloud/ocis/pull/7285 https://github.com/owncloud/ocis/pull/7194 https://github.com/cs3org/reva/pull/4147 diff --git a/go.mod b/go.mod index 20ceae213a6..4bd6c708983 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/coreos/go-oidc v2.2.1+incompatible github.com/coreos/go-oidc/v3 v3.6.0 github.com/cs3org/go-cs3apis v0.0.0-20230516150832-730ac860c71d - github.com/cs3org/reva/v2 v2.16.1-0.20230911153145-a2e2320f3448 + github.com/cs3org/reva/v2 v2.16.1-0.20230915081009-843fe781fbf8 github.com/disintegration/imaging v1.6.2 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e github.com/egirna/icap-client v0.1.1 diff --git a/go.sum b/go.sum index 9af77a03b97..4f2046435fc 100644 --- a/go.sum +++ b/go.sum @@ -1015,6 +1015,8 @@ github.com/crewjam/saml v0.4.13 h1:TYHggH/hwP7eArqiXSJUvtOPNzQDyQ7vwmwEqlFWhMc= github.com/crewjam/saml v0.4.13/go.mod h1:igEejV+fihTIlHXYP8zOec3V5A8y3lws5bQBFsTm4gA= github.com/cs3org/reva/v2 v2.16.1-0.20230911153145-a2e2320f3448 h1:cQt0iMKURVZ6d0DhiNh9eqJ0WTQfPwDn29VArnJpwYg= github.com/cs3org/reva/v2 v2.16.1-0.20230911153145-a2e2320f3448/go.mod h1:RvhuweTFqzezjUFU0SIdTXakrEx9vJlMvQ7znPXSP1g= +github.com/cs3org/reva/v2 v2.16.1-0.20230915081009-843fe781fbf8 h1:7aj/OEZ6NbpB3nSKRJUlp2l0AT0j5tGP0nynLZS8UpU= +github.com/cs3org/reva/v2 v2.16.1-0.20230915081009-843fe781fbf8/go.mod h1:RvhuweTFqzezjUFU0SIdTXakrEx9vJlMvQ7znPXSP1g= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/services/frontend/pkg/config/config.go b/services/frontend/pkg/config/config.go index ff716ec87de..f9346cc41c1 100644 --- a/services/frontend/pkg/config/config.go +++ b/services/frontend/pkg/config/config.go @@ -58,7 +58,7 @@ type Config struct { AutoAcceptShares bool `yaml:"auto_accept_shares" env:"FRONTEND_AUTO_ACCEPT_SHARES" desc:"Defines if shares should be auto accepted by default. Users can change this setting individually in their profile."` ServiceAccount ServiceAccount `yaml:"service_account"` - PasswordPolicies PasswordPolicies `yaml:"password_policies"` + PasswordPolicy PasswordPolicy `yaml:"password_policy"` Supervised bool `yaml:"-"` Context context.Context `yaml:"-"` @@ -174,11 +174,11 @@ type ServiceAccount struct { ServiceAccountSecret string `yaml:"service_account_secret" env:"OCIS_SERVICE_ACCOUNT_SECRET;FRONTEND_SERVICE_ACCOUNT_SECRET" desc:"The service account secret."` } -// PasswordPolicies configures reva password policies -type PasswordPolicies struct { - MinCharacters int `yaml:"min_characters,omitempty" env:"FRONTEND_PASSWORD_POLICIES_MIN_CHARACTERS" desc:"Define the minimum password length. Defaults to 0 if not set."` - MinLowerCaseCharacters int `yaml:"min_lowercase_characters" env:"FRONTEND_PASSWORD_POLICIES_MIN_LOWERCASE_CHARACTERS" desc:"Define the minimum number of uppercase letters. Defaults to 0 if not set."` - MinUpperCaseCharacters int `yaml:"min_uppercase_characters" env:"FRONTEND_PASSWORD_POLICIES_MIN_UPPERCASE_CHARACTERS" desc:"Define the minimum number of lowercase letters. Defaults to 0 if not set."` - MinDigits int `yaml:"min_digits" env:"FRONTEND_PASSWORD_POLICIES_MIN_DIGITS" desc:"Define the minimum number of digits. Defaults to 0 if not set."` - MinSpecialCharacters int `yaml:"min_special_characters" env:"FRONTEND_PASSWORD_POLICIES_MIN_SPECIAL_CHARACTERS" desc:"Define the minimum number of characters from the special characters list to be present. Defaults to 0 if not set."` +// PasswordPolicy configures reva password policy +type PasswordPolicy struct { + MinCharacters int `yaml:"min_characters,omitempty" env:"FRONTEND_PASSWORD_POLICY_MIN_CHARACTERS" desc:"Define the minimum password length. Defaults to 0 if not set."` + MinLowerCaseCharacters int `yaml:"min_lowercase_characters" env:"FRONTEND_PASSWORD_POLICY_MIN_LOWERCASE_CHARACTERS" desc:"Define the minimum number of uppercase letters. Defaults to 0 if not set."` + MinUpperCaseCharacters int `yaml:"min_uppercase_characters" env:"FRONTEND_PASSWORD_POLICY_MIN_UPPERCASE_CHARACTERS" desc:"Define the minimum number of lowercase letters. Defaults to 0 if not set."` + MinDigits int `yaml:"min_digits" env:"FRONTEND_PASSWORD_POLICY_MIN_DIGITS" desc:"Define the minimum number of digits. Defaults to 0 if not set."` + MinSpecialCharacters int `yaml:"min_special_characters" env:"FRONTEND_PASSWORD_POLICY_MIN_SPECIAL_CHARACTERS" desc:"Define the minimum number of characters from the special characters list to be present. Defaults to 0 if not set."` } diff --git a/services/frontend/pkg/revaconfig/config.go b/services/frontend/pkg/revaconfig/config.go index 619ac29c5a4..8792edc414d 100644 --- a/services/frontend/pkg/revaconfig/config.go +++ b/services/frontend/pkg/revaconfig/config.go @@ -274,13 +274,13 @@ func FrontendConfigFromStruct(cfg *config.Config) (map[string]interface{}, error "share_jail": cfg.EnableShareJail, "max_quota": cfg.MaxQuota, }, - "password_policies": map[string]interface{}{ + "password_policy": map[string]interface{}{ "max_characters": 72, - "min_characters": cfg.PasswordPolicies.MinCharacters, - "min_lowercase_characters": cfg.PasswordPolicies.MinLowerCaseCharacters, - "min_uppercase_characters": cfg.PasswordPolicies.MinUpperCaseCharacters, - "min_digits": cfg.PasswordPolicies.MinDigits, - "min_special_characters": cfg.PasswordPolicies.MinSpecialCharacters, + "min_characters": cfg.PasswordPolicy.MinCharacters, + "min_lowercase_characters": cfg.PasswordPolicy.MinLowerCaseCharacters, + "min_uppercase_characters": cfg.PasswordPolicy.MinUpperCaseCharacters, + "min_digits": cfg.PasswordPolicy.MinDigits, + "min_special_characters": cfg.PasswordPolicy.MinSpecialCharacters, }, "notifications": map[string]interface{}{ "endpoints": []string{"list", "get", "delete"}, diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data/capabilities.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data/capabilities.go index a53ac679b91..27f24561666 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data/capabilities.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/data/capabilities.go @@ -50,14 +50,14 @@ type CapabilitiesData struct { // Capabilities groups several capability aspects type Capabilities struct { - Core *CapabilitiesCore `json:"core" xml:"core"` - Checksums *CapabilitiesChecksums `json:"checksums" xml:"checksums"` - Files *CapabilitiesFiles `json:"files" xml:"files" mapstructure:"files"` - Dav *CapabilitiesDav `json:"dav" xml:"dav"` - FilesSharing *CapabilitiesFilesSharing `json:"files_sharing" xml:"files_sharing" mapstructure:"files_sharing"` - Spaces *Spaces `json:"spaces,omitempty" xml:"spaces,omitempty" mapstructure:"spaces"` - Graph *CapabilitiesGraph `json:"graph,omitempty" xml:"graph,omitempty" mapstructure:"graph"` - PasswordPolicies *CapabilitiesPasswordPolicies `json:"password_policies,omitempty" xml:"password_policies,omitempty" mapstructure:"password_policies"` + Core *CapabilitiesCore `json:"core" xml:"core"` + Checksums *CapabilitiesChecksums `json:"checksums" xml:"checksums"` + Files *CapabilitiesFiles `json:"files" xml:"files" mapstructure:"files"` + Dav *CapabilitiesDav `json:"dav" xml:"dav"` + FilesSharing *CapabilitiesFilesSharing `json:"files_sharing" xml:"files_sharing" mapstructure:"files_sharing"` + Spaces *Spaces `json:"spaces,omitempty" xml:"spaces,omitempty" mapstructure:"spaces"` + Graph *CapabilitiesGraph `json:"graph,omitempty" xml:"graph,omitempty" mapstructure:"graph"` + PasswordPolicy *CapabilitiesPasswordPolicy `json:"password_policy,omitempty" xml:"password_policy,omitempty" mapstructure:"password_policy"` Notifications *CapabilitiesNotifications `json:"notifications,omitempty" xml:"notifications,omitempty"` } @@ -86,15 +86,14 @@ type CapabilitiesGraph struct { Users CapabilitiesGraphUsers `json:"users" xml:"users" mapstructure:"users"` } -// CapabilitiesPasswordPolicies hold the password policies capabilities -type CapabilitiesPasswordPolicies struct { - MinCharacters int `json:"min_characters" xml:"min_characters" mapstructure:"min_characters"` - MaxCharacters int `json:"max_characters" xml:"max_characters" mapstructure:"max_characters"` - MinLowerCaseCharacters int `json:"min_lowercase_characters" xml:"min_lowercase_characters" mapstructure:"min_lowercase_characters"` - MinUpperCaseCharacters int `json:"min_uppercase_characters" xml:"min_uppercase_characters" mapstructure:"min_uppercase_characters"` - MinDigits int `json:"min_digits" xml:"min_digits" mapstructure:"min_digits"` - MinSpecialCharacters int `json:"min_special_characters" xml:"min_special_characters" mapstructure:"min_special_characters"` - SpecialCharacters string `json:"special_characters" xml:"special_characters" mapstructure:"special_characters"` +// CapabilitiesPasswordPolicy hold the password policy capabilities +type CapabilitiesPasswordPolicy struct { + MinCharacters int `json:"min_characters" xml:"min_characters" mapstructure:"min_characters"` + MaxCharacters int `json:"max_characters" xml:"max_characters" mapstructure:"max_characters"` + MinLowerCaseCharacters int `json:"min_lowercase_characters" xml:"min_lowercase_characters" mapstructure:"min_lowercase_characters"` + MinUpperCaseCharacters int `json:"min_uppercase_characters" xml:"min_uppercase_characters" mapstructure:"min_uppercase_characters"` + MinDigits int `json:"min_digits" xml:"min_digits" mapstructure:"min_digits"` + MinSpecialCharacters int `json:"min_special_characters" xml:"min_special_characters" mapstructure:"min_special_characters"` } // CapabilitiesGraphUsers holds the graph user capabilities diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go index ff239b649c0..28ed61adc77 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocs/handlers/apps/sharing/shares/shares.go @@ -1591,15 +1591,15 @@ func publicPwdEnforced(c *config.Config) passwordEnforced { } func passwordPolicies(c *config.Config) password.Validator { - if c.Capabilities.Capabilities == nil || c.Capabilities.Capabilities.PasswordPolicies == nil { - return password.NewPasswordPolicies(0, 0, 0, 0, 0) - } - return password.NewPasswordPolicies( - c.Capabilities.Capabilities.PasswordPolicies.MinCharacters, - c.Capabilities.Capabilities.PasswordPolicies.MinLowerCaseCharacters, - c.Capabilities.Capabilities.PasswordPolicies.MinUpperCaseCharacters, - c.Capabilities.Capabilities.PasswordPolicies.MinDigits, - c.Capabilities.Capabilities.PasswordPolicies.MinSpecialCharacters, + if c.Capabilities.Capabilities == nil || c.Capabilities.Capabilities.PasswordPolicy == nil { + return password.NewPasswordPolicy(0, 0, 0, 0, 0) + } + return password.NewPasswordPolicy( + c.Capabilities.Capabilities.PasswordPolicy.MinCharacters, + c.Capabilities.Capabilities.PasswordPolicy.MinLowerCaseCharacters, + c.Capabilities.Capabilities.PasswordPolicy.MinUpperCaseCharacters, + c.Capabilities.Capabilities.PasswordPolicy.MinDigits, + c.Capabilities.Capabilities.PasswordPolicy.MinSpecialCharacters, ) } diff --git a/vendor/github.com/cs3org/reva/v2/pkg/password/password_policies.go b/vendor/github.com/cs3org/reva/v2/pkg/password/password_policies.go index 9a499ba8ce7..4cada0b9d34 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/password/password_policies.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/password/password_policies.go @@ -27,8 +27,8 @@ type Policies struct { specialCharactersRegexp *regexp.Regexp } -// NewPasswordPolicies returns a new NewPasswordPolicies instance -func NewPasswordPolicies(minCharacters, minLowerCaseCharacters, minUpperCaseCharacters, minDigits, minSpecialCharacters int) Validator { +// NewPasswordPolicy returns a new NewPasswordPolicy instance +func NewPasswordPolicy(minCharacters, minLowerCaseCharacters, minUpperCaseCharacters, minDigits, minSpecialCharacters int) Validator { p := &Policies{ minCharacters: minCharacters, minLowerCaseCharacters: minLowerCaseCharacters, diff --git a/vendor/modules.txt b/vendor/modules.txt index bcb4678afcf..f5175d0ac71 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -356,7 +356,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1 github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1 github.com/cs3org/go-cs3apis/cs3/tx/v1beta1 github.com/cs3org/go-cs3apis/cs3/types/v1beta1 -# github.com/cs3org/reva/v2 v2.16.1-0.20230911153145-a2e2320f3448 +# github.com/cs3org/reva/v2 v2.16.1-0.20230915081009-843fe781fbf8 ## explicit; go 1.20 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime