2017-05-17 6 views
0

私はconfigure spring bootに大きな問題があります。私のアプリケーションでは、XSRF-TOKENを認可に使用しています。スプリングブートXSRF-TOKENどのようにssl(https)の設定を追加する

  http.httpBasic().and() 
       .formLogin().loginPage("/login").and() 
       .authorizeRequests() 
       .antMatchers(
         "/index_orange.html", 
         "/index.html", 
         "/databases.html", 
         "/crm.html", 
         "/price.html", 
         "/var/www/download" 
       ) 
       .permitAll() 
       .antMatchers("/admin/**").hasRole("ADMIN") 
       .antMatchers("/user/**").hasRole("USER") 
       .anyRequest().authenticated().and() 
       .requiresChannel() 
       .csrf().ignoringAntMatchers("/registerform","/newpassblue","/getPaymentNotification") 
       .csrfTokenRepository(csrfTokenRepository()).and() 
       .addFilterBefore(csrfHeaderFilter(), SessionManagementFilter.class); 

認証はうまく機能しますが、SSL(HTTPS)をどのように追加できますか?

.requiresChannel()を使用する必要がありますが、この接続によってコンパイルエラーが発生します。

マイglobalUserDetails:

 @Autowired 
    public void globalUserDetails(AuthenticationManagerBuilder auth) throws Exception { 
     auth 
       .jdbcAuthentication() 
       .dataSource(securityDataSource) 
       .usersByUsernameQuery(USER_BY_EMAILS) 
       .authoritiesByUsernameQuery(AUTHORIZATION_BY_EMAILS) 
       .passwordEncoder(new ShaPasswordEncoder(512)); 

    } 

私のプロパティファイル:

server: 
    port: 8083 
    ssl: 
     enabled: true 
     key-alias: tomcat 
     key-store: keystore.p12 
     key-store-password: "*****" 
logging: 
    path: /var/log/gateway2 
    level: 
     org.springframework.security: INFO 
security: 
    sessions: ALWAYS 
zuul: 
    routes: 
     front: 
      url: http://192.168.14.73:8080/ui-web 
     backend: 
      url: http://192.168.14.63:8180/idbms-web 
     backend2: 
      url: http://192.168.14.50:8080/itdjg-mcalendar-ui 
     crm: 
      url: http://192.168.14.73:8080/ui-web/crm 
     bazy-danych: 
      url: http://192.168.14.73:8080/ui-web 
spring: 
    mvc: 
     view: 
      prefix: /WEB-INF/jsp/ 
      suffix: .jsp 

答えて

0

と(追加) requiresChannel()後。しかし、私はsslであなたの春のブートアプリケーションを開始する必要があると思う。

keystore.jksをビルドし、次の引数を使用してアプリケーションを実行するか、application.propertiesに追加します。

--server.port=443 --server.ssl.key-store=classpath:keystore.jks --server.ssl.key-store-password=<password> --server.ssl.key-password=<password> 
関連する問題