feat(api-keys): CI licences by API key and integration keys
Step 1b of ADR 0001, with the user's decisions D1–D3 recorded: - POST /v1/licences/ci (PUBLIC_EXPLICIT, the bearer is a tenant API key with scope <product>:licence): 24 h licence with kind "ci", no heartbeat, not a seat (D1; the registry records ci.licence usage once per key and day). Reused per key, device and UTC day; at most 60 calls per key and hour. Unblocks firmwerk#64 step 1. - Werkpilot CI licences carry the tenant's LiteLLM key (D2) with a 1-day LiteLLM expiry; the secret is sealed on the licence row (AES-256-GCM, new SECRETS_ENCRYPTION_KEY, migration 0017) so the reused licence hands out the same key. At most 10 keys per API key and day. Without the encryption key a reuse comes without the key. - Integration keys: a tenant admin's user token from a holder product's web client (werkmeister-<env>) creates, lists and revokes that holder's key for its own tenant only; scopes from a per-holder allowlist, the holder product must be booked. A user token on the key routes is classified as AUTHZ group api-keys.integration, so plain api-keys stays a service grant. - Migration 0016: key names are unique among active keys only, so a revoked name can be reused (re-issue = revoke, then create). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
97284b5008
commit
b89dd2ae4c
28 files changed
+1208
-39
No files matched your search
+11
-1
@@ -19,6 +19,7 @@ import (
|
||||
"git.breakpilot.com/platform/tenant-registry/internal/licence"
|
||||
"git.breakpilot.com/platform/tenant-registry/internal/llmkeys"
|
||||
"git.breakpilot.com/platform/tenant-registry/internal/product"
|
||||
"git.breakpilot.com/platform/tenant-registry/internal/secretbox"
|
||||
"git.breakpilot.com/platform/tenant-registry/internal/server"
|
||||
"git.breakpilot.com/platform/tenant-registry/internal/store"
|
||||
"git.breakpilot.com/platform/tenant-registry/migrations"
|
||||
@@ -126,6 +127,15 @@ func main() {
|
||||
slog.Info("licence signer configured", "kid", signer.KID(), "issuer", signer.Issuer())
|
||||
}
|
||||
|
||||
secrets, err := secretbox.New(cfg.SecretsEncryptionKey)
|
||||
if err != nil {
|
||||
slog.Error("secrets encryption key invalid", "err", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if !secrets.Enabled() {
|
||||
slog.Warn("SECRETS_ENCRYPTION_KEY not set — a reused Werkpilot CI licence cannot hand out its LiteLLM key again")
|
||||
}
|
||||
|
||||
// LiteLLM virtual keys for Werkpilot licences (D6).
|
||||
llmKeys := llmkeys.New(llmkeys.Config{BaseURL: cfg.LiteLLMBaseURL, MasterKey: cfg.LiteLLMMasterKey, Models: cfg.LiteLLMModels,
|
||||
BudgetTrial: cfg.LiteLLMBudgetTrial, BudgetDefault: cfg.LiteLLMBudgetDefault})
|
||||
@@ -157,7 +167,7 @@ func main() {
|
||||
if mc := (mail.Config{Host: cfg.SMTPHost, Port: cfg.SMTPPort, User: cfg.SMTPUser, Password: cfg.SMTPPassword, From: cfg.MailFrom, FromName: cfg.MailFromName}); mc.Configured() {
|
||||
mailer = &mail.SMTP{Cfg: mc}
|
||||
}
|
||||
app := &server.Server{Cfg: cfg, Log: logger, Store: s, Keycloak: kc, Auth: av, Authz: authz, Product: pv, ERP: erpClient, Licences: signer, LLMKeys: llmKeys, Objects: objects, Mail: mailer}
|
||||
app := &server.Server{Cfg: cfg, Log: logger, Store: s, Keycloak: kc, Auth: av, Authz: authz, Product: pv, ERP: erpClient, Licences: signer, LLMKeys: llmKeys, Secrets: secrets, Objects: objects, Mail: mailer}
|
||||
handler := server.NewRouter(app)
|
||||
srv := &http.Server{
|
||||
Addr: cfg.Addr,
|
||||
|
||||
Reference in new issue
Block a user