Skip to content

[auth] Quick-setup helpers and env validation - #100

Open
ROHIT-JR wants to merge 1 commit into
nitrocloudofficial:developfrom
ROHIT-JR:feat/70-quick-setup
Open

ROHIT-JR wants to merge 1 commit into
nitrocloudofficial:developfrom
ROHIT-JR:feat/70-quick-setup

Conversation

@ROHIT-JR

Copy link
Copy Markdown
Collaborator

Closes #70

What this adds

New nitrostack/auth/setup.py, exported from nitrostack:

  • setup_jwt_auth, setup_api_key_auth, setup_oauth_auth: each returns a dict of keyword arguments for the matching module, so JWTModule.for_root(**setup_jwt_auth()) works. Secrets in the dict are SecretValue (from [auth] SecretValue wrapper for secrets #69), so printing the config never shows them. Plain str secrets are accepted and wrapped.
  • validate_auth_env(kind) -> (valid, missing): lists every missing variable, not just the first. Where any one of several variables would do (for example JWKS_URI or an introspection endpoint) they are shown joined with "or".
  • print_auth_setup_instructions(kind): prints the steps; never prints a secret.
  • generate_test_credentials(): random SecretValue JWT secret and API key on every call, documented as test-only, never printed.

Differences from closed PR #4

PR #4's setup.py added Starlette middleware from a middleware.py that does not exist on develop. The current modules are DI-based, so these helpers return config for the modules instead of patching an app. camelCase aliases and print calls are dropped.

Tests

tests/test_auth_setup.py (19 tests): each helper's output configures its module and the resulting service works (JWT sign and verify, API key list, OAuth fields), all missing variables are reported, partial and complete environments, random test credentials, nothing printed or logged, and unknown kind. Full suite: 844 passed locally (--timeout=60).

Notes

  • The environment variable names follow what the repo already documents (JWT_SECRET, API_KEY / API_KEY_<n>, RESOURCE_URI, AUTH_SERVER_URL, JWKS_URI, OAUTH_INTROSPECTION_ENDPOINT).
  • README gets a short "Quick auth setup" section.

@AadarshM07 AadarshM07 linked an issue Oct 29, 2026 that may be closed by this pull request
3 tasks
@AadarshM07
AadarshM07 self-requested a review October 29, 2026 12:08

@AadarshM07 AadarshM07 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed the changes on feat/70-quick-setup against develop. Everything looks good to me. tested the changes locally, test and CI passes as well

This branch has not been deployed

No deployments
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.

Quick-setup helpers and env validation

2 participants