feat(serviceadapter): enforce JWT auth on X-Service dispatch
CI / CI (pull_request) Successful in 3m36s
CI / CI (pull_request) Successful in 3m36s
Replace hardcoded SQS-only validator (pointed at non-existent sqs provider JWKS) with shared multi-issuer validator from proxy. Auth-required adapters now validate JWT and check capability (<service>:read for GET, <service>:write for POST). Identity headers injected on success. Auth-optional adapters unchanged. 10 new tests, 69% package coverage. Closes homelab#11 Co-authored-by: poimen <[email protected]>
This commit is contained in:
+8
-1
@@ -9,6 +9,7 @@ import (
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"forgejo.riotpiao.com/rock/homelab-frontend/internal/auth"
|
||||
"forgejo.riotpiao.com/rock/homelab-frontend/internal/config"
|
||||
"forgejo.riotpiao.com/rock/homelab-frontend/internal/proxy"
|
||||
"forgejo.riotpiao.com/rock/homelab-frontend/internal/server"
|
||||
@@ -75,7 +76,13 @@ func main() {
|
||||
_ = registry.Add(a)
|
||||
}
|
||||
log.Printf("%d service adapters loaded", registry.Count())
|
||||
dispatcher := serviceadapter.NewDispatcher(registry)
|
||||
|
||||
// Create shared JWT validator for X-Service auth enforcement
|
||||
var jwtValidator *auth.Validator
|
||||
if cfg.Auth.Enabled && cfg.Auth.JWKSURL != "" {
|
||||
jwtValidator = auth.NewValidator(cfg.Auth.Issuer, cfg.Auth.Audience, cfg.Auth.JWKSURL)
|
||||
}
|
||||
dispatcher := serviceadapter.NewDispatcher(registry, jwtValidator)
|
||||
|
||||
// Create router that handles health endpoints, X-Service (ServiceAdapter) routing,
|
||||
// temporal endpoints, and passes others to upstream handler
|
||||
|
||||
Reference in New Issue
Block a user