|
@@ -174,8 +174,10 @@ However, there are times that it is beneficial to know the ordering, if you want
|
|
|
|
|
|
To exemplify the above paragraph, let's consider the following security configuration:
|
|
To exemplify the above paragraph, let's consider the following security configuration:
|
|
|
|
|
|
-====
|
|
|
|
-.Java
|
|
|
|
|
|
+[tabs]
|
|
|
|
+======
|
|
|
|
+Java::
|
|
|
|
++
|
|
[source,java,role="primary"]
|
|
[source,java,role="primary"]
|
|
----
|
|
----
|
|
@Configuration
|
|
@Configuration
|
|
@@ -196,7 +198,9 @@ public class SecurityConfig {
|
|
|
|
|
|
}
|
|
}
|
|
----
|
|
----
|
|
-.Kotlin
|
|
|
|
|
|
+
|
|
|
|
+Kotlin::
|
|
|
|
++
|
|
[source,kotlin,role="secondary"]
|
|
[source,kotlin,role="secondary"]
|
|
----
|
|
----
|
|
import org.springframework.security.config.web.servlet.invoke
|
|
import org.springframework.security.config.web.servlet.invoke
|
|
@@ -220,7 +224,7 @@ class SecurityConfig {
|
|
|
|
|
|
}
|
|
}
|
|
----
|
|
----
|
|
-====
|
|
|
|
|
|
+======
|
|
|
|
|
|
The above configuration will result in the following `Filter` ordering:
|
|
The above configuration will result in the following `Filter` ordering:
|
|
|
|
|
|
@@ -336,8 +340,9 @@ Instead of implementing `Filter`, you can extend from {spring-framework-api-url}
|
|
|
|
|
|
Now, we need to add the filter to the security filter chain.
|
|
Now, we need to add the filter to the security filter chain.
|
|
|
|
|
|
-====
|
|
|
|
-.Java
|
|
|
|
|
|
+======
|
|
|
|
+Java::
|
|
|
|
++
|
|
[source,java,role="primary"]
|
|
[source,java,role="primary"]
|
|
----
|
|
----
|
|
@Bean
|
|
@Bean
|
|
@@ -348,7 +353,9 @@ SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
|
return http.build();
|
|
return http.build();
|
|
}
|
|
}
|
|
----
|
|
----
|
|
-.Kotlin
|
|
|
|
|
|
+
|
|
|
|
+Kotlin::
|
|
|
|
++
|
|
[source,kotlin,role="secondary"]
|
|
[source,kotlin,role="secondary"]
|
|
----
|
|
----
|
|
@Bean
|
|
@Bean
|
|
@@ -359,7 +366,7 @@ fun filterChain(http: HttpSecurity): SecurityFilterChain {
|
|
return http.build()
|
|
return http.build()
|
|
}
|
|
}
|
|
----
|
|
----
|
|
-====
|
|
|
|
|
|
+======
|
|
|
|
|
|
<1> Use `HttpSecurity#addFilterBefore` to add the `TenantFilter` before the `AuthorizationFilter`.
|
|
<1> Use `HttpSecurity#addFilterBefore` to add the `TenantFilter` before the `AuthorizationFilter`.
|
|
|
|
|