Я новичок в весенней безопасности, и я не понимаю, как работает весенняя безопасность.У меня есть цепочка фильтров, определенная следующим образом:
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/rest/internal/*</url-pattern>
<url-pattern>/user/*</url-pattern>
<url-pattern>/http/*</url-pattern>
</filter-mapping>
, и моя конфигурация безопасности выглядит следующим образом:
<global-method-security pre-post-annotations="enabled"/>
<http entry-point-ref="aligneUnauthorisedEntryPoint" use-expressions="true" create-session="never">
<!--<intercept-url pattern="/user/login" access="isAuthenticated()"/>-->
<intercept-url pattern="/rest/internal/**" access="isAuthenticated()"/>
<intercept-url pattern="/http/**" access="isAuthenticated()"/>
<custom-filter ref="loginFilter" position="FORM_LOGIN_FILTER"/>
<custom-filter ref="logoutFilter" position="LOGOUT_FILTER"/>
<csrf disabled="true"/>
<http-basic/>
</http>
<authentication-manager alias="aligneAuthenticationManager">
<authentication-provider ref="aligneUserAuthenticationProvider"/>
</authentication-manager>
<beans:bean id="loginFilter" class="com.altra.middleware.security.AligneAuthenticationFilter">
<beans:property name="authenticationManager" ref="aligneAuthenticationManager"/>
<beans:property name="authenticationFailureHandler" ref="aligneAuthenticationFailureHandler"/>
<beans:property name="authenticationSuccessHandler" ref="aligneAuthenticationSuccessHandler"/>
<beans:property name="filterProcessesUrl" value="/user/login"/>
</beans:bean>
Когда я нажимаю следующий URL из моего браузера: http://localhost:9099/jedi/rest/internal/main/dropdown
Я получаю следующую ошибку.
Во-вторых, возникает то же исключение, когда я пытаюсь вызвать службу из другого контроллера пружины, используя RestTemplate
.
ОШИБКА HTTP 503 Ошибка доступа к / jedi / rest / internal / main/падать.Причина:
Full authentication is required to access this resource
, где /jedi
- контекст приложения.
Если я закомментирую <intercept-url pattern="/rest/internal/**" access="isAuthenticated()"/>
, то вызывается правильный метод контроллера.
Какое значение access="isAuthenticated()"
?У нас этот метод переопределен, но он никогда не вызывается.
Как мне решить эту проблему?