Skip to content

credential chain - #464

Open
patelspratik wants to merge 1 commit into
mainfrom
pr2-credential-chain
Open

credential chain#464
patelspratik wants to merge 1 commit into
mainfrom
pr2-credential-chain

Conversation

@patelspratik

@patelspratik patelspratik commented Aug 27, 2026

Copy link
Copy Markdown
Contributor
  • add global flag for --api-key (still hidden)
  • add BREV_API_KEY env var support
  • also fixed declining login causing stack trace

@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.87805% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.09%. Comparing base (17ccd79) to head (6944cc9).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
pkg/store/organization.go 33.33% 23 Missing and 5 partials ⚠️
pkg/cmd/cmd.go 18.75% 13 Missing ⚠️
pkg/cmd/cmderrors/cmderrors.go 0.00% 9 Missing ⚠️
pkg/cmd/register/register.go 78.57% 5 Missing and 4 partials ⚠️
pkg/analytics/posthog.go 65.00% 6 Missing and 1 partial ⚠️
pkg/cmd/login/login.go 88.23% 0 Missing and 2 partials ⚠️
pkg/store/http.go 93.75% 2 Missing ⚠️
pkg/cmd/ls/ls.go 0.00% 1 Missing ⚠️
pkg/errors/errors.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #464      +/-   ##
==========================================
+ Coverage   24.67%   29.09%   +4.42%     
==========================================
  Files         134      140       +6     
  Lines       18337    19809    +1472     
==========================================
+ Hits         4525     5764    +1239     
- Misses      13335    13462     +127     
- Partials      477      583     +106     
Flag Coverage Δ
Linux 29.09% <64.87%> (+4.42%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread pkg/cmd/register/register.go Outdated
Comment on lines 177 to 180
// Verify the user is authenticated before performing any local side effects.
if _, err := s.GetCurrentUser(); err != nil {
return breverrors.WrapAndTrace(err)
}

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.

Only do this if we're in the normal non-key mode?

@patelspratik patelspratik Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this should really be something like "isAuthenticated". I'll fix this with a better sentinel.

Base automatically changed from pr1-register-resiliency to main August 28, 2026 18:26
@patelspratik
patelspratik force-pushed the pr2-credential-chain branch 2 times, most recently from a7dfe8c to 92c34a0 Compare August 28, 2026 23:05
Rebased onto pr1-register-resiliency (post ssh-certs uptake).

- BREV_ACCESS_KEY renamed to BREV_API_KEY (never released); all
  access-key identifiers and messages renamed to API key
- Env-key orgs resolve in real time from the backend: the key is bound
  to exactly one org server-side, so no persisted org is consulted and
  staleness is impossible. Established logins keep persisted org
  behavior (APIKeyOrgID / active-org cache)
- Single-org invariant hoisted to auth.SingleOrgForAPIKey, shared by
  register and the general resolution path
- GetActiveOrganizationOrNil branches on credential source; env path
  returns the full org (name included) without a second GetOrganization
  round-trip
- Register with no env key and no persisted credential now prompts the
  device-flow login (externalNodeAuth fallback) instead of erroring;
  tokens stay in memory, the login email is cached for pre-fill
- Register tests moved/renamed to the APIKey convention
@patelspratik patelspratik changed the title Pr2 credential chain credential chain Aug 29, 2026
@patelspratik
patelspratik marked this pull request as ready for review August 29, 2026 00:01
@patelspratik
patelspratik requested a review from a team as a code owner August 29, 2026 00:01
Comment thread pkg/store/http.go

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is very stupid and all because we do a singular automatic retry in our resty client, which prints errors automatically/uncontrollably.

I'd like to remove that, but it is a nice feature to try automatically renew stale creds, so I left that and this.

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