2016-09-09 40 views
5
applicationContext.xml

Bahar Güvenlik Özel filtre

<bean id="springSecurityFilterChain" class="org.springframework.security.web.FilterChainProxy"> 
     <security:filter-chain-map request-matcher="ant"> 
      <security:filter-chain pattern="/health" 
       filters="none" /> 
      <security:filter-chain pattern="/swagger-ui.html" 
       filters="none" /> 
      <security:filter-chain pattern="/images/**" 
       filters="none" /> 
      <security:filter-chain pattern="/webjars/**" 
       filters="none" /> 
      <security:filter-chain pattern="/v2/apidocs" 
       filters="none" />    
      <security:filter-chain pattern="/*.ico" 
       filters="none" />    
      <security:filter-chain pattern="/**" 
       filters="customAuthorizationFilter" /> 
     </security:filter-chain-map> 

dosyanın

Porsiyon: Güvenlik-context.xml

<beans:beans xmlns="http://www.springframework.org/schema/security" 
      xmlns:beans="http://www.springframework.org/schema/beans" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
    http://www.springframework.org/schema/security 
    http://www.springframework.org/schema/security/spring-security-4.0.xsd"> 

    <http> 
     <intercept-url pattern="/swagger-ui.html" access="hasRole('ROLE_ADMIN')" /> 
     <http-basic/> 
     <csrf disabled="true"/> 
    </http> 

    <authentication-manager> 
     <authentication-provider> 
      <user-service> 
       <user name="abc" password="Basicauth" authorities="ROLE_ADMIN" /> 
      </user-service> 
     </authentication-provider> 
    </authentication-manager> 

</beans:beans> 

isteği doğrulayarak yöntemini sabitlemek için özel filtre yoktu ve hatayı kontrol etmek. Güvenlik-context.xml dosyasını ekledikten sonra, kullanıcı adı ve parola ile belirli bir son nokta için kaynak tabanlı güvenlik (swagger-ui.html).

Bu güvenlik değişikliğinden sonra, özel filtre yetkisi çalışmıyor, belki yeni güvenlik uygulaması tarafından geçersiz kılınmış. Bu nasıl düzeltilebilir?

cevap

0

cevap koyarak önce test için yeterli zaman yoktu ama siz aşağıya özel filtre oluşturma deneyebilirsiniz:

<custom-filter ref="customAuthorizationFilter" before="BASIC_AUTH_FILTER"/>

Ben filtrelerin önceliği hakkında olduğunu düşünüyorum.

İlgili konular