Skip to content

​Overview

Private Channels includes an optional Auth Service that gates gateway access with JWT authentication and role-based access control (RBAC). When authentication is disabled, the gateway accepts all connections. When enabled, clients must present a valid JWT in every request. This page covers both audiences:
  • Developers - registration, login, wallet verification, and making authenticated requests
  • Operators - enabling the auth service, configuring JWT_SECRET, and provisioning the operator role

​Enabling Auth

Authentication is enabled by setting JWT_SECRET (non-empty) on both the gateway and the Auth Service. The Auth Service also requires AUTH_DATABASE_URL. When JWT_SECRET is not set, the gateway operates in open mode; no token is required.
Docker Compose: The auth service is a Docker Compose profile and is not started by default. To include it, pass --profile auth to your docker compose command, including --env-file .env so secrets like JWT_SECRET and POSTGRES_PASSWORD actually resolve (Compose disables its automatic .env auto-load once any --env-file flag is passed):

​Auth Service API

All endpoints are under /auth. The auth service listens on AUTH_PORT (default 8903).

​POST /auth/register

Create a new account. All users are registered with the user role.
  • Username: 5-32 characters, alphanumeric plus _ and -
  • Password: 6-128 characters
  • Returns the created user; password is never returned

​POST /auth/login

Authenticate and receive a signed JWT valid for 24 hours.
Returns { "token": "<jwt>" }. Both wrong username and wrong password return 401 to prevent username enumeration.

​POST /auth/challenge-wallet

Request a signing challenge to prove ownership of a Solana wallet. Requires a valid JWT; the request has no body. Returns a message, nonce, and expiry. The challenge expires in 10 minutes. Sign the message exactly as returned; it names the user id and the nonce:

​POST /auth/verify-wallet

Submit the signed challenge to register a wallet as verified. Requires a valid JWT.
The service reconstructs the challenge message, verifies the Ed25519 signature, and stores the wallet. Each nonce can only be consumed once; replays are rejected with 400 invalid or expired challenge. Returns { "pubkey": "<base58>", "created_at": "<iso8601>" }.

​GET /auth/wallets

List all verified wallets for the authenticated user. Requires a valid JWT.

​DELETE /auth/wallets/{pubkey}

Remove a verified wallet from the authenticated user’s account. Requires a valid JWT. Returns 204 on success, or 400 wallet not associated with this user if the wallet is not attached to the user.

​GET /health

Liveness check. Returns 200 with an empty body. No authentication required.

​JWT Structure

Tokens use the HS256 algorithm and expire 24 hours after issue.
ClaimValue
subUser UUID
role"user" or "operator"
iss"private-channel-auth"
aud"private-channel-gateway"
expUnix timestamp (24h from issue)
iss and aud are present in the JWT payload but are validated by the gateway’s JWT configuration, not deserialized into the application claims struct. Application-layer code has access to sub, role, and exp only.
Pass the token in the Authorization header:

​Roles

​user

Default role on registration.
  • Access is gated to the user’s own verified wallets
  • Blocked from: getBlock, getTransaction, simulateTransaction
  • Can: call Deposit on the Escrow Program, initiate withdrawals via WithdrawFunds

​operator

Elevated role. Must be provisioned directly; there is no self-service path to escalate from user to operator. Grant the role with the Admin CLI (auth-admin, installed in the services’ Docker image). It reads the auth database URL from AUTH_DATABASE_URL and identifies users by username:
Direct SQL also works:
This is a privileged database operation. Restrict access to the Auth Service database accordingly and audit any role changes.
Register a wallet without the self-verify flow (Admin CLI, auth-admin, same environment variables as above):
This inserts a verified wallet directly into the verified_wallets table, bypassing the challenge/verify flow. Enforces a unique constraint on (user_id, pubkey). It does not grant the operator role by itself; use set-role or the SQL update above for that. This command is for attaching a wallet to an account (for example, a service account) without requiring the interactive challenge/verify flow. Capabilities:
  • Bypasses all wallet ownership checks
  • Full access to all gateway RPC methods, including getBlock, getTransaction, simulateTransaction
  • Required for: ReleaseFunds, ResetSmtRoot (RotateBitmap on upstream main)

​Full Authentication Flow

Full Authentication Flow diagramFull Authentication Flow diagram

​Making Authenticated Requests

Send the token with every gateway request. This example reads the balance of the user’s channel token account, which the user role may query because the account’s owner is one of the user’s verified wallets:
The channel’s RPC serves only the methods in the access matrix below. It has no getBalance, so read token balances with getTokenAccountBalance.

​Gateway Endpoints

These endpoints do not require authentication:
EndpointMethodDescriptionSuccessFailure
/healthGETLiveness check200 {"status":"ok"}-
/readyGETDeep readiness; probes write + read nodes200 {"status":"ready"}503 {"status":"degraded"}
For the JWT_SECRET and gateway environment variable reference, see the Configuration reference.

​RPC Method Access Matrix

The following methods are recognized by the gateway. When JWT_SECRET is set, access depends on JWT role:
MethodRouteNo JWTuseroperator
sendTransactionWrite node✓✓✓
getLatestBlockhashRead node✓✓✓
getSlotRead node✓✓✓
getRecentBlockhashRead node✓✓✓
getSignatureStatusesRead node✓✓✓
getTransactionCountRead node✓✓✓
getFirstAvailableBlockRead node✓✓✓
getBlocksRead node✓✓✓
getBlocksWithLimit²Read node✓✓✓
getBlockHeight²Read node✓✓✓
getEpochInfoRead node✓✓✓
getEpochScheduleRead node✓✓✓
getRecentPerformanceSamplesRead node✓✓✓
getBlockTimeRead node✓✓✓
getVoteAccountsRead node✓✓✓
getSupplyRead node✓✓✓
getSlotLeadersRead node✓✓✓
isBlockhashValidRead node✓✓✓
getAccountInfoRead node401ownership-gated¹✓
getTokenAccountBalanceRead node401ownership-gated¹✓
getSignaturesForAddressRead node401ownership-gated¹✓
getBlockRead node401403✓
getTransactionRead node401403✓
simulateTransactionRead node401403✓
¹ Ownership-gated: for an SPL Token account (owner field is TokenkegQ... or TokenzQ..., data of at least 165 bytes), the gateway checks that the owner or delegate field matches one of the authenticated user’s verified wallets. For any other account type (a System Program wallet, or an unknown PDA), it instead checks whether the queried pubkey itself is one of the user’s verified wallets, since such accounts have no owner/delegate field to inspect. Either check failing returns 403. ² Not served at commit c9e2240, the version these docs target; upstream main adds it.