|
| 1 | +# MSC4098: User account provisioning using SCIM |
| 2 | + |
| 3 | +This proposal suggests to use the SCIM protocol as a standard way to achieve |
| 4 | +user account [provisioning](https://en.wikipedia.org/wiki/Account_provisioning), fix several use cases uncovered |
| 5 | +by the specification, and in the end help reduce friction for system administrators managing Matrix servers. |
| 6 | + |
| 7 | +## Proposal |
| 8 | + |
| 9 | +System for Cross-domain Identity Management, or SCIM, is a protocol that normalizes users and groups provisioning. |
| 10 | +In short, *provisioning* is a way for different services to exchange information about users and groups. |
| 11 | +The [SCIM IETF working group](https://datatracker.ietf.org/wg/scim/about/) wrote |
| 12 | +[RFC7642](https://www.rfc-editor.org/rfc/rfc7642), [RFC7643](https://www.rfc-editor.org/rfc/rfc7643) and |
| 13 | +[RFC7644](https://www.rfc-editor.org/rfc/rfc7644) which details the protocol. |
| 14 | + |
| 15 | +A SCIM implementation basically consists in a set of HTTP endpoints used to read or edit objects such as *Users* and |
| 16 | +*Groups*, plus a few metadata endpoints. The different standard HTTP methods (GET, POST, PUT, PATCH, DELETE) are used |
| 17 | +depending on the intended actions on the objects. |
| 18 | + |
| 19 | +SCIM is to *provisioning* what OpenID Connect (OIDC) is to *authentication*, and is generally implemented in Identity |
| 20 | +and Authorization Management (IAM) software. |
| 21 | + |
| 22 | +### Use cases |
| 23 | + |
| 24 | +Using SCIM as a provisioning protocol would help with some use cases. |
| 25 | +A lot of scenarios where SCIM is pertinent are available on [RFC7642](https://www.rfc-editor.org/rfc/rfc7642). |
| 26 | + |
| 27 | +Organizations often rely on IAM software to centralize information about their users. This |
| 28 | +allows for unique authentication with protocols like OIDC. A common practice is to dynamically |
| 29 | +create users on services when they first log-in with OIDC, based on the data provided by the [authentication |
| 30 | +tokens](https://tools.ietf.org/html/rfc9068) or a dedicated [endpoint at the |
| 31 | +IAM](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo). However this does not fit all use cases. |
| 32 | +For instance, a new employee joins a company. The team with which the employee will work wants to prepare |
| 33 | +their collaboration tools, so everything is set up for the employee's first day of work. The team |
| 34 | +reaches the company system administrators who create a user profile in the IAM software. |
| 35 | +- Without a provisioning protocol, the new employee's profile will only be created on the collaboration tools at the |
| 36 | +employee first log-in, preventing the team to share files, send welcome emails etc. or in case of a Matrix server, |
| 37 | +invite them in a discussion or a space. This is unless system administrators manually perform the user creation on |
| 38 | +all the services. |
| 39 | +- With a provisioning protocol, |
| 40 | +the IAM can reach the different services to push the new employee profile, so their team can share |
| 41 | +anything they need before the new employee has ever logged in. |
| 42 | + |
| 43 | +Similarly, when an employee leaves the company, the system administrators will remove or de-activate |
| 44 | +the user profile from the IAM, that will immediately prevent the leaving employee to log-in at any service. |
| 45 | +However the employee may still have data left on all those services (such as files, emails, personal |
| 46 | +profile information etc.), that sooner or later will be needed |
| 47 | +to remove, either because of disk usage or privacy reasons. |
| 48 | +- Without a provisioning protocol, the system administrators |
| 49 | +needs manually perform the account removal operation on all the services the employee have been using. This can |
| 50 | +be cumbersome depending on the quantity of users and services. |
| 51 | +- With a provisioning protocol, the modifications on the user profile |
| 52 | +are automacally repercuted on all the services, so the system administrators only need to do the once on |
| 53 | +the IAM. |
| 54 | + |
| 55 | +As an illustration, synapse implements its own provisioning protocol with its |
| 56 | +[Users admin API](https://matrix-org.github.io/synapse/latest/admin_api/user_admin_api.html). |
| 57 | +While this is useful from the point of view of the synapse ecosystem, this has limitations from an IAM - or system |
| 58 | +administrator - perspective. |
| 59 | +Indeed, in cases an IAM software is connected to a multiple services, |
| 60 | +it implies that it implements the custom provisioning protocol for each one of those services, multiplicating the |
| 61 | +maintenance burden and the room for bugs. |
| 62 | + |
| 63 | +To paraphrase |
| 64 | +[MSC1779](https://github.com/matrix-org/matrix-spec-proposals/blob/main/proposals/1779-open-governance.md), |
| 65 | +*"interoperability is better than fragmentation*". This is why this proposal advises to use SCIM as |
| 66 | +a standard provisioning protocol for Matrix. |
| 67 | + |
| 68 | +From a larger perspective, the SCIM implementation would help Matrix integration in software suites, by reducing the |
| 69 | +friction for system administrators. |
| 70 | + |
| 71 | +### Real world implementations |
| 72 | + |
| 73 | +While being almost 10 years old, SCIM suffers from not being very popular yet (at least, not as much as protocols like |
| 74 | +OIDC). |
| 75 | +It is facing a chicken and egg issue, where services are waiting for IAMs to implement SCIM before they find useful to |
| 76 | +implement it in return, and vice-versa. However, SCIM seems to gain in popularity lately. |
| 77 | +Here is a quick state of the art of the current SCIM implementations in famous IAMs. |
| 78 | + |
| 79 | +- [Auth0](https://auth0.com/docs/authenticate/protocols/scim) ✅ |
| 80 | +- Authelia ❌ |
| 81 | +- [Authentik](https://goauthentik.io/docs/providers/scim/) ✅ |
| 82 | +- [Authentic2](https://dev.entrouvert.org/issues/70751) ❌ |
| 83 | +- [Canaille](https://canaille.readthedocs.io/en/latest/specifications.html#scim) ❌ |
| 84 | +- [CAS](https://apereo.github.io/cas/7.0.x/integration/SCIM-Provisioning.html) ✅ |
| 85 | +- Connect2id ❌ |
| 86 | +- [Gluu](https://gluu.org/docs/gluu-server/4.0/api-guide/scim-api/) ✅ |
| 87 | +- [Hydra](https://github.com/ory/hydra/issues/235) ❌ |
| 88 | +- Keycloak, via plugins [scim-for-keycloak](https://scim-for-keycloak.de/) |
| 89 | + or [keycloak-scim](https://lab.libreho.st/libre.sh/scim/keycloak-scim) ✅ |
| 90 | +- LemonLDAP ❌ |
| 91 | +- [Okta](https://developer.okta.com/docs/reference/scim/scim-20/) ✅ |
| 92 | + |
| 93 | +### Detailed implementation proposal |
| 94 | + |
| 95 | +#### Endpoints |
| 96 | + |
| 97 | +[RFC7644](https://www.rfc-editor.org/rfc/rfc7644) defines different endpoints. |
| 98 | +This proposal is to implement the following endpoints: |
| 99 | + |
| 100 | +- [User](https://www.rfc-editor.org/rfc/rfc7643#section-4.1) endpoint, which are used to manage users. |
| 101 | + - creation with [POST](https://www.rfc-editor.org/rfc/rfc7644#section-3.3) |
| 102 | + - retrieval with [GET](https://www.rfc-editor.org/rfc/rfc7644#section-3.4) |
| 103 | + - replacement with [PUT](https://www.rfc-editor.org/rfc/rfc7644#section-3.5.1) |
| 104 | + - deletion with [DELETE](https://www.rfc-editor.org/rfc/rfc7644#section-3.6) |
| 105 | +- [Service Provider Configuration endpoints](https://www.rfc-editor.org/rfc/rfc7644#section-4), which display metadata |
| 106 | + about the SCIM implementation. |
| 107 | + - `/ServiceProviderConfig` |
| 108 | + - `/Schemas` |
| 109 | + - `/ResourceTypes` |
| 110 | + |
| 111 | +Other endpoints such as [Bulk operations](https://www.rfc-editor.org/rfc/rfc7644#section-3.7) |
| 112 | +or [Search](https://www.rfc-editor.org/rfc/rfc7644#section-3.4.3), or methods like |
| 113 | +[PATCH](https://www.rfc-editor.org/rfc/rfc7644#section-3.5.2), are considered optional. |
| 114 | + |
| 115 | +#### User attributes matching |
| 116 | + |
| 117 | +The SCIM User attributes are detailed on [RFC7643](https://www.rfc-editor.org/rfc/rfc7643#section-4.1). |
| 118 | +Some attributes easily fits between the SCIM and the Matrix specifications: |
| 119 | + |
| 120 | +| SCIM | Matrix | |
| 121 | +| ------------ | ------------- | |
| 122 | +| userName | username | |
| 123 | +| password | [password](https://spec.matrix.org/v1.9/client-server-api/#post_matrixclientv3accountpassword) | |
| 124 | +| emails | 3pid email | |
| 125 | +| phoneNumbers | 3pid msisdn | |
| 126 | +| displayName | display name | |
| 127 | +| photos | avatar_url | |
| 128 | +| active | [deactivate](https://spec.matrix.org/v1.9/client-server-api/#post_matrixclientv3accountdeactivate) | |
| 129 | + |
| 130 | +*Note that the Matrix attributes edition availability should reflect |
| 131 | +[Change password](https://spec.matrix.org/v1.9/client-server-api/#mchange_password-capability), |
| 132 | +[Set displayname](https://spec.matrix.org/v1.9/client-server-api/#mset_displayname-capability) |
| 133 | +and [Set avatar](https://spec.matrix.org/v1.9/client-server-api/#mset_avatar_url-capability) capabilities.* |
| 134 | + |
| 135 | +The [Matrix specification on profiles](https://spec.matrix.org/latest/#profiles) indicates that |
| 136 | +*Users may publish arbitrary key/value data associated with their account*, and on its own side, SCIM is very feature |
| 137 | +complete and leaves room for additional attributes with its [extension |
| 138 | +model](https://www.rfc-editor.org/rfc/rfc7643#section-3.3). |
| 139 | + |
| 140 | +In the end, the exact attribute matching implementation should be left to the Matrix server, in a similar fashion |
| 141 | +than synapse achieves [mapping from attributes from SSO |
| 142 | +providers](https://matrix-org.github.io/synapse/latest/sso_mapping_providers.html). |
| 143 | + |
| 144 | +#### Authentication |
| 145 | + |
| 146 | +The SCIM protocol [supports all the common HTTP authentication |
| 147 | +methods](https://www.rfc-editor.org/rfc/rfc7644#section-2), so the provisioning endpoints should use the same user |
| 148 | +[authentication methods](https://spec.matrix.org/v1.9/client-server-api/#client-authentication) than the rest of the |
| 149 | +Matrix server. |
| 150 | + |
| 151 | +As indicated in the [Server Administration](https://spec.matrix.org/v1.9/client-server-api/#server-administration) |
| 152 | +paragraph, *Server-local administrator privileges are not specified in this document.* It could rely on a |
| 153 | +local *administrator flags*, or a SCIM [entitlements](https://www.rfc-editor.org/rfc/rfc7643#section-4.1) attribute |
| 154 | +values for instance. |
| 155 | + |
| 156 | +## Potential issues |
| 157 | + |
| 158 | +The scope of the SCIM User model and the Matrix User model might not perfectly match, however the SCIM [extension |
| 159 | +model](https://www.rfc-editor.org/rfc/rfc7643#section-3.3) can be used in the future to standardize more attributes of |
| 160 | +the User model in the Matrix specification. |
| 161 | + |
| 162 | +## Alternatives |
| 163 | + |
| 164 | +SCIM appears to be the only existing relevant user account provisioning protocol. |
| 165 | + |
| 166 | +An alternative could be for Matrix to define its own provisioning protocol. This would bring standardization between |
| 167 | +Matrix servers, but would not be as useful for IAMs attached to a large number of services, since they would still need |
| 168 | +to implement the Matrix provisioning protocol. |
| 169 | + |
| 170 | +## Security considerations |
| 171 | + |
| 172 | +SCIM security considerations are related in [a dedicated paragraph](https://www.rfc-editor.org/rfc/rfc7644#section-7) in |
| 173 | +RFC7644. |
| 174 | + |
| 175 | +## Unstable prefix |
| 176 | + |
| 177 | +The unstable prefix to use for the root SCIM endpoint is `/_matrix/client/unstable/coop.yaal/scim/`. |
| 178 | + |
| 179 | +## Dependencies |
| 180 | + |
| 181 | +This MSC has no dependency. |
| 182 | + |
| 183 | +It would solve [matrix-spec#23](https://github.com/matrix-org/matrix-spec/issues/23) and |
| 184 | +[matrix-spec#228](https://github.com/matrix-org/matrix-spec/issues/228). |
| 185 | + |
| 186 | +This MSC would play along well with |
| 187 | +[MSC3861](https://github.com/matrix-org/matrix-spec-proposals/blob/hughns/delegated-oidc-architecture/proposals/3861-delegated-oidc-architecture.md) |
| 188 | +by delegating another aspect of user management to a standard protocol. It might call for a SCIM implementation in |
| 189 | +[matrix-authentication-service](https://github.com/matrix-org/matrix-authentication-service). |
| 190 | + |
| 191 | +## Notes |
| 192 | + |
| 193 | +[Indiehosters](https://indiehosters.net/) has [obtained a |
| 194 | +grant](https://forum.indiehosters.net/t/candidature-ngi-nlnet-privacy-trust-enhancing-technologies/4715) from the |
| 195 | +[NLNet foundation](https://nlnet.nl/) for the realisation of several things around SCIM. My employer |
| 196 | +[Yaal Coop](https://yaal.coop/) has been hired to work on the possible Matrix specification and synapse implementation. |
0 commit comments