Security Model
Authorization is enforced in one place: glacez-soa-webservice. Everything else trusts its caller. That single fact explains almost every security question in the platform.
Authentication
| Component | Mechanism |
|---|---|
| Keycloak | identity provider, realm glacez, client glacez-app |
glacez-soa-webservice |
OAuth2 resource server (JWT), with httpBasic as a fallback for trusted tooling |
Vaadin webapps (ui, admin) |
OAuth2 clients — they hold the session and forward the token |
| other SOAs | none — cluster-internal HTTP, no filter chain, no token validation |
A token reaches webservice as a bearer token. The authorities come from resource_access.glacez-app.roles, mapped one-to-one with a ROLE_ prefix:
resource_access.glacez-app.roles: ["USER", "ADMIN"] → ROLE_USER, ROLE_ADMIN
The converter validates the whole path (resource_access → glacez-app → roles → string entries). A token issued for another client, carrying no roles, or carrying non-string roles is rejected as a 401, not a 500 — BadCredentialsException from the converter is caught by the bearer filter and turned into an authentication failure, whereas the unchecked exception of a direct cast answers 500.
Rejection means throwing. An empty authority list is not a refusal: anyRequest().authenticated() only needs a token, so a converter that degrades to zero authorities silently authenticates the caller. A test on the converter asserts on the ROLE_ prefix rather than the whole list — JwtAuthenticationConverter appends its own FACTOR_BEARER authority.
Roles in use today: USER, ADMIN.
Authorization
Webservice's filter chain is coarse: everything except /public/**, /actuator/**, /swagger-ui/** and /glacez-docs/** requires an authenticated caller. Method security is enabled (@EnableMethodSecurity(securedEnabled = true, jsr250Enabled = true)), so individual resources can add @Secured / @RolesAllowed.
Fine-grained rules are code-level, not declarative. The ownership check lives in GlacezResources:
checkAuthenticatedPermissions(username):
authenticated = preferred_username claim
allow if authenticated == username, or the caller holds ROLE_ADMIN
otherwise AccessDeniedException
and the REST paths carry the owner: /users/{username}/snapshots/portfolio, /users/{username}/....
Two consequences worth remembering:
- The URL is the authorization subject. Any endpoint that takes a
{username}path segment must callcheckAuthenticatedPermissions— an endpoint that forgets it is readable by every authenticated user. - A missing
preferred_usernameclaim is an unusable authentication (401), never the literal user"null". Do not reintroduce aString.valueOf(...)-style default there.
What each layer may assume
| Layer | Assumes | Must enforce |
|---|---|---|
| webapps | the token is valid; the backend re-checks | hide/disable UI for ROLE_USER / ROLE_ADMIN, nothing more |
| webservice | token is valid and claims are shaped as documented | ownership, role gates, input validation |
| other SOAs | the caller is webservice | nothing — but see the exposure below |
Because the six non-webservice SOAs have no security filter, any client that can reach their service port bypasses authorization entirely. That is why they are only exposed inside the cluster, and why "add a header check" is not how a permission is expressed in this platform — a permission goes in webservice.
Actuator
An actuator endpoint is reachable only when both halves agree, and they live in different files: management.endpoints.web.exposure.include decides what the endpoint layer publishes, the security chain decides who may call it. The six SOAs have no security layer at all, so for them the exposure list is the boundary; webservice adds its permit-all list on top.
Both are trimmed to what the platform reads:
| Half | State |
|---|---|
exposure.include |
health, prometheus only, in every service — chart probes and the ServiceMonitor scrape |
| webservice permit-all | /actuator/health, /actuator/health/**, /actuator/prometheus |
| health details | status code only — show-details is gone, so Mongo/Rabbit/disk state is no longer published anonymously |
So a new actuator endpoint needs a consumer before it is exposed, and the status code says which half is missing: 401 means a security layer refused it, 404 means nothing was exposed to refuse.
Known exposures (in-cluster, deliberate or pending)
- The webapps' dev profiles carry a Keycloak client secret in
application-dev.yml; rotation is tracked inglacez-webapp-adminbacklog. Never copy such a value into a wiki page, a ticket, or a test fixture.
Rules for new code
- A new endpoint under
/users/{username}/...callscheckAuthenticatedPermissions. No exceptions. - A new role is added in Keycloak (
glacez-app), then read fromresource_access; never invent an authority from another claim. - Never trust a username, user id, or ownership field supplied in a request body when the token already carries one.
- Secrets live in Kubernetes secrets/SOPS, not in
application.yaml. A secret found in a plain-text config is a rotation event, not a cleanup task.