Spring security 2.0.4では以下のように宣言し、個別のbean宣言でフィルターの位置も宣言していた……。
古い Security.xml
<sec:http session-fixation-protection="migrateSession">
<sec:intercept-url pattern="/login.hm*" filters="none" requires-channel="https" />
<sec:intercept-url pattern="/services/**" filters="none" requires-channel="https"/>
<sec:intercept-url pattern="/widget/**" filters="none" requires-channel="https" />
<sec:intercept-url pattern="/istore/theme/**" filters="none" requires-channel="https"/>
<sec:intercept-url pattern="/logout.hm*" filters="none" requires-channel="https" />
<sec:intercept-url pattern="/mstore/theme/**" filters="none" requires-channel="https"/>
<sec:intercept-url pattern="/istore/history*" access="ROLE_UU" requires-channel="https"/>
<sec:intercept-url pattern="/istore/consumer_goods*" access="ROLE_UU" requires-channel="https"/>
<sec:intercept-url pattern="/istore/electronics*" access="ROLE_UU" requires-channel="https"/>
<sec:intercept-url pattern="/istore/accessories*" access="ROLE_UU" requires-channel="https"/>
<sec:intercept-url pattern="/istore/reward_redemption*" access="ROLE_UU" requires-channel="https"/>
<sec:intercept-url pattern="/istore/**" access="ROLE_UU,ROLE_SSS" requires-channel="https"/>
<sec:form-login
login-page="${login.url}"
login-processing-url="${login.processing.url}"
default-target-url="${setuppassword.page.url}"
authentication-failure-url="${login.failure.url}" always-use-default-target="false" />
</sec:http>
Spring Security:特定のリソースを除外する方法は?
https://www.baeldung.com/security-none-filters-none-access-permitAll
主な問題は、フィルターが特定の URL パターンに対して除外されず、他のパターンに対してより正確な方法で設定されないことです。
PS また、移行中の HDIV もあります。
- 特定の URL のフィルターとチェーン オーダーを構成し、一部の URL を無視するにはどうすればよいですか?
- Java ベースの構成の方が優れていますか、それとも XML ですか?
起動ログ
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'sitemesh' to urls: [*.hm]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'CustomSecurityHeaderFilter' to urls: []
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'HttpOnlyCookieFilter' to urls: [*.hm]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'ValidatorFilter' to urls: [*.hm]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'org.springframework.security.filterChainProxy' to: [/*]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter:'org.springframework.security.web.access.intercept.FilterSecurityInterceptor#0' to: [/*]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' to: [/*]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpOnlyCookieFilter' to: [/*]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'logoutFilter' to: [/*]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'iStoreFilter' to: [/*]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'loginFilter' to: [/*]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'preLoginFilter' to: [/*]
INFO 78928 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: '_formLoginFilter' to: [/*]