A pluggable Identity and Access Management (IAM) SDK for GDP Labs applications.
Project description
GL-IAM
Description
A pluggable Identity and Access Management (IAM) SDK for GDP Labs applications. GL-IAM provides a unified interface for authentication, authorization, user management, and organization management following the Single Interface Multiple Implementation (SIMI) pattern.
Key Features
- Pluggable Authentication: Support for Stack Auth, Keycloak (with LDAP/SAML federation), PostgreSQL, and custom providers
- User Store Abstraction: Flexible user storage with JIT (Just-In-Time) provisioning
- Role-Based Access Control (RBAC): Comprehensive permission and role management
- Multi-Factor Authentication (MFA): TOTP and other second-factor methods
- Organization Management: Multi-tenancy support for enterprise applications
- FastAPI Integration: Ready-to-use dependencies for FastAPI applications
Installation
Prerequisites
Mandatory:
- Python 3.11+ — Install here
- pip — Install here
- uv — Install here
For PostgreSQL provider: 4. PostgreSQL 13+ — Recommended for production (details)
Extras (required only for Artifact Registry installations):
- gcloud CLI (for authentication) — Install here, then log in using:
gcloud auth login
Option 1: Install from Artifact Registry
This option requires authentication via the gcloud CLI.
uv pip install \
--extra-index-url "https://oauth2accesstoken:$(gcloud auth print-access-token)@glsdk.gdplabs.id/gen-ai-internal/simple/" \
gl-iam
With optional dependencies:
# With FastAPI integration
uv pip install "gl-iam[fastapi]"
# With Stack Auth provider
uv pip install "gl-iam[stackauth]"
# With LDAP provider
uv pip install "gl-iam[ldap]"
# With all providers
uv pip install "gl-iam[all]"
Option 2: Install from PyPI
This option requires no authentication. However, it installs the binary wheel version of the package, which is fully usable but does not include source code.
uv pip install gl-iam-binary
Quick Start
Basic Usage
from gl_iam import IAMGateway
from gl_iam.providers.stackauth import StackAuthProvider
# Initialize with Stack Auth as full-stack provider
gateway = IAMGateway.from_fullstack_provider(
provider=StackAuthProvider(
api_url="https://api.stack-auth.com",
project_id="your-project-id",
secret_key="your-secret-key",
)
)
# Authenticate a user
result = await gateway.authenticate(
credentials={"email": "user@example.com", "password": "secret"}
)
if result.is_ok:
user = result.user
print(f"Authenticated: {user.display_name}")
Mix-and-Match Providers
from gl_iam import IAMGateway
from gl_iam.providers.ldap import LDAPAuthProvider
from gl_iam.providers.stackauth import StackAuthUserStore
# Use LDAP for authentication, Stack Auth for user storage
gateway = IAMGateway(
auth_provider=LDAPAuthProvider(
server_url="ldap://ad.company.com",
base_dn="dc=company,dc=com",
),
user_store=StackAuthUserStore(
api_url="https://api.stack-auth.com",
project_id="your-project-id",
),
enable_jit_provisioning=True, # Auto-create users on first login
)
FastAPI Integration
from fastapi import FastAPI, Depends
from gl_iam.fastapi import get_current_user, require_permission, require_role
from gl_iam.types import User
app = FastAPI()
@app.get("/profile")
async def get_profile(user: User = Depends(get_current_user)):
return {"user_id": user.id, "email": user.email}
@app.delete("/admin/users/{user_id}")
async def delete_user(
user_id: str,
_: None = Depends(require_permission("users:delete")),
):
# Only users with "users:delete" permission can access
pass
@app.get("/admin/dashboard")
async def admin_dashboard(_: None = Depends(require_role("admin"))):
# Only users with "admin" role can access
pass
Local Development Setup
Prerequisites
-
Python 3.11+ — Install here
-
pip — Install here
-
uv — Install here
-
gcloud CLI — Install here, then log in using:
gcloud auth login
-
Git — Install here
-
Access to the GDP Labs SDK GitHub repository
1. Clone Repository
git clone git@github.com:GDP-ADMIN/gl-sdk.git
cd gl-sdk/libs/gl-iam
2. Setup Authentication
Set the following environment variables to authenticate with internal package indexes:
export UV_INDEX_GEN_AI_INTERNAL_USERNAME=oauth2accesstoken
export UV_INDEX_GEN_AI_INTERNAL_PASSWORD="$(gcloud auth print-access-token)"
export UV_INDEX_GEN_AI_USERNAME=oauth2accesstoken
export UV_INDEX_GEN_AI_PASSWORD="$(gcloud auth print-access-token)"
3. Quick Setup
Run:
make setup
4. Activate Virtual Environment
source .venv/bin/activate
Local Development Utilities
The following Makefile commands are available for quick operations:
Install uv
make install-uv
Install Pre-Commit
make install-pre-commit
Install Dependencies
make install
Update Dependencies
make update
Run Tests
make test
Architecture
GL-IAM follows the Single Interface Multiple Implementation (SIMI) pattern:
┌─────────────────────────────────────────────────────────────┐
│ IAMGateway │
│ (Central Orchestrator - Coordinates all IAM operations) │
└─────────────────────────────────────────────────────────────┘
│
┌─────────────────────┼─────────────────────┐
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ Authentication│ │ User Store │ │ Session │
│ Provider │ │ Provider │ │ Provider │
└───────────────┘ └───────────────┘ └───────────────┘
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ - Stack Auth │ │ - Stack Auth │ │ - Stack Auth │
│ - LDAP │ │ - PostgreSQL │ │ - Redis │
│ - SAML │ │ - Custom │ │ - JWT │
│ - OAuth2 │ │ │ │ │
└───────────────┘ └───────────────┘ └───────────────┘
Migration Guides
Migrating from BOSA Core Auth
If you're currently using BOSA Core Authentication (bosa-core[authentication]) and want to migrate to GL-IAM, see the comprehensive migration guide:
📖 BOSA to GL-IAM Migration Guide
The guide covers:
- Step-by-step migration instructions
- API mapping reference (BOSA → GL-IAM)
- Data migration scripts
- Code examples for common patterns
- Testing and rollback strategies
Contributing
Please refer to the Python Style Guide for information about code style, documentation standards, and SCA requirements.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gl_iam_binary-0.3.9b1-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: gl_iam_binary-0.3.9b1-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 2.9 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
945178b6edb8c2c5e869667e04d169a981c15086a2e246c094cfc0d11d7ec1a9
|
|
| MD5 |
adc971100c3d78ba2cd6365ddb3288c6
|
|
| BLAKE2b-256 |
5d13a8a8f9386317bee69770b6bbfdbaf4ad166862b57a51c8a5143d41bb6808
|
Provenance
The following attestation bundles were made for gl_iam_binary-0.3.9b1-cp313-cp313-win_amd64.whl:
Publisher:
build-binary.yml on GDP-ADMIN/gl-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gl_iam_binary-0.3.9b1-cp313-cp313-win_amd64.whl -
Subject digest:
945178b6edb8c2c5e869667e04d169a981c15086a2e246c094cfc0d11d7ec1a9 - Sigstore transparency entry: 2211796161
- Sigstore integration time:
-
Permalink:
GDP-ADMIN/gl-sdk@27dc0c0bc1ae047b305f1fef0d4febe53f14a55d -
Branch / Tag:
refs/tags/gl_iam-v0.3.9b1 - Owner: https://github.com/GDP-ADMIN
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-binary.yml@27dc0c0bc1ae047b305f1fef0d4febe53f14a55d -
Trigger Event:
push
-
Statement type:
File details
Details for the file gl_iam_binary-0.3.9b1-cp313-cp313-manylinux_2_31_x86_64.whl.
File metadata
- Download URL: gl_iam_binary-0.3.9b1-cp313-cp313-manylinux_2_31_x86_64.whl
- Upload date:
- Size: 4.0 MB
- Tags: CPython 3.13, manylinux: glibc 2.31+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0729afba9dde21db4d0136d5b4d8c8232c0290081381f8a6b395693d43c513f
|
|
| MD5 |
dc965d8b33b7e4292317e6ead8da84f1
|
|
| BLAKE2b-256 |
1d2d014bbbc13635eddda3d0b6c0bd50f9e0c387f15620cc6efb1281c84ae521
|
File details
Details for the file gl_iam_binary-0.3.9b1-cp313-cp313-macosx_13_0_arm64.whl.
File metadata
- Download URL: gl_iam_binary-0.3.9b1-cp313-cp313-macosx_13_0_arm64.whl
- Upload date:
- Size: 3.2 MB
- Tags: CPython 3.13, macOS 13.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b76f5930ba46d40516c83c5a17f2f34a0e0f712566cd7240066ad61efb7b33d
|
|
| MD5 |
ef0c42b36dfabd0470187406993c8c95
|
|
| BLAKE2b-256 |
0ad0a79cf12fdc5e5faec4864575a1d63b803d1ec4842c6603b344151e10bd3e
|
Provenance
The following attestation bundles were made for gl_iam_binary-0.3.9b1-cp313-cp313-macosx_13_0_arm64.whl:
Publisher:
build-binary.yml on GDP-ADMIN/gl-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gl_iam_binary-0.3.9b1-cp313-cp313-macosx_13_0_arm64.whl -
Subject digest:
2b76f5930ba46d40516c83c5a17f2f34a0e0f712566cd7240066ad61efb7b33d - Sigstore transparency entry: 2211796111
- Sigstore integration time:
-
Permalink:
GDP-ADMIN/gl-sdk@27dc0c0bc1ae047b305f1fef0d4febe53f14a55d -
Branch / Tag:
refs/tags/gl_iam-v0.3.9b1 - Owner: https://github.com/GDP-ADMIN
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-binary.yml@27dc0c0bc1ae047b305f1fef0d4febe53f14a55d -
Trigger Event:
push
-
Statement type:
File details
Details for the file gl_iam_binary-0.3.9b1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: gl_iam_binary-0.3.9b1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 2.9 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ee498d591767c077cb21c3a6672e6fac451cf44d94238e1c8916e4565cd647b
|
|
| MD5 |
b58de1ca33c45615660478a16ba9a913
|
|
| BLAKE2b-256 |
57b64e9b266c4a9b3abb8eba790c2865826df8cf513fe750786411caa4a5628e
|
Provenance
The following attestation bundles were made for gl_iam_binary-0.3.9b1-cp312-cp312-win_amd64.whl:
Publisher:
build-binary.yml on GDP-ADMIN/gl-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gl_iam_binary-0.3.9b1-cp312-cp312-win_amd64.whl -
Subject digest:
2ee498d591767c077cb21c3a6672e6fac451cf44d94238e1c8916e4565cd647b - Sigstore transparency entry: 2211795843
- Sigstore integration time:
-
Permalink:
GDP-ADMIN/gl-sdk@27dc0c0bc1ae047b305f1fef0d4febe53f14a55d -
Branch / Tag:
refs/tags/gl_iam-v0.3.9b1 - Owner: https://github.com/GDP-ADMIN
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-binary.yml@27dc0c0bc1ae047b305f1fef0d4febe53f14a55d -
Trigger Event:
push
-
Statement type:
File details
Details for the file gl_iam_binary-0.3.9b1-cp312-cp312-manylinux_2_31_x86_64.whl.
File metadata
- Download URL: gl_iam_binary-0.3.9b1-cp312-cp312-manylinux_2_31_x86_64.whl
- Upload date:
- Size: 4.0 MB
- Tags: CPython 3.12, manylinux: glibc 2.31+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37dbbdd4fd682bc89a0f1c356dfc68a5a76f3b2a91ebe9ed3a7eeaa23a60d3cd
|
|
| MD5 |
f237ab039d9ce9347c2ef7c3f5546d53
|
|
| BLAKE2b-256 |
d0543a4a6d73bcb1d4fecf4db517401f864a07e065ba90b2bb8886c4914bea34
|
File details
Details for the file gl_iam_binary-0.3.9b1-cp312-cp312-macosx_13_0_arm64.whl.
File metadata
- Download URL: gl_iam_binary-0.3.9b1-cp312-cp312-macosx_13_0_arm64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.12, macOS 13.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
880aa35d7b31994681e47b22f2a088fe57de7cef80072e1348ddf5159e6045e2
|
|
| MD5 |
770ac07b10dfbbca91bb58cf463450a9
|
|
| BLAKE2b-256 |
822fc32cdde7d8184380279de254136efb79447a438fb4aab5985ab48418312f
|
Provenance
The following attestation bundles were made for gl_iam_binary-0.3.9b1-cp312-cp312-macosx_13_0_arm64.whl:
Publisher:
build-binary.yml on GDP-ADMIN/gl-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gl_iam_binary-0.3.9b1-cp312-cp312-macosx_13_0_arm64.whl -
Subject digest:
880aa35d7b31994681e47b22f2a088fe57de7cef80072e1348ddf5159e6045e2 - Sigstore transparency entry: 2211796043
- Sigstore integration time:
-
Permalink:
GDP-ADMIN/gl-sdk@27dc0c0bc1ae047b305f1fef0d4febe53f14a55d -
Branch / Tag:
refs/tags/gl_iam-v0.3.9b1 - Owner: https://github.com/GDP-ADMIN
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-binary.yml@27dc0c0bc1ae047b305f1fef0d4febe53f14a55d -
Trigger Event:
push
-
Statement type:
File details
Details for the file gl_iam_binary-0.3.9b1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: gl_iam_binary-0.3.9b1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 2.8 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59200750d20fe23d6e83d22f96e00f260db769c6597fe9eab71b49fdd178496b
|
|
| MD5 |
695fc977a4dc88905aa5f775a157f3af
|
|
| BLAKE2b-256 |
42c2754199974813c1647fc3b9d5e84d9e5741b877b921e1b8cd9ba72e9c86c5
|
Provenance
The following attestation bundles were made for gl_iam_binary-0.3.9b1-cp311-cp311-win_amd64.whl:
Publisher:
build-binary.yml on GDP-ADMIN/gl-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gl_iam_binary-0.3.9b1-cp311-cp311-win_amd64.whl -
Subject digest:
59200750d20fe23d6e83d22f96e00f260db769c6597fe9eab71b49fdd178496b - Sigstore transparency entry: 2211796082
- Sigstore integration time:
-
Permalink:
GDP-ADMIN/gl-sdk@27dc0c0bc1ae047b305f1fef0d4febe53f14a55d -
Branch / Tag:
refs/tags/gl_iam-v0.3.9b1 - Owner: https://github.com/GDP-ADMIN
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-binary.yml@27dc0c0bc1ae047b305f1fef0d4febe53f14a55d -
Trigger Event:
push
-
Statement type:
File details
Details for the file gl_iam_binary-0.3.9b1-cp311-cp311-manylinux_2_31_x86_64.whl.
File metadata
- Download URL: gl_iam_binary-0.3.9b1-cp311-cp311-manylinux_2_31_x86_64.whl
- Upload date:
- Size: 3.6 MB
- Tags: CPython 3.11, manylinux: glibc 2.31+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.24
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17a6a7790e62ebdf519d17ed61c6535b3514e4797c47e57efd89dbfe8268145c
|
|
| MD5 |
bf92d1124ec69c29b99e2b2299f5b0fe
|
|
| BLAKE2b-256 |
d0821b3f1c483af671a232d6512d8aceca6291526fb2160a07270c3d592b0ba8
|
File details
Details for the file gl_iam_binary-0.3.9b1-cp311-cp311-macosx_13_0_arm64.whl.
File metadata
- Download URL: gl_iam_binary-0.3.9b1-cp311-cp311-macosx_13_0_arm64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.11, macOS 13.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5365f38001f8dbac22933fb29378fc62790d0ea885082d6eb5a07a0f0b080ae
|
|
| MD5 |
86c0dcfd4455aa194fd0dd4627787f10
|
|
| BLAKE2b-256 |
eb7a45286b5dd44bebd78d72aba4250e1ee5d119569f62126ea56b18452197e5
|
Provenance
The following attestation bundles were made for gl_iam_binary-0.3.9b1-cp311-cp311-macosx_13_0_arm64.whl:
Publisher:
build-binary.yml on GDP-ADMIN/gl-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gl_iam_binary-0.3.9b1-cp311-cp311-macosx_13_0_arm64.whl -
Subject digest:
a5365f38001f8dbac22933fb29378fc62790d0ea885082d6eb5a07a0f0b080ae - Sigstore transparency entry: 2211795902
- Sigstore integration time:
-
Permalink:
GDP-ADMIN/gl-sdk@27dc0c0bc1ae047b305f1fef0d4febe53f14a55d -
Branch / Tag:
refs/tags/gl_iam-v0.3.9b1 - Owner: https://github.com/GDP-ADMIN
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-binary.yml@27dc0c0bc1ae047b305f1fef0d4febe53f14a55d -
Trigger Event:
push
-
Statement type: