<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Java on shoujun KB</title><link>https://kb.shoujun.dev/tags/java/</link><description>Recent content in Java on shoujun KB</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Fri, 04 Dec 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://kb.shoujun.dev/tags/java/index.xml" rel="self" type="application/rss+xml"/><item><title>How to design OIDC third-party access, consent, and scopes</title><link>https://kb.shoujun.dev/kb/java/oidc-third-party-access-scope-design/</link><pubDate>Fri, 04 Dec 2026 00:00:00 +0000</pubDate><guid>https://kb.shoujun.dev/kb/java/oidc-third-party-access-scope-design/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Blog post: &lt;a href="https://blog.shoujun.dev/2026/12/oidc-third-parties-client-credentials.html"&gt;OIDC third parties: client credentials, consent, and scope design&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="choose-the-right-grant"&gt;Choose the right grant&lt;/h2&gt;
&lt;p&gt;Use &lt;strong&gt;authorization code&lt;/strong&gt; when an end user delegates access to an application. Use &lt;strong&gt;client credentials&lt;/strong&gt; only when a machine or service acts as itself and no end user is involved.&lt;/p&gt;
&lt;p&gt;Do not use &lt;code&gt;client_credentials&lt;/code&gt; as a shortcut for user-delegated access. Its token subject is the client ID, not a user; downstream services cannot make user-specific authorization decisions from it.&lt;/p&gt;</description></item><item><title>OIDC edge gateway JWT validation checklist</title><link>https://kb.shoujun.dev/kb/java/oidc-edge-gateway-validation/</link><pubDate>Thu, 03 Dec 2026 00:00:00 +0000</pubDate><guid>https://kb.shoujun.dev/kb/java/oidc-edge-gateway-validation/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Blog post: &lt;a href="https://blog.shoujun.dev/2026/12/the-oidc-edge-gateway-validating-tokens.html"&gt;The OIDC edge gateway: validating tokens you did not issue&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="token-validation"&gt;Token validation&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Resolve discovery and JWKS from the trusted issuer.&lt;/li&gt;
&lt;li&gt;Validate signature, issuer, expiry, and not-before time.&lt;/li&gt;
&lt;li&gt;Enforce the route-specific audience and scopes.&lt;/li&gt;
&lt;li&gt;Return 401 for missing or invalid authentication and 403 for insufficient authorization.&lt;/li&gt;
&lt;li&gt;Use introspection only where rapid revocation detection is required; cache briefly and fail closed.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="trusted-identity-propagation"&gt;Trusted identity propagation&lt;/h2&gt;
&lt;p&gt;Strip every client-supplied identity or forwarding header before routing. Derive downstream identity headers only from validated claims, including subject, username, roles, and client ID. Do not forward bearer tokens unless the downstream contract explicitly requires them.&lt;/p&gt;</description></item><item><title>OIDC public vs confidential clients: security differences</title><link>https://kb.shoujun.dev/kb/java/oidc-public-vs-confidential-clients/</link><pubDate>Thu, 03 Dec 2026 00:00:00 +0000</pubDate><guid>https://kb.shoujun.dev/kb/java/oidc-public-vs-confidential-clients/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Blog post: &lt;a href="https://blog.shoujun.dev/2026/12/the-oidc-relying-party-built-twice.html"&gt;The OIDC relying party, built twice&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="confidential-client"&gt;Confidential client&lt;/h2&gt;
&lt;p&gt;A server-side application can protect a client secret and keep tokens in a server session. It can authenticate at the token endpoint, receive refresh tokens, validate ID tokens through a mature framework, and perform RP-initiated logout with an &lt;code&gt;id_token_hint&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="public-client"&gt;Public client&lt;/h2&gt;
&lt;p&gt;Browser and native clients cannot protect a secret. Use authorization code with PKCE and register &lt;code&gt;clientAuthenticationMethod: none&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The client must:&lt;/p&gt;</description></item><item><title>Spring Authorization Server production checklist</title><link>https://kb.shoujun.dev/kb/java/spring-authorization-server-checklist/</link><pubDate>Thu, 03 Dec 2026 00:00:00 +0000</pubDate><guid>https://kb.shoujun.dev/kb/java/spring-authorization-server-checklist/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Blog post: &lt;a href="https://blog.shoujun.dev/2026/12/spring-authorization-server-from-zero.html"&gt;Spring Authorization Server: from zero to a working OIDC provider&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="protocol-surface"&gt;Protocol surface&lt;/h2&gt;
&lt;p&gt;Verify discovery, authorization, token, JWKS, introspection, revocation, and UserInfo endpoints. Enable only the grant types and scopes each registered client needs.&lt;/p&gt;
&lt;h2 id="persistence"&gt;Persistence&lt;/h2&gt;
&lt;p&gt;Back these contracts with durable storage:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;RegisteredClientRepository&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;OAuth2AuthorizationService&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;OAuth2AuthorizationConsentService&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;UserDetailsService&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Manage schemas with migrations and refuse production startup when required secrets or database settings are absent.&lt;/p&gt;
&lt;h2 id="security-checklist"&gt;Security checklist&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Persist RSA or EC signing keys and rotate them without dropping still-valid public keys.&lt;/li&gt;
&lt;li&gt;Map &lt;code&gt;sub&lt;/code&gt; to an immutable UUID, not a username.&lt;/li&gt;
&lt;li&gt;Keep browser login and consent routes session-based with CSRF protection.&lt;/li&gt;
&lt;li&gt;Keep token and administrative APIs stateless with explicit 401 responses.&lt;/li&gt;
&lt;li&gt;Prefer &lt;code&gt;client_secret_basic&lt;/code&gt;; avoid &lt;code&gt;client_secret_post&lt;/code&gt; logging exposure.&lt;/li&gt;
&lt;li&gt;Require PKCE for public clients.&lt;/li&gt;
&lt;li&gt;Rate-limit credential-bearing endpoints.&lt;/li&gt;
&lt;li&gt;Use separate development seed data and production configuration.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="end-to-end-verification"&gt;End-to-end verification&lt;/h2&gt;
&lt;p&gt;Complete a full authorization-code roundtrip, validate the ID token, call UserInfo, refresh where permitted, revoke the token, and confirm the revoked credential is rejected.&lt;/p&gt;</description></item><item><title>What an OIDC provider must implement beyond protocol endpoints</title><link>https://kb.shoujun.dev/kb/java/oidc-provider-responsibilities/</link><pubDate>Thu, 03 Dec 2026 00:00:00 +0000</pubDate><guid>https://kb.shoujun.dev/kb/java/oidc-provider-responsibilities/</guid><description>&lt;blockquote&gt;
&lt;p&gt;Blog post: &lt;a href="https://blog.shoujun.dev/2026/12/building-your-own-oidc-provider-what.html"&gt;Building your own OIDC provider&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;OIDC endpoint support is only the protocol core. A production-shaped provider must also make identity, keys, clients, consent, tokens, and operations durable and secure.&lt;/p&gt;
&lt;h2 id="responsibilities"&gt;Responsibilities&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Publish discovery metadata and JWKS.&lt;/li&gt;
&lt;li&gt;Implement authorization code with PKCE, refresh token, and client credentials where appropriate.&lt;/li&gt;
&lt;li&gt;Persist registered clients, authorizations, consents, users, and authorities.&lt;/li&gt;
&lt;li&gt;Use an immutable identifier for &lt;code&gt;sub&lt;/code&gt;; keep mutable usernames in a separate claim.&lt;/li&gt;
&lt;li&gt;Persist and rotate signing keys while retaining keys needed to validate existing tokens.&lt;/li&gt;
&lt;li&gt;Separate browser/session security from stateless protocol and administrative APIs.&lt;/li&gt;
&lt;li&gt;Restrict client authentication methods and avoid secrets in request bodies.&lt;/li&gt;
&lt;li&gt;Rate-limit login, token, introspection, and user-info endpoints.&lt;/li&gt;
&lt;li&gt;Provide revocation, health probes, audit logs, and explicit production startup validation.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="gotchas"&gt;Gotchas&lt;/h2&gt;
&lt;p&gt;A provider that generates a signing key at every restart invalidates tokens in flight. Disabling CSRF globally to simplify token endpoints also weakens browser-facing session routes. Treat these as separate security domains.&lt;/p&gt;</description></item></channel></rss>