2016-06-20 3 views
0

フィルタBeanを追加しようとしているため、特定のURLへのリクエストを認証できます。この場合、私はURLプレフィックス、/api/v1/*を追加しようとしているので、このプレフィックスを持つすべてのURLが認証されます。私が定義したURLの代わりにすべてのURLを登録するSpring FilterRegistrationBean?

@EnableAutoConfiguration 
@ComponentScan 
@Configuration 
public class Application { 
    @Bean 
    public FilterRegistrationBean jwtFilter() { 
       FilterRegistrationBean registrationBean = new FilterRegistrationBean(); 
     registrationBean.setFilter(new JwtFilter()); 
     registrationBean.addUrlPatterns("/api/v1/*"); 

     return registrationBean; 
    } 
    .... 
    public static void main(String[] args) { 
     SpringApplication.run(Application.class, args); 
    } 
} 

しかし、これは、/api/v1を含むすべてのURLの代わりのものプレフィックスを登録しているようです。

私はPOSTリクエストを送信した場合、私は次のような応答を取得したい:

{ 
    "timestamp": 1466406709295, 
    "status": 401, 
    "error": "Unauthorized", 
    "message": "Full authentication is required to access this resource", 
    "path": "/user/login/email" 
} 

私のポンポン、それは場合に役立ちます:奇妙だったな、すまんすまんが続いてき

 <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-data-jpa</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-redis</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-devtools</artifactId> 
     </dependency> 

     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <scope>runtime</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-test</artifactId> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-security</artifactId> 
     </dependency> 

答えて

0

何かを、後には、再コンパイル、再構築、および再起動を行うと、何も修正されませんでした。だから私は終了しましたintelliJそれを再オープンし、問題は修正されました。

関連する問題