简体   繁体   中英

Delegate/forward Kerberos tickets with Spring Security

I'm trying to find information whether the Spring Security implementation of Kerberos handles delegation/forwarding of ticket granting tickets so that my app server can call other Kerberos services reusing the principals TGT? Any documentation on this would be highly appreciated. Cheers!

This is possible since the release of Spring Security Kerberos 1.0.0.

The SunJaasKerberosTicketValidator can be configured to store the authentication context:

ticketValidator.setHoldOnToGSSContext(true);

Here's some code to get you started:

Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

if (authentication instanceof KerberosServiceRequestToken) {
    KerberosServiceRequestToken token = (KerberosServiceRequestToken) authentication;

    if (token.getTicketValidation() == null) {
        // No delegation possible...
    } else {
        GSSContext context = token.getTicketValidation().getGssContext();

        // ...
    }
}

Spring security does not implement any Kerberos functionality. If you are referring to the kerberos extension then the answer is no. It only does authentication and it's just a wrapper around the Java JAAS API Krb5LoginModule .

As Koraktor mentioned, SunJaasKerberosTicketValidator class has the details which are equivalent to the JAAS config file. However, SunJaasKerberosTicketValidator has isInitiator flag set to false. This causes context.getCredDeleg() to return false, and you can not delegate the credentials. I have done a POC where my observation is the delegation/forward works only if isInitiator is set to true.

I solved this issue by writing my own TicketValidator , everything from SunJaasKerberosTicketValidator kept as it is, except, changed the entry of isInitiator flag to options.put("isInitiator", "true");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM