feat(keycloak): M4.3 — Admin API adapter + claim resolver
internal/keycloak Adapter (HTTPAdapter + Mock). POST /v1/tenants now provisions a KC organization + IT_ADMIN invite when admin_email is set; KC failures emit keycloak.provision_failed but don't roll back. POST /v1/internal/keycloak/claims resolves the current claim bundle for any (tenant_id|tenant_slug|user_attrs.*) lookup. Mock used in tests + when KEYCLOAK_ADMIN_URL is empty. HTTPAdapter tested against an in-process stub KC (httptest.Server). Refs: M4.3
This commit was merged in pull request #8.
This commit is contained in:
@@ -3,6 +3,7 @@ package config
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
@@ -10,6 +11,15 @@ type Config struct {
|
||||
Addr string // listen address, e.g. ":8090"
|
||||
KeycloakIssuer string // e.g. http://localhost:8080/realms/breakpilot-dev
|
||||
DatabaseURL string // postgres DSN (unused in skeleton; in-memory store)
|
||||
|
||||
// Keycloak Admin API — only used if KeycloakAdminURL is set. Empty
|
||||
// values disable the adapter and tenant-registry falls back to the
|
||||
// Mock (dev convenience).
|
||||
KeycloakAdminURL string
|
||||
KeycloakRealm string
|
||||
KeycloakClientID string
|
||||
KeycloakClientSecret string
|
||||
KeycloakTimeout time.Duration
|
||||
}
|
||||
|
||||
func Load() (*Config, error) {
|
||||
@@ -23,6 +33,12 @@ func Load() (*Config, error) {
|
||||
Addr: getenv("ADDR", ":8090"),
|
||||
KeycloakIssuer: getenv("KEYCLOAK_ISSUER", "http://localhost:8080/realms/breakpilot-dev"),
|
||||
DatabaseURL: os.Getenv("DATABASE_URL"),
|
||||
|
||||
KeycloakAdminURL: os.Getenv("KEYCLOAK_ADMIN_URL"),
|
||||
KeycloakRealm: getenv("KEYCLOAK_REALM", "breakpilot-dev"),
|
||||
KeycloakClientID: os.Getenv("KEYCLOAK_CLIENT_ID"),
|
||||
KeycloakClientSecret: os.Getenv("KEYCLOAK_CLIENT_SECRET"),
|
||||
KeycloakTimeout: 10 * time.Second,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user