feat: implement OAuth2/OIDC support for self-hosted Superset #19
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds comprehensive OAuth2/OIDC authentication support for self-hosted Superset instances with automatic token refresh and CSRF management.
Overview
This PR implements Phase 1 of OAuth2/OIDC support for self-hosted Superset instances. Users can now authenticate sup with external identity providers (Keycloak, Okta, Auth0, Azure AD, Cognito, Dex) using the resource owner password grant flow.
Core Implementation
New Classes & Functions
OAuthSupersetAuth (src/preset_cli/auth/oauth_superset.py, 273 LOC)
create_superset_auth factory (src/preset_cli/auth/factory.py, 109 LOC)
Configuration
Extended SupersetInstanceConfig with OAuth2 fields:
Testing
Features
✓ Zero new dependencies - Uses only requests, yarl (already included)
✓ No breaking changes - All existing auth methods still work
✓ Fully type-safe - Complete type hints throughout
✓ Production ready - Battle-tested OAuth2 patterns
✓ Secure by default - In-memory token caching, environment variable support
Usage
Configure in
~/.sup/config.yml:Then use sup normally:
Provider Support
Tested and working with:
Documentation
Comprehensive documentation included:
Updated README.md with OAuth2 overview and quick setup examples.
Testing
All existing tests pass + 24 new tests:
pytest tests/auth/test_oauth_superset.py tests/auth/test_auth_factory.py -v # 24 passed in 0.45sBackward Compatibility
Next Steps (Future Phases)
Optional enhancements for later:
sup config oauth)