Merge pull request #11332 from kobergj/AddServerManagedSpacesCapability

Add server managed spaces capability
This commit is contained in:
kobergj authored and GitHub committed 2025-05-21 15:27:52 +02:00
commit 32b7f5ac91
6 files changed
+83 -14

No files matched your search

@@ -0,0 +1,5 @@
Enhancement: Add capability for server managed spaces
Adds the capability for server managed spaces, which will deactivate adding/removing users to/from spaces in the web UI.
https://github.com/owncloud/ocis/pull/11332
+6 -1
View File
@@ -77,7 +77,8 @@ In Infinite Scale, the password policy is always enabled because the max-length
With the password policy, mandatory criteria for the password can be defined via the environment variables listed below.
Generally, a password can contain any UTF-8 characters, however some characters are regarded as special since they are not used in ordinary texts. Which characters should be treated as special is defined by "The OWASP® Foundation" [password-special-characters](https://owasp.org/www-community/password-special-characters) (between double quotes): " !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"
Generally, a password can contain any UTF-8 characters, however some characters are regarded as special since they are not used in ordinary texts. Which characters should be treated as special is defined by "The OWASP® Foundation" [password-special-characters](https://owasp.org/www-community/password-special-characters) (between double quotes):\
" !"#$%&'()*+,-./:;<=>?@\[\]^_`{|}~"
The validation against the banned passwords list can be configured via a text file with words separated by new lines. If a user tries to set a password listed in the banned passwords list, the password can not be used (is invalid) even if the other mandatory criteria are passed. The admin can define the path of the banned passwords list file. If the file doesn't exist in a location, Infinite Scale tries to load a file from the `OCIS_CONFIG_DIR/OCIS_PASSWORD_POLICY_BANNED_PASSWORDS_LIST`. An option will be enabled when the file has been loaded successfully.
@@ -140,3 +141,7 @@ For public accessible writable shares, a password can be enforced. To change the
Note that changing this environment variable only makes sense if\
`OCIS_SHARING_PUBLIC_SHARE_MUST_HAVE_PASSWORD`\
is set to `false`.
## Space Management Through OIDC Claims
When **Space Management Through OIDC Claims** has been enabled in the `proxy` service via the envvar `OCIS_CLAIM_MANAGED_SPACES_ENABLED`, this envvar must also be set for the `frontend` service. This is necessary to block adding or removing users to or from spaces through the web UI.
+2
View File
@@ -61,6 +61,8 @@ type Config struct {
ConfigurableNotifications bool `yaml:"configurable_notifications" env:"FRONTEND_CONFIGURABLE_NOTIFICATIONS" desc:"Allow configuring notifications via web client." introductionVersion:"7.1"`
ServerManagedSpaces bool `yaml:"server_managed_spaces" env:"OCIS_CLAIM_MANAGED_SPACES_ENABLED" desc:"Enables Space management through OIDC claims. See the text description for more details." introductionVersion:"%%NEXT%%"`
Context context.Context `yaml:"-"`
}
+6 -5
View File
@@ -294,11 +294,12 @@ func FrontendConfigFromStruct(cfg *config.Config, logger log.Logger) (map[string
},
},
"spaces": map[string]interface{}{
"version": "1.0.0",
"enabled": true,
"projects": true,
"share_jail": true,
"max_quota": cfg.MaxQuota,
"version": "1.0.0",
"enabled": true,
"projects": true,
"share_jail": true,
"max_quota": cfg.MaxQuota,
"server_managed": cfg.ServerManagedSpaces,
},
"theme": capabilities.Default().Theme,
"search": map[string]interface{}{
+63 -7
View File
@@ -50,12 +50,16 @@ unprotected: false # with false (default), calling the endpoint requires authori
# with true, anyone can call the endpoint without authorisation.
```
## Automatic User and Group Provisioning
## Automatic Assignments
Some assignments can be automated using yaml files, environment variables and/or OIDC claims.
### Automatic User and Group Provisioning
When using an external OpenID Connect IDP, the proxy can be configured to automatically provision
users upon their first login.
### Prequisites
#### Prequisites
A number of prerequisites must be met for automatic user provisioning to work:
@@ -70,7 +74,7 @@ A number of prerequisites must be met for automatic user provisioning to work:
stable per IDP. If a claim like `email` or `preferred_username` is used, you
have to ensure that the user's email address or username never changes.
### Configuration
#### Configuration
To enable automatic user provisioning, the following environment variables must
be set for the proxy service:
@@ -100,7 +104,7 @@ This is the name of the user attribute in ocis that is used to lookup the user b
value of the `PROXY_USER_OIDC_CLAIM`. For auto provisioning setups this usually
needs to be set to `username`.
### How it Works
#### How it Works
When a user logs into ownCloud Infinite Scale for the first time, the proxy
checks if that user already exists. This is done by querying the `users` service for users,
@@ -128,7 +132,7 @@ somewhat costly operation, especially if the user is a member of a large number
groups. If the group memberships of a user are changed in the IDP after the
first login, it can take up to 5 minutes until the changes are reflected in Infinite Scale.
### Claim Updates
#### Claim Updates
OpenID Connect (OIDC) scopes are used by an application during authentication to authorize access to a user's detail, like name, email or picture information. A scope can also contain among other things groups, roles, and permissions data. Each scope returns a set of attributes, which are called claims. The scopes an application requests, depends on which attributes the application needs. Once the user authorizes the requested scopes, the claims are returned in a token.
@@ -152,7 +156,7 @@ For shares or space memberships based on groups, a renamed or deleted group will
To give access for rejected users on a resource, one with rights to share must update the group information.
## Automatic Quota Assignments
### Quota Assignments
It is possible to automatically assign a specific quota to new users depending on their role.
To do this, you need to configure a mapping between roles defined by their ID and the quota in bytes.
@@ -165,7 +169,7 @@ role_quotas:
<role ID2>: <quota2>
```
## Automatic Role Assignments
### Role Assignments
When users login, they do automatically get a role assigned. The automatic role assignment can be
configured in different ways. The `PROXY_ROLE_ASSIGNMENT_DRIVER` environment variable (or the `driver`
@@ -227,6 +231,58 @@ The default `role_claim` (or `PROXY_ROLE_ASSIGNMENT_OIDC_CLAIM`) is `roles`. The
claim_value: ocisGuest
```
### Space Management Through OIDC Claims
**IMPORTANT**
* This is an experimental/preview feature and may change.
* This feature only works using an external IDP. The embedded IDP does not support this.
* If you enable this feature, you can no longer use the Web UI to manually to assign or remove users to Spaces. The Web UI no longer displays related configuration options. Assigning or removing users from a Space can only be done by claims managed through the IDP.
* If enabled and a user is not assigned a claim with defined spaces and roles, the user can only access his personal space.
* When this functionality has been enabled via the envvar `OCIS_CLAIM_MANAGED_SPACES_ENABLED`, this envvar must also be set in the `frontend` service. This is necessary to block adding or removing users to or from spaces through the web UI.
If required, users can be assigned or removed to Spaces via OIDC claims. This makes central user/Space management easy. Managed via environment variables, administrators can define the claim to use, a regex ruleset to extract the Space IDs and roles from a claim for provisioning. It is also possible to manually map OIDC roles to Infinite Scale Space roles. Note that assigning works both ways. Users can be added to Spaces as well as removed. Users must log out and log in again to activate any changes. The relevant environment variables that manage Spaces through OIDC claims follow the `OCIS_CLAIM_MANAGED_SPACES_xxx` pattern. See xref:maintenance/space-ids/space-ids.adoc[Listing Space IDs] for how to obtain the ID of a Space.
**NOTE**\
The following rules apply if enabled:
* If the claim is not found, it is not considered but the incident is logged.
* A faulty regex prevents the proxy service from starting. By this, admins can immediately identify a major configuration issue. The incident is logged.
* Entries in a claim that do not match the regex are not considered, the incident is not logged ^(1)^.
* Unknown Space IDs and unknown roles are not considered, the incident is not logged ^(1)^.
* When multiple entries are created with the same Space ID but different roles, the role with the highest permission counts.
(1) ... These incidents cannot be logged due to the fact that claims can have a variety of layouts and may also contain data unrelated to Infinite Scale.
**Example Setup**\
The following is a simple setup of what space management through OIDC claims can look like. The way how a claim is setup depends on the IDP used. It is important to understand, that the claim setup and the corresponding regex must match.
A claim defined as `ocis-spaces` containing two entries:
```JSON
"ocis-spaces": [
"spaceid=b622d44a-1747-4eda-8905-89f3605d5849:role=member",
"spaceid=129cb9b6-c579-41b5-9316-93c6543484e5:role=spectator",
]
```
The environment variables to extract the data from the above claim look like this:
Environment variable definition:
```plaintext
OCIS_CLAIM_MANAGED_SPACES_ENABLED=true
OCIS_CLAIM_MANAGED_SPACES_CLAIMNAME=ocis-spaces
OCIS_CLAIM_MANAGED_SPACES_REGEXP="spaceid=([a-zA-Z0-9-]+):role=(.*)",
OCIS_CLAIM_MANAGED_SPACES_MAPPING="member:editor,spectator:viewer"
```
Result:\
This would add a user, to which this claim is assigned, to the following Spaces with defined roles:
* `b622d44a-1747-4eda-8905-89f3605d5849` with the role `editor` and to
* `129cb9b6-c579-41b5-9316-93c6543484e5` with the role `viewer`.
Note that `OCIS_CLAIM_MANAGED_SPACES_MAPPING` can be omitted if roles in the claim already match roles defined by Infinite Scale.
## Recommendations for Production Deployments
In a production deployment, you want to have basic authentication (`PROXY_ENABLE_BASIC_AUTH`) disabled which is the default state. You also want to setup a firewall to only allow requests to the proxy service or the reverse proxy if you have one. Requests to the other services should be blocked by the firewall.
+1 -1
View File
@@ -234,7 +234,7 @@ type Events struct {
// ClaimSpaceManagement holds the configuration for claim managed spaces
type ClaimSpaceManagement struct {
Enabled bool `yaml:"enabled" env:"OCIS_CLAIM_MANAGED_SPACES_ENABLED" desc:"Enables Space management through OIDC claims." introductionVersion:"%%NEXT%%"`
Enabled bool `yaml:"enabled" env:"OCIS_CLAIM_MANAGED_SPACES_ENABLED" desc:"Enables Space management through OIDC claims. See the text description for more details." introductionVersion:"%%NEXT%%"`
Claim string `yaml:"claim" env:"OCIS_CLAIM_MANAGED_SPACES_CLAIMNAME" desc:"The name of the claim used to manage Spaces." introductionVersion:"%%NEXT%%"`
Regexp string `yaml:"regexp" env:"OCIS_CLAIM_MANAGED_SPACES_REGEXP" desc:"The regular expression that extracts Space IDs and roles from a claim." introductionVersion:"%%NEXT%%"`
Mapping []string `yaml:"mapping" env:"OCIS_CLAIM_MANAGED_SPACES_MAPPING" desc:"(Optional) Mapping of OIDC roles to ocis Space roles. Example: 'oidcroleA:viewer,oidcroleB:manager'" introductionVersion:"%%NEXT%%"`