<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Spring-Security on Java &amp; Software Architecture Knowledge Hub</title><link>https://samirsahoo.github.io/design-patterns-hub/tags/spring-security/</link><description>Recent content in Spring-Security on Java &amp; Software Architecture Knowledge Hub</description><generator>Hugo</generator><language>en-US</language><copyright>© 2026 Samir Kumar Sahoo (https://github.com/samirsahoo). All rights reserved.</copyright><atom:link href="https://samirsahoo.github.io/design-patterns-hub/tags/spring-security/index.xml" rel="self" type="application/rss+xml"/><item><title>Spring Security Architecture: The Security Filter Chain</title><link>https://samirsahoo.github.io/design-patterns-hub/spring/security/security-filter-chain/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/spring/security/security-filter-chain/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Spring Security&lt;/strong&gt; protects applications with a chain of &lt;strong&gt;servlet filters&lt;/strong&gt; that runs &lt;strong&gt;before&lt;/strong&gt; your controllers. The filters &lt;strong&gt;authenticate&lt;/strong&gt; the caller (who are you?), store the result in a &lt;strong&gt;&lt;code&gt;SecurityContext&lt;/code&gt;&lt;/strong&gt;, and &lt;strong&gt;authorize&lt;/strong&gt; the request (are you allowed?). It is configured with one or more &lt;strong&gt;&lt;code&gt;SecurityFilterChain&lt;/code&gt;&lt;/strong&gt; beans.&lt;/p&gt;</description></item><item><title>Authentication and Authorization with OAuth 2.0, OpenID Connect and JWT</title><link>https://samirsahoo.github.io/design-patterns-hub/spring/security/oauth2-oidc-and-jwt/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/spring/security/oauth2-oidc-and-jwt/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;strong&gt;Authentication&lt;/strong&gt; proves &lt;strong&gt;who&lt;/strong&gt; someone is. &lt;strong&gt;Authorization&lt;/strong&gt; decides &lt;strong&gt;what they may do&lt;/strong&gt;.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;OAuth 2.0&lt;/strong&gt; is a framework for &lt;strong&gt;delegated authorization&lt;/strong&gt;: an app obtains an &lt;strong&gt;access token&lt;/strong&gt; to call an API on a user&amp;rsquo;s behalf, or on its own behalf.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;OpenID Connect (OIDC)&lt;/strong&gt; adds an &lt;strong&gt;authentication&lt;/strong&gt; layer on top: an &lt;strong&gt;ID token&lt;/strong&gt; that says who logged in.&lt;/li&gt;&#10;&lt;li&gt;&lt;strong&gt;JWT (JSON Web Token)&lt;/strong&gt; is a common, self-contained, signed token format.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="the-problem"&gt;The problem&lt;a class="heading-anchor" href="#the-problem" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;Every service managing its own passwords leads to weak security, no single sign-on and no MFA. Sharing user passwords with third-party apps is unacceptable. OAuth 2.0 and OIDC centralise login in an &lt;strong&gt;authorization server&lt;/strong&gt; (identity provider) and give apps and APIs &lt;strong&gt;scoped, short-lived tokens&lt;/strong&gt; instead.&lt;/p&gt;</description></item><item><title>Method-Level Security with @PreAuthorize and @PostAuthorize</title><link>https://samirsahoo.github.io/design-patterns-hub/spring/security/method-level-security/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://samirsahoo.github.io/design-patterns-hub/spring/security/method-level-security/</guid><description>&lt;h2 id="simple-definition"&gt;Simple definition&lt;a class="heading-anchor" href="#simple-definition" aria-label="Link to this section"&gt;#&lt;/a&gt;&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Method-level security&lt;/strong&gt; checks authorization &lt;strong&gt;on service methods&lt;/strong&gt; instead of (or in addition to) URL rules:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;@PreAuthorize&lt;/code&gt; decides &lt;strong&gt;before&lt;/strong&gt; the call&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;@PostAuthorize&lt;/code&gt; decides &lt;strong&gt;after&lt;/strong&gt;, using the returned object&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;@PreFilter&lt;/code&gt; and &lt;code&gt;@PostFilter&lt;/code&gt; filter collections.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;It is enabled with &lt;code&gt;@EnableMethodSecurity&lt;/code&gt; and implemented with &lt;strong&gt;AOP proxies&lt;/strong&gt;.&lt;/p&gt;</description></item></channel></rss>