Skip to main content

c3g-oidc

The in-app OIDC client library C3G apps use for Tier 3b authentication — full per-app identity checks, for when oauth2-proxy's cookie-based gate doesn't serve every client (e.g. a CLI companion that has no browser to sit behind a proxy). See web-app-template's for-app-developers.md and README.md for where this fits among the authentication/authorization tiers.

Two independent halves, installable and importable separately:

  • c3g_oidc.server — validates a Bearer token inside a Flask app (signature, expiry, issuer, audience — via joserfc, Authlib's JOSE library) and exposes its groups claim, so c3g-flask-opa can use it as a groups source for authorization decisions.
  • c3g_oidc.client — no Flask dependency. What a CLI companion (like pt_cli) uses to log in via the OIDC device-code flow (RFC 8628), cache the resulting token, and refresh it automatically without a browser.

Status: working, and verified for real — not a mocked-out stub. server's test suite signs real RSA-backed JWTs and validates them against a real HTTP-served JWKS, proving signature/issuer/audience/expiry checks and JWKS caching all work; client's test suite runs the device-code flow (including authorization_pending, slow_down, access_denied, expiry, caching, and refresh) against a real mock authorization server. See CLAUDE.md for how to run either yourself.

Pre-1.0: the API may change between minor versions until a first app has adopted it.

Install

pip install c3g-oidc            # client half only
pip install "c3g-oidc[server]"  # + Flask/joserfc server half

Usage

Server half (inside a Flask app)

from flask import g, request
from c3g_oidc.server import BearerTokenValidator

validator = BearerTokenValidator(
    issuer_url="https://comanage.example/oidc",
    audience="my-app",
)

@app.before_request
def load_groups():
    token = request.headers.get("Authorization", "").removeprefix("Bearer ")
    g.groups = validator.validate(token)  # raises TokenValidationError on anything invalid

g.groups is then what you pass as the groups-source callable to c3g-flask-opa.

Client half (inside a CLI)

from c3g_oidc.client import DeviceCodeSession

session = DeviceCodeSession(
    issuer_url="https://comanage.example/oidc",
    client_id="pt-cli",
    token_cache_path="~/.cache/pt_cli/token.json",
)

token = session.get_access_token()  # interactive device-code login on first use,
                                     # silent cache/refresh on every call after that

Metadata

Release files for c3g-oidc 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for c3g-oidc 0.1.0
File Size Uploaded Provenance
c3g_oidc-0.1.0.tar.gz 23.6 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for c3g-oidc 0.1.0
File Interpreter ABI Platform
c3g_oidc-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 46.0 kB

Release files / c3g_oidc-0.1.0.tar.gz

Download URL c3g_oidc-0.1.0.tar.gz
Size 23.6 kB
Tags Source
SHA-256 checksum
How to use checksums
efa9d11d91a18a07fc7a567b0c5a3ebc702d7a2cc7de75c898a9ecc55a2c5439
BLAKE2b-256 checksum
How to use checksums
74dbe5d0bf342064f420f9924ee86b5ab286ef2a217c9382839a369c4b3dfba4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Release files / c3g_oidc-0.1.0-py3-none-any.whl

Download URL c3g_oidc-0.1.0-py3-none-any.whl
Size 22.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
09922f83a62a2af9240ab6ea4556373096c1c610b45c603a401bf2219c5c9be1
BLAKE2b-256 checksum
How to use checksums
808b761bf0837fab27d3d7f7e27a1469cad4c531befdd55e359b81346e9a84cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

Security for c3g-oidc 0.1.0

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for c3g_oidc-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page