0
が発生し、私はそれを定義しています支払い "、すべてが実行されます。春のセキュリティhasIpAddressは私の構成でエラー
しかし、私はIP検証有効にしようとします
{"errorMessage":"Not Found","errorId":"6ae34aa3-9195-42d6-8906-996906988ce0","errorDetails":null}
私が間違っているのは何:
http.exceptionHandling()
.authenticationEntryPoint(authEntryPoint)
.and()
.authorizeRequests()
//.antMatchers("/api/payment").permitAll()
.antMatchers("/api/payment").hasIpAddress("XXX.XXX.X.XX")
...
要求が与えられたIPアドレスからの送信を次の応答を受け取りますか?
EDIT
これは私が起動しています方法です:
@RequestMapping(value = "/payment", method = POST)
public String saveOrder(@ModelAttribute PaymentDto paymentDto) {
paymentService.savePayment(paymentDto);
return "OK";
}
を私は常に要求データを送信するので(例えば、ポストは、次のURLにある:api/payment?id=123&whatever
)
私は以下を追加しました:
.antMatchers("/api/payment?**").access("hasIpAddress('XXX.XXX.X.XX')")
しかし、これはどちらもうまくいきませんでした。
UPDATEは2
私はこのように私のantMatcherの配置を変更しました:今、ちょうど私が与えられたからポストを作成しようとしているログインページに私をリダイレクトし
http.exceptionHandling()
.authenticationEntryPoint(authEntryPoint)
.and()
.authorizeRequests()
.antMatchers("/", "/app/**", "/assets/**", "/fonts/**", "/images/**").permitAll()
.antMatchers("/authentication/login", "/login.html").anonymous()
.antMatchers("/api/products/**").permitAll()
.antMatchers("/api/cities/**").permitAll()
.antMatchers("/api/order/**").permitAll()
.antMatchers("/api/payment").hasIpAddress("XXX.XXX.X.XX")
.anyRequest().authenticated()
.and()
.csrf().requireCsrfProtectionMatcher(new CsrfRequestMatcher())
.and()
.formLogin()
.loginPage("/login.html")
.loginProcessingUrl("/authentication/login")
.successHandler(authSuccessHandler)
.failureHandler(authFailureHandler)
.and()
.logout()
.logoutUrl("/authentication/logout")
.logoutSuccessHandler(logoutSuccessHandler)
.deleteCookies(JSESSIONID_COOKIE, CSRF_COOKIE)
.invalidateHttpSession(true)
.permitAll();
IPアドレス
は、おそらくあなたはNullPointerExceptionがに – reos
@reosを取得しているが、何のNullPointerExceptionがありません。メソッドはまったく実行されません。 – uksz
おそらくIPがnullで、春はnullpointerをスローします – reos