You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/servlet/architecture.adoc
+130Lines changed: 130 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -562,6 +562,136 @@ In the event that you are unable to reconfigure `HttpSecurity` to not add a cert
562
562
----
563
563
====
564
564
565
+
[[servlet-public-endpoints]]
566
+
== Configuring Public Endpoints
567
+
568
+
There are often endpoints that need to be accessible without authentication, such as login pages, public assets, or public APIs. The `@SecurityFilterChain` API allows you to configure which endpoints should be publicly accessible.
569
+
570
+
Let's look at how to configure endpoints to allow public access:
571
+
572
+
[tabs]
573
+
======
574
+
Java::
575
+
+
576
+
[source,java,role="primary"]
577
+
----
578
+
@Bean
579
+
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
If a request presents credentials (tokens, Basic Auth, etc.), Spring Security will attempt to authenticate the user even when an endpoint is configured with `permitAll()`.
620
+
====
621
+
622
+
623
+
[TIP]
624
+
By using the `@Order` annotation, you can define separate security filter chains for public and secured endpoints.
625
+
Filter chains with lower order numbers are evaluated first.
626
+
627
+
628
+
[tabs]
629
+
======
630
+
Java::
631
+
+
632
+
[source,java,role="primary"]
633
+
----
634
+
@Bean
635
+
@Order(1)
636
+
public SecurityFilterChain publicFilterChain(HttpSecurity http) throws Exception {
0 commit comments