cloud-wallet-account-service

command module
v1.0.8-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

XFSC Cloud Wallet Account Service

Goa-based replacement for the legacy Gin gateway. Retrieval, verification, storage, backup, devices and plugin APIs are not implemented here.

Build

Go 1.24+, PostgreSQL 16 and NATS. Run make build or make test. Goa generates gen/ and OpenAPI from design/design.go. Generated files and root go.sum are not included because dependency downloads were unavailable during preparation. docker compose up --build provides a local environment. CloudEvent Provider v0.1.5 is a regular module dependency. The supplied NATS Message Library snapshot remains a local replacement. Run go mod tidy before building. The history method is named historyEndpoint and its result type HistoryEntry to avoid Goa naming collisions. Regenerate gen/ before building. The upstream library API and build could not be verified offline.

API

All requests require trusted X-Tenant-ID and X-Account-ID (Keycloak sub). Envoy must validate JWT and overwrite both headers. No shared secret is used; both HTTP and gRPC ports must remain private and accessible only to trusted cluster workloads.

Method Path Response
GET /api/account id, firstName, lastName, email
GET /api/configuration/user language, historyLimit
PUT /api/configuration/language updated settings; body {"language":"en"}
PUT /api/configuration/user updated settings; body {"language":"en","historyLimit":50}
GET /api/history array of id, type, event, timestamp

Unknown account returns 404. Settings default to de/50; history is newest first and limited by settings. History writes are internal NATS events, not browser operations. History supports basic receipts only, not the optional credential/disclosure metadata from the wallet mock. No deep-link dispatcher is included in this scope.

Identity events

The supplied Keycloak listener publishes structured CloudEvents on tenant.management.identity.user.created and .deleted, source urn:xfsc:keycloak, data realmId, userId, optional email. This service additionally accepts optional firstName and lastName; the supplied listener does not publish them, so they remain empty until the producer is extended. It only emits REGISTER and DELETE_ACCOUNT, not admin creation or profile updates. Existing users need a separate backfill. A duplicate event ID is ignored; deleted subjects are tombstoned to prevent stale create events from resurrecting them. Deletion cascades to settings/history. Core NATS is best effort: offline events are lost; production requires durable JetStream consumers and producer reliability or reconciliation. Restrict publish permissions to trusted producers.

Database

Startup applies embedded versioned SQL transactionally with an advisory lock. New schema wallet_account avoids overwriting the old accounts schema. No legacy data import is performed. Down migration is destructive and intended only for controlled manual rollback; remove version 1 from public.xfsc_account_migrations in the same rollback transaction. The consolidated initial migration requires a fresh database; account IDs are globally unique, with tenant-scoped foreign keys. The ID is the Keycloak subject, assumed equal to listener userId (no pairwise subject mapper).

Verification status

Source was formatted with gofmt. Dependency resolution, Goa generation, compilation and integration tests could not be run in the offline environment. Generated method/type names and transport signatures must be checked by running make build. Old Helm, plugin Docker build and CI workflows are deliberately not carried over because they target the removed architecture. Compose is a development example, not production deployment.

Kubernetes operator deployment

The chart in deployment/helm uses the XFSC operator's independent workload injection and ResourceClaim flows. Configure provider names explicitly if multiple providers match. The claim ExternalSecrets must exist (or be generated by the selected provider) and resolve to the same credentials used by workload injection. The inspected operator requires external-secrets.io/v1, one remote key per claim ExternalSecret, and Secret keys username (or user) and password. The provider's externalSecret outputs must therefore use those keys as well, using a separate claim ExternalSecret if the injected Secret uses environment names as keys. Verify this against your provider configuration before deploying.

Environment Source
POSTGRES_HOST, POSTGRES_PORT, POSTGRES_SSLMODE PostgreSQL provider outputs
POSTGRES_USER, POSTGRES_PASSWORD PostgreSQL credential injection
POSTGRES_DATABASE Helm release name with hyphens replaced by underscores
NATS_URL NATS provider output
NATS_USERNAME, NATS_PASSWORD NATS credential injection

DATABASE_URL takes precedence over individual PostgreSQL variables for local Compose compatibility. PostgreSQL SSL defaults to require; explicitly configure disable only for trusted development environments. No environment prefix is applied. No environment replacements are used. Go reads the provider output names directly. The operator does not define fixed output names: configure ResourceProvider outputs.env, outputs.config[].env and outputs.externalSecrets[].data[].envName to match the table above. The username names follow the previous chart’s assumed provider output names; confirm them against the deployed ResourceProviders. Do not inject POSTGRES_DATABASE as well as setting it in Helm. NATS credentials are optional for local development; set both for authenticated deployments.

The NATS claim must use the same account as the event publishers, or an account with configured imports. Creating a separate NATS account does not automatically expose events. The inspected operator's NATS backend uses nsc; verify its user/password provisioning and server resolver deployment independently. The chart does not create credentials or grant cross-account access. TCP probes only check that the listener has started, not ongoing database/NATS readiness. Provisioning and injection are asynchronous; startup failures are retried by Kubernetes. The existing service still uses Core NATS; JetStream is not implemented.

PostgreSQL provisioning

With podAnnotations.inject.xfsc.io/enabled set to the string "true", the chart creates both a PostgreSQL ResourceClaim and an ExternalSecret named <release>-postgres-credentials. The latter reads username and password from ocm-wstack/system/postgres using the namespaced openbao SecretStore. The claim references this secret and provisions the release-derived database (hyphens replaced by underscores), with schema public and no extensions. The deployment sets POSTGRES_DATABASE to the same name. The existing Go code reads it directly. The service migration also creates its own wallet_account schema; the runtime database role must have permission to create that schema. NATS claim configuration is unchanged and still requires its own external secret. No environment replacements are used. Helm rendering and cluster provisioning have not been tested.

Experimental account key generation

Set CRYPTO_GRPC_ADDR, CRYPTO_ENGINE, and KEY_ROTATION_INTERVAL (default 720h) using Helm extraEnv. The worker reconciles accounts every minute, including pre-existing accounts, and creates separate signing (P-256) and encryption (RSA-2048) generations. It retains old provider keys. PostgreSQL migration 1 stores successful generations; advisory locks serialize provisioning per account. Do not enable provider-internal automatic rotation for these keys. The provider connection currently uses plaintext gRPC and must be restricted to a trusted internal network. Credential binding resolution is not implemented; do not enable presentation routing on its basis. No build verification was possible with the installed Go 1.23 toolchain.

Tenant-derived crypto namespace

The Keycloak identity CloudEvent maps data.realmId to the canonical tenant ID at the messaging boundary. Internally only tenant_id is stored and used as the crypto namespace. Use a fresh database; existing schemas require a separately planned migration.

Envoy external authorization (v3 gRPC)

Set EXT_AUTH_ADDR=:9000 (Helm extAuth.enabled/port). The internal gateway must overwrite x-tenant-id and x-account-id after JWT validation. Restrict access to the gRPC port using network policy or equivalent. Use fail-closed ext_authz and run before path rewrite. The current signing key is returned only for DELETE /api/offers/accept/{id}; this also covers deny requests on that route, which currently require a provisioned key. Other routes remove client-supplied key headers. Presentation binding resolution is not implemented here. Account identity is now (tenant_id,id); Keycloak realmId is translated at the messaging boundary, not stored separately. Run go mod tidy and go test ./... with a compatible Go toolchain before deployment.

External authorization: tenant_id must be provided in trusted Envoy contextExtensions, not in client headers. Upstream REST requests still require X-Tenant-ID.

CloudEvent Provider messaging

The account service subscribes through CloudEventProvider.SubCtx to identity events and retrieval.offering.publication. The latter projects retrieval.offering.received (offer stored, not credential issued) using RetrievalNotification.TenantId and GroupId. Storage commands are not completion events; verifier status lacks account identity and is not projected. No accounts.record subscription. Core NATS is non-durable. NATS_QUEUEGROUP defaults to wallet-account; NATS_REQUEST_TIMEOUT defaults to 10s.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
gen
internal
extauth
Package extauth implements Envoy's v3 external authorization protocol.
Package extauth implements Envoy's v3 external authorization protocol.
keys
Package keys provisions immutable key generations.
Package keys provisions immutable key generations.

Jump to

Keyboard shortcuts

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