liveBook · Manning

JWKSource

As explained in Spring Security in Action, Second Edition

JWKSource is a component that supplies JSON Web Keys for cryptographic operations such as signing authorization-server tokens.

A JWKSource supplies the key material that a Spring Security authorization server uses to sign non-opaque tokens, such as JWTs. The server exposes corresponding public keys so clients can validate token authenticity. section 14.1

Configure JWKSource with these responsibilities in mind:

  • Provide a set of signing keys through a JWKSource<SecurityContext> bean. section 14.1
  • Generate or load an RSA key pair, package it as an RSAKey, and assign it a key ID. section 14.1
  • Store production keys securely and preserve them across deployments; regenerating them on restart invalidates previously issued tokens. section 14.1
  • Use JWKSource for non-opaque tokens; opaque-token deployments instead rely on resource-server introspection. section 14.6

Programmatic RSA configuration

A minimal configuration creates a 2048-bit RSA pair, wraps its public and private keys in RSAKey, assigns a generated key ID, and returns the configured key source. This is suitable for demonstration, not for deployments where issued tokens must survive restarts. section 14.1

Figure 14.2 The components we need to configure and plug in for an authorization server implemented with Spring Security to work

Use the component diagram to place JWKSource alongside the authorization server’s protocol, client, user, and endpoint configuration. section 14.1

How Spring Security in Action, Second Edition covers it

How deep it goes
Builds a programmatic RSA example and explains persistent production storage, but defers detailed vault integration.
Examples
Uses a Java bean that generates a 2048-bit RSA pair, constructs an RSAKey, and assigns a UUID key ID.
What it assumes
Assumes basic Spring and Java knowledge while introducing authorization-server key management alongside user and client components.
What you can do after
Operate/configure Spring Security authorization servers with a signing-key source and recognize when durable key storage is required.
How it connects
Connects JSON Web Tokens, OAuth 2 authorization servers, RSA key pairs, opaque tokens, resource servers, and introspection endpoints.

Also explained in

Compare how 2 books explain JWKSource →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring Security in Action, Second Edition. The section links point to the parts of the book it draws on.