Multi-cluster user database » History » Revision 15
« Previous |
Revision 15/18
(diff)
| Next »
Tom Clegg, 08/07/2019 05:41 PM
Multi-cluster user database¶
It is sometimes desirable to share a single user database across multiple Arvados clusters. For example:- Clusters aaaaa, bbbbb, ccccc, ddddd, eeeee are on different continents, but they use the same upstream authentication providers (ldap/google) and a given user either has access to all clusters, or none.
- A down/unreachable cluster should not prevent any user from using other clusters in the group -- even if the down/unreachable cluster is the one where the user's account was initially created.
This requires some changes to login and token validation. (Currently, any given user account has a single "home cluster" that can issue or validate tokens for it.)
Logging in¶
Each user should be able to log in to their account using any cluster, regardless of where/whether they have logged in previously.
To achieve this (without depending real-time communication between clusters) the participating clusters need to agree on a mapping of upstream authentication results to Arvados user UUIDs. For example, if the upstream authentication result is"foo@bar.example"
("an upstream auth provider assures us this user is foo@bar.example"):
- Generate a UUID "eeeee-tpzed-${sha1part(upstream)}" (where eeeee is a common prefix used by all participating clusters and sha1part() is the first 15 chars of base-36-encoded sha1())
- If it doesn't already exist, add a row to the users table with this UUID
- If another row exists in the users table with the same upstream (or same identity_url) but a different UUID, [offer to] merge the old account's data/objects/permissions into the new account (it isn't possible to log into the old account any more, but we know it belongs to the same person as the new account).
This also makes upstream authentication providers equivalent: as long as they report the same IDs (email addresses), users/sites can switch upstream providers on the fly without having to merge or migrate accounts.
Notes- the "upstream" field is similar to identity_url as initially conceived. Since #4601, identity_url has been an opaque SSO-generated UUID, with no info about upstream -- so we will rely on it to detect "same upstream as old account that needs to be migrated" but we can't use it to generate the same user UUID as other clusters, hence the need for a new "upstream" field
- "remote" accounts (the kind that we already have in the users table with foreign UUIDs) have a null identity_url field, and will also have a null upstream field
uuid | upstream | identity_url | significance |
eeeee-tpzed-012340123401234 | foo@bar.example | login-tpzed-aaaaaaaaaaaaaaa | Newly created user account |
aaaaa-tpzed-aaaaaaaaaaaaaaa | NULL | login-tpzed-aaaaaaaaaaaaaaa | Old user account (can't log in to this any more - contents should be migrated to eeeee-*) |
ooooo-tpzed-ooooooooooooooo | NULL | NULL | Remote user from cluster ooooo (not part of our multi-cluster group) |
Configuration¶
Each cluster needs to know- the uuid prefix to use when creating a new account, e.g., "eeeee" (this will be the initial "master" cluster -- see below)
- which other clusters are authorized to issue tokens for "eeeee-tpzed-*" users
Clusters:
eeeee:
Login:
AssignUUIDPrefix: eeeee
RemoteClusters:
bbbbb:
Proxy: true
AuthenticateLocalUsers: true # all clusters should accept tokens issued by bbbbb for users with uuid eeeee-*
Example: aaaaa needs to validate a token issued by bbbbb.
- Do a callback to bbbbb (or check JWT signature) to confirm bbbbb really issued this token and get the relevant user UUID (result: yes, user uuid is eeeee-tpzed-012340123401234).
- Fetch eeeee's config.
- If RemoteClusters.bbbbb.AuthenticateLocalUsers is true, accept the token. Otherwise, reject the token.
- If the token is accepted, update the local cache of the user record from eeeee.
Validating tokens¶
(...even when the issuing cluster is unreachable)
Each cluster should be able to validate a token that was issued by a different, currently unreachable, cluster. This contrasts with the current setup, where aaaaa validates tokens issued by bbbbb by doing a callback to bbbbb.
This seems easy enough: instead of random strings, tokens can be [like] JSON Web Tokens, signed by a private key whose public part is known by all clusters. (This would also be more efficient than callbacks, benefiting the mutually-untrusted cluster scenario too.)
"Master" cluster¶
The authoritative place to store/load per-user information (preferences, and the "this email is just an alternate way to log in to a different account" marker) is:- ...for callers outside the "eeeee" group of clusters: the "eeeee" cluster
- ...for callers inside the "eeeee" group of clusters, for now: a manually designated "master" cluster (probably "eeeee")
- ...for callers inside the "eeeee" group of clusters, in future: a group-wide distributed database whose default/initial "master" is eeeee
Until a distributed database is implemented, each non-master cluster can update its cached user record (if stale at login or token validation time) from the master cluster, and proxy update requests to the master.
Migration¶
Admin migration tool should, for each record in the user database:- Check whether the UUID has been generated from the email address as described above (if so, do nothing)
- Check whether another user record exists with the generated UUID (if not, create one)
- [Prompt and] change existing references to the old UUID to the new generated UUID (if the existing email field is trusted, this should include tokens, SSH keys, etc.)
Updated by Tom Clegg about 5 years ago · 15 revisions