apexauthlib
Private Python library for integrating backend services with the company auth-service.
This library provides:
- Entities used across services (user, service, client, service metadata, permissions).
- A FastAPI router (
auth_api) with login endpoints and dependency helpers that inject the current user + metadata from JWT. - A small HTTP client wrapper (
AuthApiProvider/AuthApi) for services to:- obtain a token (password login or OAuth code exchange),
- fetch current user and service-scoped metadata,
- list users for a service,
- and register/update service permissions.
Notes
- This documentation is best used along with the documentation for auth-service.
- This is a private library. If you change it, you should push to GitHub and then update downstream usage by running
make installwherever it’s consumed (per team workflow).
Concepts at a glance
Users
The User entity includes:
hashed_password: must never expose an actual password through APIs (except in create/update requests handled elsewhere).is_admin: indicates whether the user is a “superadmin”.
Service-scoped auth model
The auth model used by services is service-centric:
- Services have a name (
service_name) and service admins. - Each service can define permissions (schema) and per-user metadata values that should align with those permissions.
See: docs/concepts.md
Usage pattern (high-level)
1) Create an AuthApiProvider
Example (from service code):
provider = AuthApiProvider[HaccpPermissions](
http=FluentHttp(
Httpx.Builder().with_url(AUTH_SERVICE_API).build(),
),
service_name=SERVICE_NAME,
formatter=DataclassFormatter(HaccpPermissions),
)
2) Register permissions (service schema)
Example:
provider.for_token(
provider.login(ADMIN_USERNAME, ADMIN_PASSWORD)
).update_permissions(
[
ServicePermission(
# ...
)
]
)
3) Add FastAPI auth routes + dependencies
Example:
FastApiBuilder()
.with_title(TITLE)
.with_description(DESCRIPTION)
.with_version(VERSION)
.with_route(auth_api)
.with_dependency(
auth=provider,
auth_code=AuthCodeApi(
http=FluentHttp(
Httpx.Builder()
.with_url(AUTH_SERVICE_API)
.build(),
),
client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
),
)
.build()
See: docs/fastapi.md
Known Limitations
Permission sync is name-based only
AuthApi.update_permissions() compares permissions by name and only creates/deletes. If a permission keeps the same name but changes type, default, label, etc., it currently won’t be updated automatically.
Admin password dependency for permission registration
The example uses provider.login(ADMIN_USERNAME, ADMIN_PASSWORD) to obtain a token for updating permissions. If the admin password changes, downstream services must update their configuration, or a more proper flow should be introduced (e.g., service-to-service auth or code-based admin auth).
Refresh tokens are not currently handled in this library
Current flow assumes a bearer access token is provided/used. Supporting refresh tokens would enable longer-lived sessions with automatic token renewal.
Metadata
Release files for apexauthlib 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| apexauthlib-0.3.1.tar.gz | 6.1 kB | Without provenance | Details for apexauthlib-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| apexauthlib-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for apexauthlib-0.3.1-py3-none-any.whl |
Total release size: 14.5 kB
Release files / apexauthlib-0.3.1.tar.gz
| Download URL | apexauthlib-0.3.1.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a2fdd07f2e6c2552cdcbf8454afe0b5af0ee009abb5142639a1636b75aca6db
|
|
BLAKE2b-256 checksum How to use checksums |
b34aded84f7b195df9187d69aa6626b001225e31dee5b8dd2913f3ece135a0f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.4 CPython/3.12.13 Linux/6.17.0-1010-azure
|
Release files / apexauthlib-0.3.1-py3-none-any.whl
| Download URL | apexauthlib-0.3.1-py3-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
000c3bc1b583e9aa54de1d9936da0a2eac0e6df6ab0d7d306b6e0240b9d40101
|
|
BLAKE2b-256 checksum How to use checksums |
ed2cb5722b94d5ccfe579e623f03663649fc159bf37ef32039c11f851af87c87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.4 CPython/3.12.13 Linux/6.17.0-1010-azure
|
Security for apexauthlib 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.