Skip to content

PINF-703 add token login support to autheticate with token passing#2157

Open
pgvishnuram wants to merge 4 commits into
mainfrom
feat/fix-apc-token-login-flow
Open

PINF-703 add token login support to autheticate with token passing#2157
pgvishnuram wants to merge 4 commits into
mainfrom
feat/fix-apc-token-login-flow

Conversation

@pgvishnuram

@pgvishnuram pgvishnuram commented May 26, 2026

Copy link
Copy Markdown
Contributor

Description

APC cloud has a option to pass token as a input param to get authenticated avoiding the whole oauth flow , seems the flow doesnt work from the begining and this adds the missing flow to allow CI/CD systems to get authenticated by passing the token directly

export APC_CLOUD_TOKEN=xxxxxxx
./astro login <cluster-url> --token-login $APC_CLOUD_TOKEN

🎟 Issue(s)

https://linear.app/astronomer/issue/PINF-703/broken-cli-token-auth-flow-for-cicd

🧪 Functional Testing

QA should able to pass token string as below format
export APC_CLOUD_TOKEN=xxxxxxx
./astro login --token-login $APC_CLOUD_TOKEN
and see sucessful authtication message

📸 Screenshots

📋 Checklist

  • Rebased from the main (or release if patching) branch (before testing)
  • Ran make test before taking out of draft
  • Ran make lint before taking out of draft
  • Added/updated applicable tests
  • Tested against Astro-API (if necessary).
  • Tested against Houston-API and Astronomer (if necessary).
  • Communicated to/tagged owners of respective clients potentially impacted by these changes.
  • Updated any related documentation

@pgvishnuram pgvishnuram changed the title add token login support to autheticate with token passing PINF-703 add token login support to autheticate with token passing May 26, 2026
@coveralls-official

coveralls-official Bot commented May 26, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 0

Coverage increased (+0.001%) to 45.092%

Details

  • Coverage increased (+0.001%) from the base build.
  • Patch coverage: 4 uncovered changes across 1 file (12 of 16 lines covered, 75.0%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
software/auth/auth.go 14 10 71.43%
Total (2 files) 16 12 75.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 56374
Covered Lines: 25420
Line Coverage: 45.09%
Coverage Strength: 7.81 hits per line

💛 - Coveralls

@pgvishnuram pgvishnuram marked this pull request as ready for review May 26, 2026 18:41
@pgvishnuram pgvishnuram requested review from a team as code owners May 26, 2026 18:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for authenticating to Astro Private Cloud (software/Houston) using a pre-provided token (intended for CI/CD), bypassing the interactive OAuth/basic-auth acquisition flow when a token is supplied.

Changes:

  • Extend software/auth.Login to accept an optional token argument and resolve it via a new resolveAuthToken helper.
  • Wire the existing --token-login CLI flag through to the software login path (not just cloud login).
  • Update affected unit tests for the new function signature.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.

File Description
software/auth/auth.go Accepts a provided token and skips interactive auth flows when present via resolveAuthToken.
software/auth/auth_test.go Updates Login(...) callsites for the new signature (but currently contains several assertion-guard bugs noted in comments).
cmd/auth.go Passes --token-login value into software login calls.
cmd/auth_test.go Updates softwareLogin test stub signature to include the new token parameter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

houstonMock.On("ListWorkspaces", nil).Return([]houston.Workspace{{ID: "ck05r3bor07h40d02y2hw4n4v"}, {ID: "test-workspace-id"}}, nil).Once()
out = &bytes.Buffer{}
if s.NoError(Login("localhost", false, "test", "test", "0.30.0", houstonMock, out)) {
if s.NoError(Login("localhost", false, "test", "test", "", "0.30.0", houstonMock, out)) {

out := &bytes.Buffer{}
if s.NoError(Login("localhost", false, "test", "test", "0.30.0", houstonMock, out)) {
if s.NoError(Login("localhost", false, "test", "test", "", "0.30.0", houstonMock, out)) {

out := &bytes.Buffer{}
if s.NoError(Login("localhost", false, "test", "test", "0.30.0", houstonMock, out)) {
if s.NoError(Login("localhost", false, "test", "test", "", "0.30.0", houstonMock, out)) {

out := &bytes.Buffer{}
if s.NoError(Login("localhost", false, "test", "test", "0.30.0", houstonMock, out)) {
if s.NoError(Login("localhost", false, "test", "test", "", "0.30.0", houstonMock, out)) {

out := &bytes.Buffer{}
if s.NoError(Login("dev.astro.io", false, "test", "test", "0.30.0", houstonMock, out)) {
if s.NoError(Login("dev.astro.io", false, "test", "test", "", "0.30.0", houstonMock, out)) {

out := &bytes.Buffer{}
if s.NoError(Login("test.astro.io", false, "test", "test", "0.30.0", houstonMock, out)) {
if s.NoError(Login("test.astro.io", false, "test", "test", "", "0.30.0", houstonMock, out)) {

out := &bytes.Buffer{}
if s.ErrorIs(Login("localhost", false, "test", "test", "0.30.0", houstonMock, out), errMockRegistry) {
if s.ErrorIs(Login("localhost", false, "test", "test", "", "0.30.0", houstonMock, out), errMockRegistry) {

out := &bytes.Buffer{}
if s.ErrorIs(Login("localhost", false, "test", "test", "0.30.0", houstonMock, out), errMockRegistry) {
if s.ErrorIs(Login("localhost", false, "test", "test", "", "0.30.0", houstonMock, out), errMockRegistry) {
Comment thread software/auth/auth.go
Comment on lines +291 to +305
// resolveAuthToken returns the provided token when non-empty; otherwise it
// runs the interactive basic-auth/oAuth flow against Houston to obtain one.
func resolveAuthToken(token, username, password string, oAuthOnly bool, ctx *config.Context, client houston.ClientInterface) (string, error) {
if token != "" {
return token, nil
}
authConfig, err := houston.Call(client.GetAuthConfig)(ctx)
if err != nil {
return "", err
}
if username == "" && !oAuthOnly && authConfig.LocalEnabled {
username = input.Text(inputUsername)
}
return getAuthToken(username, password, authConfig, ctx, client)
}

@ianbuss ianbuss left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Change seems ok, we should test the case where a token is passed in, which I don't think I see here.

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.

3 participants