Skip to content

Phase 2: Authentication Module #13

Closed
Closed

Description

@Cesar-M-Diaz

Phase 2: Authentication Module

Implement OAuth-based authentication with NodeSource Accounts API, including token storage, validation, and the auth manager orchestrator.

Tasks

  • Task 5: Implement token storage module — Create token-storage.ts to read/write credentials to ~/.agents/.nodesource-auth.json. Implement secure file permissions (0600). Handle missing file, invalid JSON, and expired tokens. Note: on Windows, chmod 0600 has minimal effect; credential protection relies on directory ACLs.

    • Depends on: Task 4
    • Files: packages/core/src/auth/token-storage.ts
    • Testing: Unit tests for save/load credentials. Test file permissions. Test handling of corrupted file.
  • Task 6: Implement token validator module — Create token-validator.ts to validate service tokens with Accounts API at /accounts/org/access-token. Handle network errors, 401/403 responses, and timeouts. Return validation result with permissions list.

    • Depends on: Task 5
    • Files: packages/core/src/auth/token-validator.ts
    • Testing: Unit tests with mocked HTTP responses. Test success, 401, 500, and timeout scenarios.
  • Task 7: Implement OAuth callback server — Create oauth-server.ts to start local HTTP server on port 8765 (with fallback to 8766-8770). Listen for OAuth callback with token and orgId. Implement 5-minute timeout. Return received credentials.

    • Depends on: Task 4
    • Files: packages/core/src/auth/oauth-server.ts
    • Testing: Unit tests for server startup, callback handling, timeout, and port conflicts.
  • Task 8: Implement auth manager orchestrator — Create auth-manager.ts with ensureAuthenticated() function. Check for existing valid credentials first. If missing/expired, initiate OAuth flow (open browser, start callback server). Validate token with Accounts API. Store credentials. Return Credentials object.

    • Depends on: Tasks 5, 6, 7
    • Files: packages/core/src/auth/auth-manager.ts, packages/core/src/auth/index.ts
    • Testing: Integration test with mocked dependencies. Test happy path, existing valid creds, expired creds, OAuth timeout.

Activity

  1. added theissue type on Jun 9, 2026
  2. coderabbitai commented on Jun 9, 2026

    @coderabbitai
    ⚠️ Possible Duplicate Issue(s)
    🔗 Related PRs

    nodesource/nsolid-console-ng#4596 - N|Solid API - Implement comprehensive token validation middleware [merged]
    nodesource/nsentinel-vscode-extension#18 - feat: implement OAuth authentication flow with settings and logout co… [merged]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  3. self-assigned this
    on Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions