私はrest APIでintergrate Spring Securityを使用したいと思います。私は設定がすべてのルートをブロックするので問題があります。Spring Securityデフォルトのログインページを無効にする
マイ設定:
@Configuration
@EnableResourceServer
public class OAuth2ResourceServerConfig extends ResourceServerConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
http.authorizeRequests()
.antMatchers("/").permitAll()
.antMatchers(HttpMethod.POST,"/api/getNews").hasRole("ADMIN");
}
}
私はGET
のスプリングリターンを望む
<html>
<head>
<title>Login Page</title>
</head>
<body onload='document.f.username.focus();'>
<h3>Login with Username and Password</h3>
<form name='f' action='/login' method='POST'>
<table>
<tr><td>User:</td><td><input type='text' name='username' value=''></td></tr>
<tr><td>Password:</td><td><input type='password' name='password'/></td></tr>
<tr><td colspan='2'><input name="submit" type="submit" value="Login"/></td></tr>
<input name="_csrf" type="hidden" value="5453a3c5-2573-4861-b777-d008b04863c3" />
</table>
</form>
</body>
</html>
しかし、私は/
を許可するためのルールを持っています。なぜ私のAPIにアクセスできないのですか?次のが見つかりました
要求の取得 '.antMatchers(HttpMethod.GET、"/")。permitAll()' –
これを使用していない可能性があります。 – lukassz
'.antMatchers(HttpMethod.GET、"/* ")。permitAll()'? –