デニスStephanov:
あなたは春ブーツ2で安全なアクチュエータのエンドポイントに助けることができますか?私は、移行ガイドをチェックし、それは私を助けていません。
ここに私のセキュリティ設定は次のとおりです。
@Configuration
@EnableWebSecurity
public class SecConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.requestMatchers(EndpointRequest.toAnyEndpoint()).hasRole("ADMIN")
.anyRequest().authenticated();
}
}
しかし、私はに行くときhttp://localhost:8080/actuator/health
も、ログインせずにロードします。接頭辞を持つ他のエンドポイントは、/actuator
同様にログインを必要としません。私は間違って何をしましたか?
私はまた、この構成ではOAuthを追加します。
@Configuration
@EnableAuthorizationServer
public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter {
@Override
public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
clients
.inMemory()
.withClient("client-id")
.scopes("read", "write")
.authorizedGrantTypes("password")
.secret("xxxxxx")
.accessTokenValiditySeconds(6000);
}
}
@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/ajax/**").authenticated()
.and()
.csrf()
.disable();
}
}
サンフランシスコRecio:
アプリケーションがリソースサーバーである場合は、SecConfigクラスは必要ありません。
あなたはそれを削除するのであれば、あなたの中にResourceServerConfig
クラスあなたは、アクチュエータを確保することができ、ちょうどを通じて管理をしてみましょう:
@Configuration
@EnableResourceServer
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
http
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.authorizeRequests()
.antMatchers("/ajax/**").authenticated()
.antMatchers("/actuator/**").hasRole("ADMIN")
.anyRequest().authenticated()
.and()
.csrf()
.disable();
}
}
私は、追加.anyRequest().authenticated()
のアプリケーション・エンドポイントの残りの部分を確保します。