Skip to content

feat: authenticate and check registered accounts - #10

Merged
ygpark80 merged 13 commits into
mainfrom
feat/account-registry
Sep 10, 2026
Merged

ygpark80 merged 13 commits into
mainfrom
feat/account-registry

Conversation

@ygpark80

@ygpark80 ygpark80 commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

User description

Adds end-to-end account registration and checking for nosnitch. account add <provider> now starts PKCE/OAuth for OpenAI and Anthropic, or opens and monitors the first-party browser login for browser-only providers, then infers the account identity from provider readback. Metadata is stored in XDG config and credentials are stored in a hashed, mode-0600 XDG cache file.

Registered credentials are used by check --account and check --all; expiring OAuth credentials refresh with rotation, missing or rejected credentials affect only that account, and browser cookie stores include profile discovery plus WAL/SHM snapshots. README now contains the complete command table and storage/authentication contract. Validation includes unit tests, race tests, go vet, macOS and Linux cross-builds, and read-only checks against the current local sessions.


CodeAnt-AI Description

Register, authenticate, and audit individual provider accounts

What Changed

  • Users can add, list, remove, and check registered OpenAI, Anthropic, Claude, and GitHub accounts.
  • OpenAI and Anthropic account setup uses browser OAuth with identity checks, token refresh, and reauthentication errors limited to the affected account.
  • Browser-only providers open their first-party login page when no session is available and support separate Chromium profiles.
  • Registered credentials are stored separately from account metadata in protected local files with hashed filenames; removing an account also removes its cached credential.
  • Checks and privacy-setting changes can use matching registered OAuth credentials, and off now covers registered OAuth accounts.
  • Expired browser cookies are ignored, including cookies recorded in SQLite WAL and SHM files.
  • The README documents the account commands, authentication flow, storage locations, and credential handling.

Impact

✅ Checks for selected accounts without account mix-ups
✅ Fewer reauthentication interruptions for expiring OAuth credentials
✅ Privacy settings updated across registered OAuth accounts
✅ Reliable discovery across Chromium profiles
✅ Safer local storage for tokens and browser cookies

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@codeant-ai

codeant-ai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Incremental review completed 6315adc Sep 10, 2026 · 07:31 07:32
✅ Incremental review completed 472a533 Sep 10, 2026 · 05:38 05:38
✅ Incremental review completed 797db5f Sep 10, 2026 · 04:24 04:25
✅ Reviewed your PR 4fe4df2 Sep 10, 2026 · 02:17 02:19

@codeant-ai

codeant-ai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 793c3580-c60d-409f-bffb-f0251522e0e3


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Sep 10, 2026
Comment thread internal/registry/registry.go Outdated
if root == "" {
root = filepath.Join(os.Getenv("HOME"), ".cache")
}
return filepath.Join(root, "nosnitch", "credentials", id+".json")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: id is used directly in the credential path, so an account ID containing ../ lets removal target files outside the credentials directory. [security]

Assessment: 🟠 Major · 🔁 Occurrence: Rarely

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** internal/registry/registry.go
**Line:** 35:35
**Comment:**
	*Security: `id` is used directly in the credential path, so an account ID containing `../` lets removal target files outside the credentials directory.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread internal/registry/registry.go Outdated
return os.WriteFile(p, append(b, '\n'), 0600)
}
func Upsert(a Account) error {
all, e := Load()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Concurrent add or remove commands can load the same registry, overwrite each other’s changes, or read partially written JSON because updates are unlocked and direct. [race condition]

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** internal/registry/registry.go
**Line:** 64:64
**Comment:**
	*Race Condition: Concurrent add or remove commands can load the same registry, overwrite each other’s changes, or read partially written JSON because updates are unlocked and direct.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread internal/registry/registry.go Outdated
if e = Save(out); e != nil {
return e
}
_ = os.Remove(credentialPath(id))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Credential deletion errors are discarded after metadata removal, so a failed delete leaves cached secrets behind while the command reports success. [error handling]

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** internal/registry/registry.go
**Line:** 97:97
**Comment:**
	*Error Handling: Credential deletion errors are discarded after metadata removal, so a failed delete leaves cached secrets behind while the command reports success.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

Comment thread main.go Outdated
fmt.Fprintln(os.Stderr, "account identity required")
return 2
}
a := registry.Account{ID: provider + ":" + id, Provider: provider, Email: id, UpdatedAt: time.Now().UTC()}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The add command only records typed identity text; it performs no authentication and creates no credential, so the registered account cannot be used by the current account checks. [incomplete implementation]

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** main.go
**Line:** 104:104
**Comment:**
	*Incomplete Implementation: The add command only records typed identity text; it performs no authentication and creates no credential, so the registered account cannot be used by the current account checks.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@codeant-ai

codeant-ai Bot commented Sep 10, 2026

Copy link
Copy Markdown

CodeAnt Nitpicks

1 code suggestion

1. Writing an existing registry does not enforce mode 0600; a previously broad-readable file keeps its permissions and can expose account metadata.

Security · internal/registry/registry.go:61

@codeant-ai codeant-ai Bot added size:XXL This PR changes 1000+ lines, ignoring generated files and removed size:L This PR changes 100-499 lines, ignoring generated files labels Sep 10, 2026
@ygpark80 ygpark80 changed the title feat: add file-based account registry feat: authenticate and check registered accounts Sep 10, 2026
@ygpark80
ygpark80 merged commit e54d615 into main Sep 10, 2026
2 checks passed
@ygpark80
ygpark80 deleted the feat/account-registry branch September 10, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant