We will want to be able to open the API for users external to the toolforge infrastructure.
This task is to investigate current practices and options for us to do authentication in toolforge.
Currently we are doing ssl authentication using the client certificates that were generated for the tools (living in the NFS shared folders).
What we want
This authentication should grant access to anything you can do through the API at least, with access to k8s as an optional plus.
Restrictions
- We want to avoid having to process on toolforge infra any LDAP credentials directly or Openstack app credentials, only short-lived tokens generated for the authentication. Once we have validated the user against some identity provider, we can generate our own session for the rest of the interaction.
- Should be as simple as possible for users
Authenticating on toolforge API
This just needs a way to map User(being that a human user or a tool user) <-> Tool (as in tool group).
We don't need any roles/scopes or similar fine grained access control (RBAC/etc.).
Interactive authentication (ex. browser authentication)
For the future UI, we want to be able to use a browser to authenticate in an easy way (ex. avoid certificates)
Non-interactive authentication: (ex. cli authentication, gitlab/github workflows...)
We also want to enable other clients, like command line interface, authenticating in an easy way, this might require creating some sort of "api tokens" or similar to avoid having to authenticate on every cli execution (and enable automations like github/gitlab actions and such).
Toolforge tokens
This means that we need to store some tokens somewhere (be that our own miniservice, or idp/keystone/anything that has the capabilities)
Easy rotation
These "api tokens" will need some way for the users to easily rotate themselves in case of expiry, leakage or forgetting them.
Authenticating against radosgw for bucket access
We also want users to be able to access the buckets that
Authentication sources
Some options to investigate are:
idp.wmcloud.org
This uses CAS(the software) as the sso server.
Supports:
- oauth
- cas (the protocol)
- openid
- saml
- rest
The data that we get back from the server include the ldap groups in the memberOf key:
memberOf [cn=tools.sqlchecker,ou=servicegroups,dc=wikimedia,dc=org, cn=tools.wm-lol,ou=servicegroups,dc=wikimedia,dc=org, cn=tools.jobs,ou=servicegroups,dc=wikimedia,dc=org, cn=project-account-creation-assistance,ou=groups,dc=wikimedia,dc=org, cn=project-cloudvirt-canary,ou=groups,dc=wikimedia,dc=org, cn=project-dumps,ou=groups,dc=wikimedia,dc=org, cn=project-wmflabsdotorg,ou=groups,dc=wikimedia,dc=org, cn=tools.toolschecker,ou=servicegroups,dc=wikimedia,dc=org, cn=tools.cloud-ceph-performance-tests,ou=servicegroups, ...
It has no support for token-based auth
other projects using it
- Catalyst - https://phabricator.wikimedia.org/T350725
- grafana.wmcloud.org
- https://prometheus-alerts.wmcloud.org/
wikitech
This has no advantage over using idp/keystone
keystone
Has it's own authentication protocol (see docs https://docs.openstack.org/keystone/pike/user/index.html)
It can be federated (use idp underneath) - https://docs.openstack.org/keystone/latest/admin/federation/introduction.html
keycloak
Similar to CAS, can be federated with both CAS, keystone and LDAP and be deployed locally.
The advantage might be to be able to add toolforge-specific bits in it.
Implementations
For any of the solutions we would want the users to not have to deal with more than one system (ex. not have to go to keystone themselves, get a token, then go to toolforge), and instead make toolforge deal with anything needed unless it's implementing standard auth flows for web UI (ex. OIDC, etc.) where you get redirected to the id provider login page.
All keystone
A starting diagram is here with all the flows (including the current ssl certificate), still unfinished:
https://drive.google.com/file/d/1f1F2XT9ppFaeYcuNVBd8s9DjYwXrrGix/view?usp=sharing
Blockers
We can't use keystone for interactive logins directly as that would require providing either you user-pass or application credential to the toolforge server to forward to keystone.
idp for web UI, new service for app tokens
(work in progress)
Interactive client identification flows
Besides using one of the app tokens, there's the possibility to use oauth2 to authenticate the cli against idp, see:
https://medium.com/@balaajanthan/openid-flow-from-a-cli-ac45de876ead
Essentially you can use a localhost based callback url, or an application private uri (for desktop apps), the localhost url might be the easiest to support.
See specification for 'native apps' here https://datatracker.ietf.org/doc/html/rfc8252#section-7.1
It seems that using localhost for the auth flow should work for linux, mac and windows on default installations (nice).
To open urls on different oses automatically (if we want to), we can try using xdg-open on linux, open on mac, and start on windows.