Everything on this page is auto-configured. Each feature only switches on when its trigger is present, so you pay for nothing you do not use.
| Feature | Activated when |
|---|---|
a Workload API socket is found, or agentless mode is configured |
|
an identity source exists |
|
|
|
web app and |
|
web app (servlet or WebFlux) |
|
Spring Security is on the classpath |
|
always as beans; on every client with |
|
|
|
Actuator is on the classpath |
The identity source
SpiffeIdentitySource is the one bean everything else builds on. Inject it when you need the identity directly:
| Method | Returns |
|---|---|
|
this workload’s SPIFFE ID |
|
the current X.509-SVID (certificate chain and private key) |
|
the trusted X.509 bundles, one per trust domain |
|
SVID, bundles and validity, read atomically |
|
a JWT-SVID for the audiences, cached until it nears expiry |
|
the JWT signing keys used to validate inbound JWT-SVIDs |
|
a callback on every rotation |
|
where the identity comes from, such as |
identity.addListener(snapshot -> log.info("SVID rotated, now valid until {}", snapshot.expiresAt()));
The spiffe SSL bundle
The starter registers a Spring Boot SSL bundle named spiffe.
Anything in Spring Boot that accepts a bundle name accepts it:
| Where | How |
|---|---|
Embedded server (Tomcat or Reactor Netty) |
|
Every Boot-built HTTP client |
|
One |
|
One |
|
Rotation without restarts
When the agent pushes a new SVID, the starter updates the bundle:
-
Tomcat reloads its certificate from the bundle.
-
Reactor Netty and every HTTP client read the current SVID at each TLS handshake through live key and trust managers.
Neither needs a restart, and the integration tests rotate both servers while they run.
SPIFFE ID checks instead of hostnames
SVIDs normally carry no DNS name, so classic hostname verification would fail. The starter’s trust manager checks the peer’s SPIFFE ID instead, and plain HTTPS clients keep working. See the FAQ for the one client that needs care.
One bundle per upstream service
When a client must only ever talk to one service, give it its own bundle and allow-list. The TLS handshake then fails for any other server, even one from your own trust domain:
spiffe:
ssl:
bundles:
orders:
allowed-ids: spiffe://example.org/ns/shop/sa/orders
RestClient orders = builder.apply(ssl.fromBundle("orders")).build();
Authorizing callers by SPIFFE ID
Set an allow-list and the starter adds a filter to servlet and WebFlux applications:
spiffe:
mtls:
server:
allowed-ids:
- spiffe://example.org/ns/shop/sa/frontend
- spiffe://example.org/ns/ops/*
exclude-paths: /actuator/**,/error # the default
-
No client certificate:
401 Unauthorized. -
A SPIFFE ID that is not allowed:
403 Forbidden. -
An empty list turns enforcement off.
Knowing who called: @SpiffePeer
Controllers can receive the caller’s SPIFFE ID as an argument, in Spring MVC and WebFlux alike:
@GetMapping("/hello")
Map<String, String> hello(@SpiffePeer SpiffeId caller) {
return Map.of("caller", caller.toString());
}
Spring Security
With Spring Security on the classpath, the starter provides:
-
SpiffeIdX509PrincipalExtractor, which makes the SPIFFE ID the authenticated principal of an X.509 login; -
SpiffeAuthorizationManagers.hasSpiffeId(…)andinTrustDomain(…), which authorize requests on that ID with the same patterns.
@Bean
SecurityFilterChain security(HttpSecurity http, SpiffeIdX509PrincipalExtractor extractor) throws Exception {
return http
.x509(x509 -> x509
.x509PrincipalExtractor(extractor)
.userDetailsService(id -> User.withUsername(id).password("").authorities("ROLE_WORKLOAD").build()))
.authorizeHttpRequests(requests -> requests
.requestMatchers("/admin/**").access(hasSpiffeId("spiffe://example.org/ns/ops/*"))
.anyRequest().access(inTrustDomain("example.org")))
.build();
}
JWT-SVIDs on outbound calls
Use JWT-SVIDs when TLS does not reach the service end to end, for example behind an ingress or a service mesh that terminates it.
The starter provides an interceptor for RestClient and an exchange filter for WebClient:
RestClient payments = builder
.baseUrl("https://payments.internal")
.requestInterceptor(spiffeJwtClientHttpRequestInterceptor)
.build();
The audience of each token is resolved in this order:
-
a request attribute:
.attribute(SpiffeJwtAudienceResolver.AUDIENCE_ATTRIBUTE, "payments"); -
the target host:
spiffe.jwt.client.audiences.<host>; -
the default:
spiffe.jwt.client.default-audience.
spiffe:
jwt:
client:
audiences:
payments.internal: spiffe://example.org/payments
default-audience: internal-apis
auto-apply: true # add the token to every RestClient, RestTemplate and WebClient Boot builds
Tokens are cached per audience and renewed at half-life, or spiffe.jwt.client.refresh-margin before expiry, whichever comes first.
Validating inbound JWT-SVIDs
Name the audiences you accept, and Spring Security’s resource server validates bearer JWT-SVIDs against the agent’s JWT bundles:
spiffe:
jwt:
resource-server:
audiences: spiffe://example.org/payments
allowed-ids: spiffe://example.org/ns/shop/* # optional: restrict callers too
@Bean
SecurityFilterChain api(HttpSecurity http) throws Exception {
return http
.authorizeHttpRequests(requests -> requests.anyRequest().authenticated())
.oauth2ResourceServer(oauth2 -> oauth2.jwt(Customizer.withDefaults()))
.build();
}
The JWT’s sub is the caller’s SPIFFE ID:
@GetMapping("/api/payments")
String payments(@AuthenticationPrincipal Jwt jwt) {
return "called by " + jwt.getSubject();
}
Both servlet (SpiffeJwtDecoder) and reactive applications are supported.
Health and info
With Actuator present, the starter contributes:
-
a
spiffehealth indicator, which is DOWN when the SVID is missing, expired, or has less thanspiffe.health.min-remaining(5 minutes by default) left, a sign that rotation has stalled; -
a
spiffeinfo contributor with the SPIFFE ID, the identity source and the SVID validity.
Disable either one the usual Spring Boot way: management.health.spiffe.enabled=false or management.info.spiffe.enabled=false.