0
私は春の認証を実装しようとしています。私はドキュメントを読んで、以下のコードを追加しました。ログインユーザーの春の認証
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/login", "/logout", "/register", "resources/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.loginProcessingUrl("/login");
}
}
これは簡単に動作します。しかし、私が本当に望むのは、私自身のauthenticated()メソッドを実装することです。だからanyRequest().authenticated()
が実行されると、基本的に私が実装したauthenticated()メソッドを呼び出して、ユーザがログインしているかどうかをチェックする必要があります。私は
authenticated(){
//I check here if user is present in the session or not
//this means logged in or not
}
以下、このようなものは、だから私は本当に必要なものそれはanyRequest().authenticated()
が実行されたときに自分のauthenticated()
メソッドが呼び出されるようにauthenticated()
メソッドを実装する方法を知っているしたいです。
なぜそれをしたいですか?アプリケーションに必要な動作は何ですか? – chrylis