我尝试开发一个使用Kerberos进行身份验证的Web应用程序。我首先设置了一个安全的Web应用程序,其中包含JaasAuthenticationProvider
和配置login.conf
KerberosContext
{
com.sun.security.auth.module.Krb5LoginModule
required
useTicketCache=true
doNotPrompt=false;
};
My SecurityConfig看起来像这样:
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private JaasAuthenticationProvider kerberosAuthenticationProvider;
@Override
public void configure(WebSecurity web) throws Exception {
super.configure(web);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().hasRole("USER")
.and()
.formLogin();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(kerberosAuthenticationProvider);
}
}
Web应用程序现在显示一个表单登录(如果我没有通过SPNEGO进行身份验证,这是正确的),我可以使用我的活动目录的凭据登录。
但是,当我已经拥有TGT时,我怎么能跳过这个?目前,我必须提交包含任何内容的登录表单,并将使用我的身份进行身份验证。 我的TestController的示例输出:
org.springframework.security.authentication.jaas.JaasAuthenticationToken@e72aef67:
Principal: ; Credentials: [PROTECTED]; Authenticated: true; Details:
org.springframework.security.web.authentication.WebAuthenticationDetails@b364:
RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: <...>; Granted
Authorities: Jaas Authority [ROLE_USER,username@MYREALM]