Conversation
01bf72a to
9c59149
Compare
pavelsher
reviewed
Feb 9, 2026
|
|
||
| if result.Error != "" { | ||
| w.WriteHeader(http.StatusBadRequest) | ||
| _, _ = fmt.Fprintf(w, `<!DOCTYPE html><html><head><title>TeamCity CLI</title> |
Member
There was a problem hiding this comment.
Curious, is it normal to embed HTML like this? Maybe some template engine could be used, or do you think it's overkill in this case?
| // AvailableScopes lists permissions to request via PKCE. | ||
| // The server filters these to only grant what it allows. | ||
| var AvailableScopes = []string{ | ||
| // View (read-only) |
Member
There was a problem hiding this comment.
I am a bit worried that we're having a list of permissions embedded here. I think it would be better to have a REST API endpoint on TeamCity side which would provide this list.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds PKCE (RFC 7636) OAuth flow for browser-based authentication. Users can now log in via browser instead of manually copying tokens.
Changes
API (
internal/api/pkce.go)CLI (
internal/cmd/auth.go)tc auth loginnow tries PKCE first, falls back to manual token entry--no-browserflag to skip PKCE--scopesflag for custom permissionsDesign Decisions
Port range 19000-19100: Avoids common dev ports (3000, 8080, etc.) to reduce conflicts., FindAvailableListener()` returns an open listener to avoid TOCTOU race between finding and binding a port.
Scope handling: We request all scopes needed for full CLI functionality. The server filters to only grant what it allows.
Right now, the server requires the special feature flag enabled to have PKCE activated and provides limited permissions:
So this pull request will be merged once the new permission set is agreed.
Example
Test Plan
go test ./...)golangci-lint run)