Repository navigation
[CDTOOL-1144] Let profile accept service-limited tokens - #1856
Conversation
When the "fastly profile create" command is run and provided an existing (static) token, and that token is service-limited, the GET /user/:id operation invoked by the CLI to validate the token failed because that endpoint is now unavailable to service-limited tokens. This was a recent behavior change. Fix that by reusing what we already did for the "profile update" command.
A token is now accepted whenever /current_user or /tokens/self responds successfully. In service-limited tokens the email and account ID are empty, so handle that properly.
rcaril
left a comment
There was a problem hiding this comment.
Looks great, great refactor with two minor / optional nits. Please also add a changelog entry :)
(nit): the both-fail test only checks the error message - consider also verifying the token isn't saved to the config when validation fails (e.g. a Validator asserting GetAuthToken(...) is nil)
Done :) |
|
ChangeLog entry added. Not sure if that should be in "Enhancements" or "Bug fixes" (since it doesn't really fix a bug in the CLI itself). |
rcaril
left a comment
There was a problem hiding this comment.
One suggestion for the changelog, otherwise looks good!
fastly 15.5.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>## [v15.5.0](https://github.com/fastly/cli/releases/tag/v15.5.0) (2026-08-04) ### Bug Fixes: - fix(service-version): support autoclone when staging a service version. ([#1850](fastly/cli#1850)) - fix(logging): the `placement` flag for all loggging commands can now be reset back to `null` by setting it's value to `""` when it was previously set to another value ([#1855](fastly/cli#1855)) - fix(profile): profiles can now be created and updated with service-limited tokens, which cannot access `/current_user` ([#1856](fastly/cli#1856)) ### Enhancements: - feat(compute/init): add support for Python language ([#1811](fastly/cli#1811)) - feat(integrations): Add support for Notification Service Integrations ([#1868](fastly/cli#1868)) ### Dependencies: - build(deps): `golang.org/x/crypto` from 0.53.0 to 0.54.0 ([#1847](fastly/cli#1847)) - build(deps): `github.com/bodgit/sevenzip` from 1.6.4 to 1.6.5 ([#1847](fastly/cli#1847)) - build(deps): `github.com/minio/minlz` from 1.1.1 to 1.2.0 ([#1847](fastly/cli#1847)) - build(deps): `github.com/coreos/go-oidc/v3` from 3.19.0 to 3.20.0 ([#1847](fastly/cli#1847)) - build(deps): `golang.org/x/net` from 0.56.0 to 0.57.0 ([#1847](fastly/cli#1847)) - build(deps): `github.com/fastly/go-fastly` from 16.0.1 to 17.0.0 ([#1855](fastly/cli#1855)) - build(deps): `github.com/mattn/go-isatty` from 0.0.23 to 0.0.24 ([#1857](fastly/cli#1857)) - build(deps): `github.com/nwaples/rardecode/v2` from 2.2.5 to 2.3.0 ([#1857](fastly/cli#1857)) - build(deps): `github.com/mattn/go-runewidth` from 0.0.24 to 0.0.27 ([#1857](fastly/cli#1857)) - build(deps): `github.com/fastly/go-fastly/v17` from 17.0.0 to 17.1.0 ([#1862](https://github.com/fastly/cli/pull/1862))</pre> <p>View the full release notes at <a href="https://github.com/fastly/cli/releases/tag/v15.5.0">https://github.com/fastly/cli/releases/tag/v15.5.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!15863
Change summary
fastly profile create,profile updateandauth loginvalidate a static token by looking up the current user, but that endpoint was recently made unavailable to service-limited tokens (a recent change), so these commands failed even with a valid token.Fix that: tokens are now accepted as long as either
/current_useror/tokens/selfsucceeds.All Submissions:
Changes to Core Features:
User Impact
No behavior change for full-access tokens. Profiles created from a service-limited token won't display an email or account ID, but this is expected.
Are there any considerations that need to be addressed for release?
None. No breaking changes, no config format change.