Skip to main content
Glama
passmint
by unrealJune
README.md
# Passmint

Mint signed Apple Wallet passes (`.pkpass`) for friends. One container serves:

- **Web UI** (React + Fluent UI 9): design a pass field by field with a live preview, upload art,
  mint, and share a QR code or link that opens "Add to Apple Wallet" on an iPhone.
- **REST API** at `/api/v1`, with personal API tokens.
- **MCP server** at `/mcp` (Streamable HTTP) with OAuth 2.1, so Claude and other agents can make
  passes on a user's behalf.

Sign-in is Authentik (any OIDC provider works). The Apple Pass Type ID certificate stays on the
server, so nobody else needs it.

## Two ways to make a pass

|                | Simple                                                                   | Prepared ("stamp")                                                                                                                    |
| -------------- | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------- |
| Input          | images + a `PassSpec` (style, colors, fields, barcode, locations, dates) | your own `pass.json` + files, as a zip, an existing `.pkpass`, or `pass_json` + image asset ids                                       |
| Images         | one large image per slot; resized to @1x/@2x/@3x                         | used byte for byte                                                                                                                    |
| Server changes | writes all of `pass.json`                                                | replaces `passTypeIdentifier`/`teamIdentifier`, drops `webServiceURL`/`authenticationToken`, rebuilds `manifest.json` and `signature` |

## MCP tools

| Tool          | Does                                                                         |
| ------------- | ---------------------------------------------------------------------------- |
| `upload_file` | returns a single-use `curl` command (or takes `data_base64` for small files) |
| `list_assets` | your uploads                                                                 |
| `save_pass`   | create or replace a design from a PassSpec                                   |
| `list_passes` | designs; with `pass_id`, its spec and signed copies with fresh links         |
| `mint_pass`   | sign a design → `download_url`                                               |
| `stamp_pass`  | sign a bundle zip, or `pass_json` + `files`                                  |
| `delete`      | remove an asset, design or signed copy                                       |

Connect: `claude mcp add --transport http passmint https://pass.example.com/mcp`, or add
the same URL as a custom connector in Claude. The first call opens an Authentik login and a
Passmint approval screen.

### How MCP auth works

MCP clients need dynamic client registration, which Authentik does not offer, so Passmint is
its own small OAuth authorization server (`/register`, `/authorize`, `/token`, `/revoke`, plus
RFC 8414/9728 metadata). `/authorize` sends the user to a consent page that requires a normal
Passmint web session, and that session only comes from an Authentik login. Access tokens last an
hour; refresh tokens 30 days and rotate on use.

Uploads go out of band: `upload_file` reserves an asset and returns an HMAC-signed `PUT` URL
that accepts one file and expires after 15 minutes.

## Configuration

| Variable                                                               |                                                                       |
| ---------------------------------------------------------------------- | --------------------------------------------------------------------- |
| `PUBLIC_URL`                                                           | e.g. `https://pass.example.com`                                       |
| `SECRET_KEY`                                                           | cookie and link signing; 32+ random bytes                             |
| `DATABASE_URL`                                                         | Postgres; empty uses embedded PGlite in `DATA_DIR`                    |
| `DATA_DIR`                                                             | file storage (`$DATA_DIR/blobs`) when S3 is not configured            |
| `S3_BUCKET`, `S3_ENDPOINT`, `S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY` | optional S3 storage                                                   |
| `OIDC_ISSUER`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET`                  | Authentik provider                                                    |
| `OIDC_ALLOWED_GROUPS`                                                  | comma-separated; users must be in one (the `groups` claim)            |
| `APPLE_TEAM_ID`, `APPLE_PASS_TYPE_ID`                                  | from the Apple developer account                                      |
| `SIGNER_P12_PATH`, `SIGNER_P12_PASSWORD`                               | the Pass Type ID cert + key (or `SIGNER_CERT_PATH`/`SIGNER_KEY_PATH`) |
| `WWDR_CERT_PATH`                                                       | Apple WWDR G4, bundled at `certs/AppleWWDRCAG4.pem`                   |
| `DOWNLOAD_TTL_SECONDS`                                                 | download link lifetime, default 7 days                                |

Any secret variable can also be given as `NAME_FILE` pointing at a mounted file.

## Getting the Apple certificate

1. developer.apple.com → Certificates, IDs & Profiles → Identifiers → **+** → Pass Type IDs →
   e.g. `pass.com.example.passmint`.
2. Keychain Access → Certificate Assistant → _Request a Certificate From a Certificate
   Authority_ → save the CSR. On the Pass Type ID, _Create Certificate_ and upload it.
3. Download the `.cer`, double-click it, then in Keychain → My Certificates right-click
   "Pass Type ID: …" → _Export_ as `.p12` with a password.
4. Put it in a Kubernetes secret with keys `signer.p12` and `password`:
   `kubectl -n passmint create secret generic passmint-signer --from-file=signer.p12=passmint.p12 --from-literal=password=…`,
   or for a GitOps repo, `scripts/seal-signer.sh passmint.p12 path/to/signer-secret.yaml` writes a
   SOPS-encrypted one (it prompts for the password).

## Development

```bash
mise install && npm ci
npx tsx scripts/dev-stack.ts   # mock OIDC login + throwaway cert on :8080
npm run dev:web                # optional: Vite with hot reload on :5173, proxied to :8080
npm test                       # signing (verified with openssl), REST, OAuth + MCP end to end
```

Passes signed by the dev stack's throwaway certificate are structurally valid but Wallet will
not accept them; only the real Pass Type ID certificate makes installable passes.

## Deploying

Each push to `main` that passes CI is released automatically (see `.github/workflows/release.yml`):
a semver tag picked from Conventional Commit subjects (`feat:` minor, `feat!:` major, anything else
patch), a multi-arch image and a Helm chart with the same version:

```bash
helm install passmint oci://ghcr.io/unrealjune/charts/passmint --version <version> \
  --namespace passmint --create-namespace \
  --set publicUrl=https://pass.example.com \
  --set oidc.issuer=https://auth.example.com/application/o/passmint/ \
  --set oidc.clientId=<client id> --set 'oidc.allowedGroups={passmint-users}' \
  --set apple.teamId=<team id> --set apple.passTypeId=pass.com.example.passmint \
  --set ingress.enabled=true --set ingress.host=pass.example.com
```

The chart expects two secrets you create yourself: `passmint-secrets` (`secret-key`,
`oidc-client-secret`, optional `database-url`) and `passmint-signer` (`signer.p12`, `password`).
See `chart/passmint/values.yaml`. Run one replica; it keeps files on a ReadWriteOnce volume.

With Flux, point an `ImagePolicy` at `ghcr.io/unrealjune/passmint` (semver) and let
`ImageUpdateAutomation` bump the HelmRelease's chart version; image and chart versions always match.

In the OIDC provider, register `https://<host>/auth/callback` as the redirect URI, request the
`openid profile email` scopes, and include a `groups` claim if you use `oidc.allowedGroups`.

Dependabot checks for updates daily. `dependabot-merge.yml` merges a PR once CI passes: minor and
patch updates right away, major ones after 48 hours open (label a PR `hold` to keep it), and then
starts a release, so every update ships and deploys on its own.

## License

[AGPL-3.0](LICENSE). If you run a modified Passmint as a network service, offer its users the
modified source.