Skip to content

Contributing to identity-model

Thank you for your interest in contributing! This repository is a polyglot monorepo containing three native OIDC/OAuth 2.0 client libraries — Python (py-identity-model plus the fastapi-identity-model middleware package), Go, and Rust — held to a single shared behavioral contract in spec/. This document covers the development workflow for all of them.

Code of Conduct

By participating in this project, you agree to maintain a respectful and inclusive environment for all contributors.

Getting Started

Prerequisites

  • Python 3.12 or higher and uv (Python library, docs, tooling)
  • Go (see go/go.mod for the required version) — only for Go changes
  • Rust (see rust/README.md for the MSRV) — only for Rust changes
  • Docker (integration-test identity providers and the conformance suite)
  • Git

Repository layout

identity-model/
├── py/           Python library + fastapi-identity-model package (uv, PyPI)
│   ├── src/py_identity_model/    library source
│   ├── src/tests/                unit / integration / security / benchmark tests
│   └── packages/fastapi-identity-model/
├── go/           Go library (module github.com/jamescrowley321/identity-model/go)
├── rust/         Rust library (crate rs-identity-model)
├── spec/         cross-language capability spec + conformance vectors
├── infra/        shared local identity-provider fixtures (docker compose)
├── conformance/  OpenID Foundation conformance-suite harness
├── docs/         mkdocs documentation site
└── Makefile      wraps the common flows for every language

Development Setup

  1. Fork and clone the repository

    git clone https://github.com/YOUR_USERNAME/identity-model.git
    cd identity-model
    

  2. Install uv (if not already installed)

    curl -LsSf https://astral.sh/uv/install.sh | sh
    

  3. Install Python dependencies (both packages)

    cd py && uv sync --all-packages && cd ..
    

  4. Install pre-commit hooks

    uv run --project py pre-commit install
    

Development Workflow

Code Style and Conventions

  • Python: Ruff for linting and formatting (line length 88), pyrefly for type checking. All code must include comprehensive type hints and Google-style docstrings for public classes and functions. Imports are sorted by Ruff.
  • Go: gofmt, go vet, and golangci-lint (config in go/.golangci.yml).
  • Rust: cargo fmt and cargo clippy -- -D warnings.

Running Tests

All targets run from the repository root; make help lists everything.

Python — full suite (unit + integration) with the coverage gate:

make test

Python — unit tests only:

make test-unit

Python — integration tests against a specific provider (Docker fixtures are started automatically where needed):

make test-integration-node-oidc   # node-oidc-provider (local Docker)
make test-integration-keycloak    # Keycloak (local Docker)
make test-integration-local       # your own provider via .env.local
make test-integration-ory         # Ory
make test-integration-descope     # Descope

Go and Rust:

make lint-go                # vet + golangci-lint
make test-unit-go           # race-enabled Go unit tests
make test-integration-go    # Go integration suite against the shared fixtures
make lint-rust              # rustfmt + clippy
make test-unit-rust         # Rust unit tests
make test-integration-rust  # Rust live integration suite

Cross-language conformance: each language's unit suite runs the shared vectors in spec/vectors/ (make test-unit, cd go && go test ./..., cd rust && cargo test) and fails if any case is not executed.

Run specific Python tests (from py/):

uv run pytest src/tests/unit/test_discovery.py -v
uv run pytest src/tests/unit/test_discovery.py::test_specific_function -v

Code Formatting and Linting

Run all pre-commit checks (lint + unit tests for Python, Go and Rust):

make lint

Pre-commit Hooks

Pre-commit hooks run automatically when you commit. Each language hook is a make target and runs only when files in its language changed: - Python: ruff lint + format and pyrefly (make lint-py); unit tests for both packages (make test-unit, make test-fastapi) - Go: vet + golangci-lint (make lint-go); unit tests (make test-unit-go) - Rust: rustfmt + clippy (make lint-rust); unit tests (make test-unit-rust) - GitHub workflows: actionlint (+ shellcheck on run: blocks) via .github/scripts/lint_workflows.sh, when .github/workflows/ changed

If pre-commit fails, fix the issues and commit again.

Making Changes

Branch Naming

Use descriptive branch names with prefixes: - feat/ - New features (e.g., feat/add-token-introspection) - fix/ - Bug fixes (e.g., fix/token-validation-bug) - docs/ - Documentation changes (e.g., docs/update-readme) - refactor/ - Code refactoring (e.g., refactor/base-classes) - test/ - Test improvements (e.g., test/add-integration-tests) - chore/ - Maintenance tasks (e.g., chore/update-dependencies)

Commit Messages

Follow the Conventional Commits specification:

<type>(<scope>): <description>

[optional body]

[optional footer]

Types: - feat: New feature - fix: Bug fix - docs: Documentation changes - refactor: Code refactoring - test: Test changes - chore: Maintenance tasks - ci: CI/CD changes - perf: Performance improvements - style: Code style changes (formatting, etc.)

Examples:

feat(token): add token introspection endpoint support

fix(validation): handle missing kid in JWT header

docs(readme): add examples for token validation

test(discovery): add integration tests for discovery endpoint

PRs are squash-merged, and the PR title becomes the commit message that drives Python releases — so the title itself must be a valid conventional commit line. A feat:/fix: title cuts a new PyPI release when it merges; use docs:, test:, ci:, or chore: for changes that should not. Releases are routed by scope, not by path: a title scoped (fastapi), (go), (rust), (node), (spec), (infra), (conformance), (tools) or (ci) never bumps py-identity-model (tools/release_parsers.py), so scope every change that belongs to another release track.

Pull Request Process

  1. Create a feature branch from main

    git checkout -b feat/your-feature-name
    

  2. Make your changes following the code style guidelines

  3. Write or update tests to cover your changes

  4. Unit tests for new functionality
  5. Integration tests proving the behavior against a real provider
  6. Shared spec/ vectors when the change affects cross-language behavior

  7. Update documentation if needed

  8. Update the docs site (docs/) and per-language READMEs for new features
  9. Update docstrings for changed functions/classes
  10. Add examples if appropriate

  11. Run tests and linting

    make test
    make lint
    

  12. Commit your changes with clear commit messages

  13. Push to your fork

    git push origin feat/your-feature-name
    

  14. Create a Pull Request on GitHub

  15. Use a conventional-commit title (it becomes the squash commit)
  16. Reference related issues (e.g., "Closes #123")
  17. Describe what changes you made and why
  18. Include examples if adding new features

Pull Request Guidelines

  • Keep PRs focused: One feature or fix per PR
  • Write clear descriptions: Explain what and why, not just how
  • Include tests: All new code should have tests
  • Update documentation: Keep docs in sync with code changes
  • Follow the style guide: Use Ruff for consistent formatting
  • Be responsive: Address review feedback promptly

Testing Requirements

Test Coverage

  • The Python suite enforces a minimum 80% coverage gate (make test fails below it)
  • All new features must include tests
  • Bug fixes should include regression tests
  • Behavioral claims need integration tests against a real provider — green unit tests alone are not sufficient for protocol behavior

Test Types

  1. Unit Tests: Test individual functions and classes
  2. Integration Tests: Test complete flows against real identity providers (the shared fixtures in infra/, or live providers)
  3. Conformance Tests: The shared spec/ vectors (all languages) and the OpenID Foundation conformance suite (conformance/)

Writing Tests

Use pytest and follow these conventions:

import pytest
from py_identity_model import DiscoveryDocumentRequest, get_discovery_document


def test_discovery_document_success():
    """Test successful discovery document retrieval."""
    request = DiscoveryDocumentRequest(address="https://example.com/.well-known/openid-configuration")
    response = get_discovery_document(request)

    assert response.is_successful
    assert response.issuer is not None


def test_discovery_document_invalid_url():
    """Test discovery document with invalid URL."""
    request = DiscoveryDocumentRequest(address="invalid-url")
    response = get_discovery_document(request)

    assert not response.is_successful
    assert response.error is not None

Documentation

Docstring Format

Use Google-style docstrings:

def validate_token(jwt: str, token_validation_config: TokenValidationConfig, disco_doc_address: str) -> dict:
    """Validate a JWT token against the provided configuration.

    Args:
        jwt: The JWT token string to validate.
        token_validation_config: Configuration for token validation.
        disco_doc_address: Address of the OpenID Connect discovery document.

    Returns:
        Dictionary containing the validated JWT claims.

    Raises:
        PyIdentityModelException: If token validation fails.

    Examples:
        >>> config = TokenValidationConfig(perform_disco=True, audience="my-api")
        >>> claims = validate_token(token, config, "https://auth.example.com")
        >>> print(claims["sub"])
    """
    # Implementation

Building Documentation

Build the documentation locally:

make docs-serve

Then visit http://127.0.0.1:8000 to view the docs. make docs-build runs the same strict build CI uses.

Release Process

Each language releases on its own cadence. Version numbers follow Semantic Versioning.

Python (py-identity-model on PyPI)

Releases are automated with semantic-release. When commits land on main, it analyzes the (squash) commit messages to determine the version bump, updates py/pyproject.toml and py/CHANGELOG.md, pushes a py-v{version} tag, and the tag triggers publishing to PyPI.

Go (github.com/jamescrowley321/identity-model/go)

A Go release is a go/vX.Y.Z tag — the subdirectory-module format go get requires. semantic-release creates the tag automatically from (go)-scoped feat/fix commits on main; the pushed tag verifies the library and cuts a GitHub Release.

Rust (rs-identity-model on crates.io)

A Rust release is a rust-vX.Y.Z tag matching the version in rust/Cargo.toml. semantic-release bumps rust/Cargo.toml and creates the tag automatically from (rust)-scoped feat/fix commits on main; the pushed tag publishes the crate to crates.io and cuts a GitHub Release.

Pre-releases

Every pull request opened from a branch of this repository (not from a fork) automatically gets a GitHub pre-release build of the Python package (an -rc version tied to the PR), with install instructions posted as a PR comment — useful for testing a change in a real environment before it merges. See the Pre-release Testing Guide for details.

Roadmap

See the project roadmap and GitHub issues for planned features and current priorities.

Getting Help

  • Issues: Open an issue for bugs or feature requests
  • Discussions: Use GitHub Discussions for questions and ideas
  • Documentation: Check the docs

Recognition

Contributors will be recognized in the project documentation and release notes. Thank you for helping make identity-model better!

License

By contributing to identity-model, you agree that your contributions will be licensed under the Apache License 2.0.

AI-Assisted Contributions

Contributions that use AI tools (GitHub Copilot, Claude Code, ChatGPT, Cursor, the Ralph loop, pi, etc.) are welcome. We apply the same quality standards to all contributions regardless of how they were authored.

Requirements for AI-assisted PRs

  • All CI checks must pass — lint, tests, security scans. No exceptions.
  • Audit disclosure is required. Every AI-assisted PR must record, in the PR description's AI provenance block, the harness/agent(s) and the model(s) used to produce the change (for example: harness Claude Code, model claude-opus-4-8; or harness ralph-orchestrator + pi, model z-ai/glm-5.2).
  • The submitter is responsible for the correctness, security, and quality of the code regardless of whether it was AI-generated.
  • Advisory-only AI. AI output — including automated review — is advisory. A green check is not sign-off.

Requesting a review from Claude

Comment @claude review this PR on a pull request and Claude runs this project's own blind-peer-review lenses against the diff — one fresh reviewer per lens (Cold Read, Edge Cases, Acceptance Criteria, Security Review, Red Team), adjudicated fail-closed into a PASS/BLOCK verdict. It is the same lens library the maintainers run locally, so CI and the laptop do not drift apart.

It also runs automatically, once, when a maintainer's (OWNER, MEMBER or COLLABORATOR) non-draft pull request is opened or marked ready for review. Pull requests from anyone else are only reviewed when a maintainer asks.

Only maintainers can trigger it. The workflow runs with repository secrets on a public repo, so the job's if: requires the commenter's author_association to be OWNER, MEMBER or COLLABORATOR. GitHub evaluates that before scheduling anything, so a mention from anyone else never starts a job at all — it is not merely rejected after the fact. (claude-code-action also requires write access and refuses bots, but that check runs inside the action, once the job is already running.)

Outside contributors therefore cannot request a review themselves, and GitHub offers no "approve this run" prompt for comment-triggered workflows the way it does for pull requests from forks. Ask a maintainer to comment @claude review this PR on your pull request — a maintainer asking is the approval.

The verdict is advice, not sign-off. Two limitations, stated plainly because a clean PASS is exactly when they matter most:

  • The lenses run as subagents of one session. Each starts from a clean context, but they share a process, a model and a host — weaker than the upstream CI adapter, which runs one job per lens. Upstream measured that batching lenses into a single agent's context turned a MUST FIX finding into a clean PASS.
  • Claude reviews code that Claude often helped write, so the reviewer shares the author's blind spots. Every run prints this caveat; leave it in the posted findings rather than trimming it.

Both are why a lens verdict is not a required check here, and why the Advisory-only AI rule above still governs: a named human attests, not a bot.

What we look for

  • No hallucinated APIs, invented SDK methods, or fabricated citations.
  • Tests actually run and cover the new functionality.
  • Documentation is accurate and complete.