Mountainash Auth Client¶
An intelligent textbook for the mountainash-auth-client type-safe multi-provider authentication library
Experimental
mountainash-auth-client 0.1.0 is experimental and not yet ready for production use. Its APIs can change between versions, and it is not yet published on PyPI.
Getting Started¶
This is an intelligent textbook built with MkDocs Material. Use the navigation sidebar on the left to explore chapters, the learning graph, MicroSims, and supporting reference content.
Front Matter¶
- About — audience, prerequisites, and how to read the book
- Course Description — the seed document used to generate the learning graph
Chapters¶
The main body of the book lives under Chapters. Each
chapter has its own folder with a two-digit prefix (e.g. 01-introduction).
Mountainash Auth Client Package Description¶
Title¶
Mountainash Auth Client: Type-Safe Multi-Provider Authentication Library
Target Audience¶
Python developers integrating with OAuth 2.0 and OAuth 1.0a APIs who need declarative, type-safe authentication with automatic token lifecycle management and pluggable credential storage.
Prerequisites¶
- Intermediate Python (Pydantic models, protocols, context managers)
- Basic understanding of OAuth 2.0 and OAuth 1.0a flows
- Familiarity with HTTP authentication (Bearer tokens, API keys)
- Understanding of credential security (file permissions, atomic writes)
Topics Covered¶
- Auth Type System — Discriminated union of 13 auth types with Literal kind discriminator
- OAuth 2.0 Flows — Authorization Code with PKCE, token exchange, refresh, expiry
- OAuth 1.0a Flows — Three-legged OAuth 1.0a (optional, requires authlib)
- Connection Mixins — OAuth2ConnectionMixin and OAuth1ConnectionMixin with token lifecycle
- Token Lifecycle — Five-state machine (no-token, valid, expired-with-refresh, expired-no-refresh, cleared)
- Secret Storage — SecretStore protocol with FilesystemStore (YAML, file locking, atomic writes)
- Auth Dispatch — Registry mapping auth types to driver-specific kwargs
- Callback Server — LocalCallbackServer for OAuth redirect capture
- Error Handling — TokenExchangeError, TokenRefreshError, AuthorizationRequired
Topics Excluded¶
- Identity provider administration
- SAML/OIDC federation
- Certificate authority management
- Network security protocols
Learning Outcomes¶
After studying this package, developers will be able to:
Remember¶
- List the 13 auth type variants in the discriminated union
- Name the five states in the token lifecycle state machine
- Identify the three error types (TokenExchangeError, TokenRefreshError, AuthorizationRequired)
Understand¶
- Explain the discriminated union + dispatch pattern for auth types
- Describe how PKCE prevents authorization code interception
- Explain file-locked concurrent-safe token refresh
Apply¶
- Configure OAuth2Auth and OAuth2AuthCodeAuth for API providers
- Implement custom SecretStore backends
- Use OAuth2ConnectionMixin for automatic token management
Analyze¶
- Analyze token lifecycle state transitions and edge cases
- Compare auth type dispatch strategies across different backends
Evaluate¶
- Assess security properties of the FilesystemStore implementation
- Judge when to use OAuth2Auth vs OAuth2AuthCodeAuth
Create¶
- Implement new auth type variants for custom authentication schemes
- Build OAuth provider connection mixins with custom metadata
- Design SecretStore backends for vault or keyring systems
Context¶
Mountainash-auth-client makes authentication declarative by representing each auth method as a typed, frozen Pydantic model in a discriminated union. A central dispatch registry maps auth types to driver kwargs, while connection mixins manage the full OAuth token lifecycle with concurrent-safe refresh and pluggable credential storage.