Pre-release
This release is a pre-release and may not be stable for production use.
Swarmauri Auth IDP Keycloak
Keycloak OAuth 2.0 / OAuth 2.1 / OIDC 1.0 identity providers packaged for Swarmauri deployments.
Features
- PKCE-enabled Authorization Code flows that integrate with Keycloak realm issuers.
- Discovery-driven OAuth 2.1/OIDC login that validates ID tokens against realm JWKS.
- UserInfo enrichment for deployments that require normalized profile payloads.
- Retry-aware HTTP integration tuned for Keycloak endpoints.
- ComponentBase-compatible models registered under
swarmauri.auth_idpentry points.
Installation
pip
pip install swarmauri_auth_idp_keycloak
uv (project)
uv add swarmauri_auth_idp_keycloak
uv (environment)
uv pip install swarmauri_auth_idp_keycloak
Usage
import asyncio
from pydantic import SecretBytes, SecretStr
from swarmauri_auth_idp_keycloak import KeycloakOAuth20Login
login = KeycloakOAuth20Login(
issuer="https://kc.example.com/realms/myrealm",
client_id="keycloak-client-id",
client_secret=SecretStr("keycloak-client-secret"),
redirect_uri="https://app.example.com/callback",
state_secret=SecretBytes(b"replace-with-random-bytes"),
)
# Optional: preload discovery metadata when running outside your Keycloak instance.
login.discovery_cache = {
"authorization_endpoint": "https://kc.example.com/realms/myrealm/protocol/openid-connect/auth",
"token_endpoint": "https://kc.example.com/realms/myrealm/protocol/openid-connect/token",
"userinfo_endpoint": "https://kc.example.com/realms/myrealm/protocol/openid-connect/userinfo",
}
async def run_flow() -> None:
auth = await login.auth_url()
print(auth["url"])
# Redirect the browser to `auth["url"]`, then capture the callback `code` and `state`.
# Later, call `login.exchange_and_identity(code, state)` inside your callback handler.
asyncio.run(run_flow())
Workflow Summary
- Call
auth_url()and redirect the browser to the returned URL. - Persist the
stateand verify it during the callback handler. - Exchange the authorization code through
exchange_and_identity()to obtain tokens and profile metadata.
Entry Points
swarmauri.auth_idp:KeycloakOAuth20Loginswarmauri.auth_idp:KeycloakOAuth21Loginswarmauri.auth_idp:KeycloakOIDC10Login
Contributing
To contribute to swarmauri-sdk, review the guidelines for contributing which cover development workflow, testing, and coding standards.
Metadata
Release files for swarmauri_auth_idp_keycloak 0.11.0.dev2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| swarmauri_auth_idp_keycloak-0.11.0.dev2.tar.gz | 11.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| swarmauri_auth_idp_keycloak-0.11.0.dev2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.1 kB
Release files / swarmauri_auth_idp_keycloak-0.11.0.dev2.tar.gz
| Download URL | swarmauri_auth_idp_keycloak-0.11.0.dev2.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33a31c96d3324a8ae3a099195767ebc0aa47b0a72131de7906cfa5e2f204ac68
|
|
BLAKE2b-256 checksum How to use checksums |
6bd62d0fce8a9c07f9815aa0fa5ceb707e28e814ec71b4eca4e1a24ad4de3180
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / swarmauri_auth_idp_keycloak-0.11.0.dev2-py3-none-any.whl
| Download URL | swarmauri_auth_idp_keycloak-0.11.0.dev2-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e420a4a77d0fafd031f0091a84f8d129b64d736db31a0d1216ed6c6fee4c409d
|
|
BLAKE2b-256 checksum How to use checksums |
d98391810556f22917c643ba0642f07798a7f89f68a4d48ae32189b9939b2dc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|