iam

module
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2026 License: MIT

README


Headless, multi-tenant authentication — password & passwordless sign-in, MFA, OAuth social login, resumable auth flows, an OIDC provider and SAML/OIDC/SCIM federation, as a SaaS-shaped service (Project + Environment).


Docs Docs build Go PostgreSQL OpenAPI SDK

Documentation · Quickstart · Concepts · SDK · REST API · Self-hosting


IAM authenticates users and manages the identity lifecycle: sign-up/in, email & phone verification, MFA, sessions, and federation. One Go binary (cmd/iam) serves the runtime API, the project-admin API, the operator API, an OIDC provider, and an embedded admin panel, backed by PostgreSQL. The HTTP contract is the single source of truth — openapi/openapi.yaml (OpenAPI 3.1) — and both the Go server and the TypeScript SDK (@gopherex/iam-sdk) are generated from it.

Quickstart

Run the whole thing — server, embedded admin panel, migrations, a seeded Root project — with one command:

docker compose up

Open http://localhost:8080 and sign in with the master key dev.

More: Quickstart.

[!WARNING] The compose defaults (master key dev, a committed AES key) are for localhost only. For anything shared, set a real IAM_SERVICE_AUTH_ENCRYPTION_KEY (openssl rand -base64 32) and IAM_SERVICE_AUTH_MASTER_KEY — see Configuration.

What it gives you

  • Every sign-in method. Password, email/SMS OTP, magic link, WebAuthn passkeys, and OAuth social login — toggled per project.
  • Resumable auth flows. A server-side state machine drives signup / signin / recovery; the client holds only an opaque flow_token and survives reloads and cross-device continuation.
  • MFA & assurance levels. TOTP, SMS, email, WebAuthn and recovery codes, with AAL1/AAL2 step-up for sensitive operations.
  • Multi-tenant by design. Projects with isolated live / test / staging environments, each with its own config, signing keys and data.
  • OIDC provider + federation. Be an OIDC IdP for your apps, and connect upstream SAML / OIDC / SCIM identity providers.
  • Webhooks & blocking hooks. Async Standard-Webhooks notifications, plus fail-closed hooks that can veto an operation.
  • Sessions done right. Sliding refresh, reuse detection, device binding, and full session management.

Integrate

import { createIamClient } from '@gopherex/iam-sdk';

const iam = createIamClient({ baseUrl: 'https://auth.example.com', clientId: 'app_web' });

// resumable signup — email verification handled by the flow
await iam.flow.start({ kind: 'signup', email, password, name });
await iam.flow.verifyEmail({ code });        // → SIGNED_IN on completion

// or a direct password sign-in
const { data, error } = await iam.auth.signInWithPassword({ email, password });

Guides: SDK quickstart · Auth flows · Passwordless · MFA.

Layout

Path Purpose
openapi/openapi.yaml the HTTP contract (OpenAPI 3.1) — source of truth
cmd/iam the server (API + embedded admin SPA)
pkg/api hand-written API implementation over the generated server
pkg/sdk Go SDK (resource-server token verification)
internal/oas/ generated ogen code (wire types, server scaffolding)
internal/infrastructure/postgres/ Postgres store: pgx + pgtx + bob + sqld
ts/ TypeScript SDK (@gopherex/iam-sdk)
web/ admin panel SPA, embedded into the binary
website/ this documentation (Docusaurus) → GitHub Pages
deployments/ production Dockerfile
docs/rfc/ reference set of the standards IAM implements

Develop

make help          # list targets
make generate      # regenerate Go (ogen) + TS + DB store from the spec
make dev           # bring up dev infra (docker compose)
make run           # run the server
make test          # unit tests
make test-db       # integration tests (testcontainers; needs Docker)
make build         # build the binary with the embedded admin panel

Stack: Go 1.26, PostgreSQL 17, OpenAPI/ogen (contract-first), and the gopherex libraries (pgtx, sqld/bob, pg-outbox, xconf, xlog, xtrace).

Scope, honestly

IAM does authentication — who you are, and proving it. Authorization (ReBAC/permissions) is a separate concern and lives in its own service; groups and tenancy modelling belong there, not here. IAM issues and verifies the identity your authz layer builds on.

License

See LICENSE.

Directories

Path Synopsis
cmd
iam command
Command iam runs the IAM server: it loads configuration, connects to Postgres, applies migrations, assembles the ogen-generated HTTP API (pkg/api) over the Postgres adapters, exposes liveness/readiness probes, runs the transactional outbox relay, and shuts down gracefully on SIGINT/SIGTERM.
Command iam runs the IAM server: it loads configuration, connects to Postgres, applies migrations, assembles the ogen-generated HTTP API (pkg/api) over the Postgres adapters, exposes liveness/readiness probes, runs the transactional outbox relay, and shuts down gracefully on SIGINT/SIGTERM.
iam-bot command
iam-bot is the Telegram operator bot for IAM access requests: it pushes new pending requests to allowlisted operators and lets them approve/deny with inline buttons or mint invites, all through the IAM admin API.
iam-bot is the Telegram operator bot for IAM access requests: it pushes new pending requests to allowlisted operators and lets them approve/deny with inline buttons or mint invites, all through the IAM admin API.
internal
config
Package config holds the IAM service configuration, loaded from a config file (config.yaml, path via CONFIG_PATH) overlaid with environment variables and validated.
Package config holds the IAM service configuration, loaded from a config file (config.yaml, path via CONFIG_PATH) overlaid with environment variables and validated.
domain
Package domain holds the IAM domain model: aggregate roots and the command value-objects services pass to the aggregate ports.
Package domain holds the IAM domain model: aggregate roots and the command value-objects services pass to the aggregate ports.
iambot
Package iambot is the Telegram operator bot: it watches pending access requests through the IAM admin API and lets allowlisted Telegram users approve/deny them (or mint invites) without opening the admin panel.
Package iambot is the Telegram operator bot: it watches pending access requests through the IAM admin API and lets allowlisted Telegram users approve/deny them (or mint invites) without opening the admin panel.
infrastructure/postgres
Package postgres is the Postgres-backed persistence for IAM: a hand-written pgx + pgtx + bob layer following the komeet pattern — a single *pgxpool.Pool, a pgtx transaction manager (tx.Trm) services use to run repo calls inside an ambient transaction, a ctx-aware TxDB executor, and a bob pool for typed query building.
Package postgres is the Postgres-backed persistence for IAM: a hand-written pgx + pgtx + bob layer following the komeet pattern — a single *pgxpool.Pool, a pgtx transaction manager (tx.Trm) services use to run repo calls inside an ambient transaction, a ctx-aware TxDB executor, and a bob pool for typed query building.
oas
Code generated by ogen, DO NOT EDIT.
Code generated by ogen, DO NOT EDIT.
pkg
api
Package api is the IAM API implementation: the hand-written code that consumers import.
Package api is the IAM API implementation: the hand-written code that consumers import.
sdk
Package sdk is the ergonomic Go SDK for IAM resource servers.
Package sdk is the ergonomic Go SDK for IAM resource servers.
sdk/grpc
Package grpc contains IAM authentication interceptors for gRPC servers.
Package grpc contains IAM authentication interceptors for gRPC servers.
Package web serves the admin SPA.
Package web serves the admin SPA.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL