API reference (14)
| Export | Kind | Description |
|---|---|---|
| VerifyResult | type | — |
| verifySignature | function | — |
| verifyViewToken | function | — |
| ViewAdapter | interface | — |
| ViewEvent | interface | — |
| ViewEventResult | type | — |
| ViewKey | interface | — |
| ViewTokenClaims | interface | — |
| wireView | const | What the decoder needs from a manifest. */ |
| withLogSecrets | function | Runs fn with these values (tokens) never written to a log line; nested calls add to the outer values. */ |
@luxel-framework/postgres
Shared stores for several nodes.
| Export | Kind | Description |
|---|---|---|
| createPgRateLimiter | function | Token buckets shared by every node. One statement per take: the bucket is refilled for the time elapsed, capped at the capacity, and a token is taken only if one is there; the row lock of the upsert serialises concurrent takes of one key across nodes. / |
| createPgReplayGuard | function | Sprint 10 (ADR-046): spends a key once across every node. One statement per claim: the insert wins, or the existing row is replaced only when it has expired. Expired rows are swept now and then. The key is a hash of the token's nonce, never the token. / |
| createPgRevocationList | function | Sprint 11 (H-PROVENANCE, ADR-048): revoked builds, shared by every node. A row per digest; rows are never removed by the framework (a revoked build stays revoked). / |
| createPgSessionStore | function | — |
| PgPoolLike | interface | — |
| PgQueryable | interface | — |
| PgRateLimiterOptions | interface | — |
| PgReplayGuardOptions | interface | — |
| PgRevocationListOptions | interface | — |
| PgSessionStoreOptions | interface | — |
Example: Envoy Gateway (OIDC) with Keycloak, identity.mode: "gateway-jwt"
The token's iss is Keycloak's public address; luxel-host, inside the cluster, fetches the key set from Keycloak's service address over http. Keycloak access tokens carry aud: "account", so only azp (the client) is checked. Envoy Gateway forwards the access token as Authorization: Bearer … (forwardAccessToken). The guide Luxel behind a gateway explains each field.
The host names, the realm (development), the client (app-frontend-dev) and the service (keycloak.oauth) are placeholders: write your own issuer, realm, client and service in their place. What matters is the shape: authorizedParty and no audience; the issuer (a public https address) and the key set (an http address on a cluster service name, with jwksHttpInCluster: true) on different hosts; the token in Authorization. luxel build applies to these values the rules luxel-host applies at start, so a value the host would refuse is never written to luxel.config.json. This shape runs through a real Envoy (OAuth2 filter) and a real Keycloak in tests/identity/envoy.test.mjs, with the service name resolved by a test stub: not in a cluster.
luxel.config.ts:
import { defineConfig } from '@luxel-framework/compiler/config'; export default defineConfig({ // … server, variants, views, home … identity: { mode: 'gateway-jwt', issuer: 'https://idp.example.net/realms/development', authorizedParty: 'app-frontend-dev', jwksUrl: 'http://keycloak.oauth.svc.cluster.local:8080/realms/development/protocol/openid-connect/certs', jwksHttpInCluster: true, // an http jwksUrl in production: only a cluster service name tokenHeader: 'authorization', // the default; Envoy's forwardAccessToken signOutPath: '/oauth2/logout', // ‹Logout> ends the Luxel session, then goes to Envoy's logoutPath }, });
Envoy Gateway:
apiVersion: gateway.envoyproxy.io/v1alpha1 kind: SecurityPolicy metadata: name: app-oidc spec: targetRefs: - group: gateway.networking.k8s.io kind: HTTPRoute name: app oidc: provider: issuer: https://idp.example.net/realms/development clientID: app-frontend-dev clientSecret: name: app-oidc-client-secret redirectURL: https://app.example.net/oauth2/callback logoutPath: /oauth2/logout forwardAccessToken: true refreshToken: true
refreshToken: true: Envoy renews an expired access token itself (Envoy Gateway's default is false). The callback (redirectURL's path) and logoutPath must be matched by an HTTPRoute this policy covers (here app, with a / prefix match).
server/bindings.mjs (the session store and the mapping of the verified claims):
import { createDelegatedSessionStore, defineIdentityPrincipal, httpSessionDelegate } from '@luxel-framework/gateway'; export const sessionStore = createDelegatedSessionStore( httpSessionDelegate({ url: process.env.SESSION_BACKEND_URL, secret: process.env.SESSION_BACKEND_SECRET }), ); export const identityPrincipal = defineIdentityPrincipal((claims) => ({ userId: String(claims.sub), roles: ['user'], displayName: String(claims.email ?? '') }));
In a handler, the request's verified token (Session.identity; never put the token in state, a page, a URL or a log):
export const home = defineLoad(views.home, async (ctx) => { const { subject, email, token, claims } = ctx.session.identity ?? {}; // call your own backend with an Authorization: Bearer header holding `token`; claims.locale, claims.groups are given, not enforced … });