Skip to content

Perform node.IsTagged() check in /authorize#160

Merged
mikeodr merged 1 commit intotailscale:mainfrom
itsvs:move-whois-lookup
Mar 26, 2026
Merged

Perform node.IsTagged() check in /authorize#160
mikeodr merged 1 commit intotailscale:mainfrom
itsvs:move-whois-lookup

Conversation

@itsvs
Copy link
Copy Markdown
Contributor

@itsvs itsvs commented Mar 22, 2026

Currently the /authorize handler happily issues an auth code for tagged nodes. Since tagged nodes represent no user identity, token exchange for these codes later (correctly) fails.

This is fundamentally an authorization validation step. A tagged node is essentially not able to identify itself, so it is poor OAuth practice to issue an auth code for it. The service already looks up node information while handling /authorize, so it should detect tagged nodes up front and prevent them from being used.

This PR adds a check to /authorize to redirect with error=access_denied if a tagged node is detected. This way, the OAuth client need not go through token exchange when the node is not authorized.

This PR also makes a few improvements to the testing flow. Specifically, it:

  1. makes it possible to mock .WhoIs responses from the local client, by representing the client as an interface rather than the *local.Client type
  2. adds a test case to token_test.go to check tagged nodes during the /token endpoint
  3. adds test cases to authorize_test.go to check tagged nodes, stop on .WhoIs errors, and check the happy path

Happy to discuss further or iterate over this PR if desired! Beyond the test updates here, I also ran this locally and performed a basic check that it works as expected (untagged nodes are unaffected, tagged nodes return the right redirect on /authorize).

Copy link
Copy Markdown
Collaborator

@mikeodr mikeodr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, overall this matches the RFC as machines would use a separate workload flow.

Just a few issues to resolve about the interface use, otherwise looks great.

Thanks!

@mikeodr
Copy link
Copy Markdown
Collaborator

mikeodr commented Mar 26, 2026

Looks good, can you squash this down to ensure all the commits have the DCO signoff?

Thanks!

Signed-off-by: Vanshaj Singhania <svanshaj2001@gmail.com>
@itsvs itsvs force-pushed the move-whois-lookup branch from 22f1b76 to 9109638 Compare March 26, 2026 17:47
@itsvs
Copy link
Copy Markdown
Contributor Author

itsvs commented Mar 26, 2026

squashed and added signoff!

@itsvs itsvs requested a review from mikeodr March 26, 2026 17:48
Copy link
Copy Markdown
Collaborator

@mikeodr mikeodr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR.

@mikeodr mikeodr merged commit c2c1d8d into tailscale:main Mar 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants