Commit Graph
20 Commits
Author SHA1 Message Date
Ejiro Asiuwhu 3094338b42 test: add failing tests for team CRUD methods
- Tests for get_team, list_teams, create_team, update_team, delete_team
- Tests for get_team_by_api_key two-step lookup
- Async equivalents for all team CRUD operations
- Uses respx mocking pattern consistent with existing user tests
2026-03-25 01:22:09 +01:00
Ejiro Asiuwhu 7f4e3eb428 feat: add session management methods to StackServerApp and AsyncStackServerApp
- list_sessions(user_id) returns list of ActiveSession for a user
- get_session(session_id, user_id) filters from list_sessions, returns ActiveSession or None
- revoke_session(session_id, user_id) deletes session via DELETE endpoint
- Both sync and async facades implement all three methods
2026-03-25 01:11:22 +01:00
Ejiro Asiuwhu e1ccb718f4 test: add failing tests for session management methods
- list_sessions, get_session, revoke_session tests for sync and async
- Tests verify user_id query param, empty results, session filtering
2026-03-25 01:10:41 +01:00
Ejiro Asiuwhu 7eb0c25dc6 feat: export StackServerApp and AsyncStackServerApp from package root
- Add top-level imports so users can write: from stack_auth import StackServerApp
- Remove outdated comment about Phase 3 adding facades
2026-03-25 01:07:48 +01:00
Ejiro Asiuwhu fd3a816700 feat: add StackServerApp and AsyncStackServerApp with user CRUD
- StackServerApp (sync) and AsyncStackServerApp (async) facade classes
- get_user returns ServerUser or None on 404
- list_users with cursor/limit/order_by/desc/query/include_restricted/include_anonymous
- create_user sends only non-None fields
- update_user uses _UNSET sentinel to distinguish not-provided from explicit None
- delete_user returns None
- get_user_by_api_key performs two-step lookup via /api-keys/check then /users/{id}
- Both classes support context managers and compose API client + optional token store
2026-03-25 01:07:02 +01:00
Ejiro Asiuwhu 13f88755e3 test: add failing tests for StackServerApp and AsyncStackServerApp
- Tests for get_user, list_users, create_user, update_user, delete_user
- Tests for get_user_by_api_key two-step lookup
- Tests for sentinel pattern in update_user (None vs not-provided)
- Both sync and async facades covered with respx mocks
2026-03-25 01:05:49 +01:00
Ejiro Asiuwhu 6b1138981d feat: add token store with CAS-based refresh and dual locks
- TokenStore ABC with get_stored_access_token, get_stored_refresh_token, compare_and_set
- MemoryTokenStore, ExplicitTokenStore, RequestTokenStore implementations
- Module-level registry shares MemoryTokenStore instances per project_id
- resolve_token_store handles memory/dict/request/None init variants
- CAS refresh algorithm (sync + async) with 20s expiry buffer and 75s iat threshold
- Token refresh via form-encoded POST to /api/v1/auth/oauth/token
- Per-instance threading.Lock and asyncio.Lock for concurrency safety
- 34 passing tests covering all store types, registry, helpers, and CAS branches
2026-03-25 00:51:40 +01:00
Ejiro Asiuwhu 8060bc67ff feat: export auth types and functions from stack_auth package
- Add AuthState, TokenPartialUser, decode_access_token_claims to public API
- Add sync_authenticate_request and async_authenticate_request exports
- Existing exports unchanged
2026-03-25 00:51:27 +01:00
Ejiro Asiuwhu 3ca550191b feat: add authenticate_request with jwt verification and partial decode
- TokenPartialUser frozen dataclass for unverified JWT payload extraction
- AuthState frozen dataclass for authentication results
- decode_access_token_claims extracts user info without signature verification
- _extract_token_from_headers handles Authorization and x-stack-auth headers
- sync_authenticate_request and async_authenticate_request compose with JWKS verifier
2026-03-25 00:50:59 +01:00
Ejiro Asiuwhu ad63cf03a0 test: add failing tests for token store subsystem
- TokenStore ABC, MemoryTokenStore, ExplicitTokenStore, RequestTokenStore
- Registry with shared instances per project_id
- CAS refresh algorithm with timing thresholds (20s/75s)
- Sync and async variants of get_or_fetch_likely_valid_tokens
- Helper functions: _is_fresh_enough, _is_expired, _decode_jwt_payload
2026-03-25 00:50:23 +01:00
Ejiro Asiuwhu ea427ed423 test: add failing tests for auth module
- Tests for decode_access_token_claims (valid JWT, defaults, malformed, missing sub, base64url)
- Tests for _extract_token_from_headers (Authorization, lowercase, x-stack-auth, missing)
- Tests for sync_authenticate_request and async_authenticate_request
2026-03-25 00:50:06 +01:00
Ejiro Asiuwhu 07c32d4a6e feat: add pagination support with cursor-based PaginatedResult
- PaginatedResult[T] generic wrapping nested {items, pagination: {next_cursor}} shape
- Convenience properties .next_cursor and .has_next_page
- Package __init__.py exports all models, errors, and PaginatedResult
- SyncAPIClient/AsyncAPIClient intentionally excluded from public API
- Tests verify pagination with ServerUser and Team types
2026-03-24 22:25:13 +01:00
Ejiro Asiuwhu aecd4aa6e7 feat: add project, api key, oauth, payment, and notification models
- Project with nested ProjectConfig and OAuthProviderConfig
- ApiKey hierarchy: ApiKey, UserApiKey, UserApiKeyFirstView, TeamApiKey, TeamApiKeyFirstView
- OAuthConnection and OAuthProvider models
- Item and Product payment models
- NotificationCategory model
- models/__init__.py re-exports all 20+ model classes
2026-03-24 22:23:58 +01:00
Ejiro Asiuwhu 28171d43cf feat: add sync and async HTTP client with retry logic
- BaseAPIClient generic base with header construction, URL building,
  response parsing via x-stack-actual-status and x-stack-known-error
- SyncAPIClient wrapping httpx.Client with context manager support
- AsyncAPIClient wrapping httpx.AsyncClient with async context manager
- Exponential backoff retry for idempotent methods (GET/PUT/DELETE)
- 429 rate limit handling with Retry-After header support
- POST/PUT/PATCH with no body sends {} as JSON
- All 26 tests passing
2026-03-24 22:23:56 +01:00
Ejiro Asiuwhu 7b75ba81a8 feat: add jwt verification with async jwks fetcher and ttl cache
- AsyncJWKSFetcher and SyncJWKSFetcher with 5-minute in-memory TTL cache
- verify_token (async + sync) decodes RS256 JWTs via PyJWT
- Algorithm hardcoded to RS256 to prevent CVE-2022-29217 algorithm confusion
- Force-refresh on unknown kid for key rotation handling
2026-03-24 22:23:23 +01:00
Ejiro Asiuwhu 488e72a9cf feat: add user, team, session, contact channel, and permission pydantic models
- BaseUser and ServerUser with camelCase aliases and millis-to-datetime properties
- Team, ServerTeam, TeamMemberProfile, TeamInvitation with timestamp conversions
- ActiveSession with GeoInfo nested model
- ContactChannel and TeamPermission/ProjectPermission
- Tests for user and team model parsing, inheritance, and field conversion
2026-03-24 22:23:11 +01:00
Ejiro Asiuwhu 6b4cd35875 test: add failing tests for jwt verification and jwks fetching
- AsyncJWKSFetcher and SyncJWKSFetcher construction and key retrieval
- TTL cache behavior with 5-minute expiry
- Force-refresh on unknown kid
- verify_token for valid, expired, invalid signature, missing kid tokens
- CVE-2022-29217 protection: HS256 tokens rejected
2026-03-24 22:22:34 +01:00
Ejiro Asiuwhu fbe1c5bfc3 test: add failing tests for sync and async HTTP client
- 22 tests covering construction, headers, URL building, request pipeline
- Response processing with x-stack-actual-status and x-stack-known-error
- Retry logic with exponential backoff for idempotent methods
- 429 rate limit handling with Retry-After header
- Context manager protocol for both sync and async clients
2026-03-24 22:22:32 +01:00
Ejiro Asiuwhu a8c18f366b feat: add python sdk package skeleton with error hierarchy
- StackAuthError base with code/message/details and from_response() factory
- 13 category subclasses: Authentication, NotFound, Validation, PermissionDenied,
  Conflict, OAuth, Passkey, ApiKey, Payment, Email, RateLimit, Cli, Analytics
- Complete _ERROR_CODE_MAP with 143 error codes from known-errors.tsx
- StackAuthModel base class with Pydantic v2 ConfigDict and millis conversion
- Package exports via __init__.py with __all__
2026-03-24 22:18:36 +01:00
Ejiro Asiuwhu 728533c87f test: add failing tests for python sdk error hierarchy and base model
- Test StackAuthError base class storage and string representation
- Test all 13 category subclasses inherit from StackAuthError
- Test from_response() dispatch for known and unknown error codes
- Test StackAuthModel config and millis conversion
- Package skeleton with pyproject.toml (stubs only, tests expected to fail)
2026-03-24 22:17:03 +01:00