1
私は、SpringブートとSpringセキュリティでLDAP認証を実装しました。構成はかなり簡単です。SpringセキュリティでLDAP認証を使用してトークンを作成する方法
@Configuration
protected static class AuthenticationConfiguration extends
GlobalAuthenticationConfigurerAdapter {
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
DefaultSpringSecurityContextSource contextSource = new DefaultSpringSecurityContextSource(url);
contextSource.setUserDn(userDn);
contextSource.setPassword(userPass);
contextSource.setReferral("follow");
contextSource.afterPropertiesSet();
LdapAuthenticationProviderConfigurer<AuthenticationManagerBuilder> ldapAuthenticationProviderConfigurer = auth.ldapAuthentication();
ldapAuthenticationProviderConfigurer
.userDnPatterns("cn={0},ou=institution,ou=people")
.userSearchBase("")
.contextSource(contextSource);
}
}
は今、私は最初のログインが成功した後、サーバは単にサーバー上に作成されたトークンとリクエストヘッダをverifingことにより、要求を検証できるように、トークンベースの認証を作成したいです。
LDAP認証はシーンの背後でldapAuthentiationProviderを使用して行われるため、最初のログインからユーザーの資格情報を取得する方法と、ログインの応答としてトークンを送信する方法がわかりません。フォームのログインフィルタにカスタム認証成功ハンドラを挿入して、ユーザーの資格情報に基づいてトークンを作成する必要がありますか?もしそうなら、どのようにして正確に行うことができますか?