Need/problem
We have recently added two new ways to authenticate:
- OIDC tokens, a more secure and convenient way to authenticate on supported CI providers
- Account tokens, offering a flexible way to communicate with the API – either on the CI or in local environments. Heavily inspired by GitHub tokens with fine-grained permissions.
These two types of tokens are on top of what we’ve already had:
- access/refresh JWT pair tailored for local flows
- project tokens meant to be on the CI
On the CI, it’s confusing which token to pick – an OIDC token, an account token, or a project token? Especially, account tokens and project tokens now serve a very similar purpose.
That’s why I would like to propose to deprecate project tokens in favor of OIDC and account tokens.
Detailed design
Teams should use OIDC tokens on the CI – if possible – since they are more secure.
If not, then teams should use account tokens instead of project tokens. However, we should make sure that the account tokens don’t need to be regenerated when new features are added. Right now, the project token has access to the following scopes:
project:previews:writeproject:cache:writeproject:bundles:writeproject:tests:writeproject:builds:write
And we expand what the project token can do when we add new features.
But account tokens need to have their scopes defined explicitly when they are created. To ensure the migration to account tokens doesn’t negatively impact the UX, I’m suggesting to add a new scope group project:ci. This scope group would be expanded into the above scopes – and we could automatically include new scopes for this group when new features are added.
The command to create a CI token would then be:
tuist account tokens create my-account --name ci-token --scopes project:ci
tuist account tokens create my-account --name ci-token --scopes project:ci --projects my-project # if you want to limit the token to specific projects
Compared to the current command:
tuist project tokens create my-account/my-project
Drawbacks
Now, the new command is definitely a bit more complex. But it does allow teams to create tokens with access to all projects instead of being forced to create a token per project. Since this would be well-documented in our docs, I don’t think the slightly longer command is a reason not to adopt this.
Alternatives
We can definitely keep the account tokens and project tokens co-existing. But I believe this causes confusion and having to support both on the server makes us more susceptible to bugs.
We can also change tuist project tokens create command to create an account token under the hood tailored for CI. This is definitely possible, but again, I believe this would cause confusion.
Adoption strategy
We should deprecate the tuist project tokens commands and refer to the documentation for how to create a CI account token instead. After 6 months, we should remove the project token support from the server.