shuffleProvider Agnostic Code

GL IAM implements the SIMI pattern (Single Interface, Multiple Implementations) - your application code stays the same regardless of which identity provider you use.

circle-check

The Problem with Provider-Specific Code

Traditional authentication code is tightly coupled to a specific provider:

# Provider-specific code - hard to migrate

# With Provider A
from provider_a import verify_token_a
user = verify_token_a(request.headers["Authorization"])
if user.permissions.get("admin"):
    ...

# With Provider B (different API)
from provider_b import decode_jwt
claims = decode_jwt(request.headers["Authorization"])
if "admin" in claims["roles"]:
    ...

Migrating between providers requires rewriting authentication logic throughout your application.

The GL IAM Solution

GL IAM provides a unified interface that abstracts provider-specific details:

Same Endpoints, Different Providers

Your endpoint code is identical across all providers:

Unified User Object

Regardless of which provider you use, get_current_user returns the same User object:

Standard Role Mapping

GL IAM maps provider-specific roles to standard roles:

Provider
Provider Role
GL IAM Standard Role

PostgreSQL

admin

ORG_ADMIN

PostgreSQL

member

ORG_MEMBER

Stack Auth

team_admin

ORG_ADMIN

Stack Auth

team_member

ORG_MEMBER

Keycloak

admin

ORG_ADMIN

Keycloak

member

ORG_MEMBER

The authorization dependencies (require_org_admin(), require_org_member()) work identically across providers because they check against these standard roles.

Benefits of Provider-Agnostic Code

Benefit
Description

Migration flexibility

Switch providers without rewriting application code

Testing simplicity

Use PostgreSQL locally, production IdP in deployment

Reduced lock-in

Your code doesn't depend on a specific vendor's API

Consistent patterns

Same authorization patterns across all projects

Faster development

Learn once, apply everywhere

Environment-Based Provider Selection

A common pattern is selecting the provider based on environment:

Last updated

Was this helpful?