-
Notifications
You must be signed in to change notification settings - Fork 56
fix(auth): honor APIFY_TOKEN env var over stored login token #1293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
l2ysho
wants to merge
6
commits into
master
Choose a base branch
from
claude/apify-token-permissions-bug-15c25d
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b7c1453
fix(auth): honor APIFY_TOKEN env var over stored login token
l2ysho b258890
Merge branch 'master' into claude/apify-token-permissions-bug-15c25d
l2ysho 9e65803
fix(auth): don't persist one-time token overrides over the stored login
l2ysho 948b388
Merge remote-tracking branch 'origin/claude/apify-token-permissions-b…
l2ysho 874f75c
Merge branch 'master' into claude/apify-token-permissions-bug-15c25d
l2ysho 5b764bf
fix(auth): resolve user identity from the APIFY_TOKEN account
l2ysho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
APIFY_TOKENnow silently overwrites the storedapify logincredentialsThe read-side precedence added here is correct, but this line has a downstream side effect that I think makes it a blocker.
Because
resolveToken()now returnsprocess.env.APIFY_TOKEN,getLoggedClient(), reached by ~all authenticated commands viagetLoggedClientOrThrow(), then persists it:setToken(…, { skipIfUnchanged: true })writes whenever the value differs from what's stored. Pre-PR,resolvedTokenwas always the stored token, so this was a no-op. Now:So a transient env var permanently mutates the durable login: the
apify loginaccount is silently replaced, and the change persists afterunset. Two consequences:APIFY_TOKENdestroys the stored login. This also contradicts the intent of the newrun.tsguard's own comment ("must win over the stored login", i.e. without replacing it).skipIfUnchangedwas added to avoid — every command run with a differingAPIFY_TOKENrewrites the keyring.Suggested fix: in
getLoggedClient, only callsetToken/setProxyPasswordwhen the token came from an explicitapify login, not when it originated fromAPIFY_TOKENor--tokenflag of command other thanapify login(the--tokenon other commands should be one-time overwrite as well), mirroring the guard already added inrun.ts:332.(Heads-up: if you make this change,
apify auth tokenwill then print the stored token while other commands use the env token — it readsgetLocalUserInfo().tokendirectly and only looks correct today because of this overwrite. It'd need to become env-aware too.)🤖 Generated with Claude Code
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you, this is a good catch and I am wondering how I missed this when I self reviewed 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also I am inspecting getLoggedClient() and there are few things I really do not like (for example it is doing mutations but name suggests it is only get), I will create a follow up issue if I find it is worth of it.