JWT Client - Cas Server

173 views
Skip to first unread message

Xavier Rodríguez

unread,
Jan 14, 2019, 10:09:57 AM1/14/19
to CAS Community
I've configured CAS-Server to return JWT and it works fine. My problem is that I don't know how configure correctly my client to read this token.
My client is configured with spring-security-cas package. In a "traditional authentication" CAS I define something similar as:

public CasAuthenticationProvider casAuthenticationProvider() {
        CasAuthenticationProvider provider = new CasAuthenticationProvider();
        provider.setServiceProperties(serviceProperties());
        provider.setTicketValidator(ticketValidator());
        ...
        provider.setUserDetailsService(
                s -> new User(...)
        ...
        return provider;
    }

In JWT case, I've to define an implementation similar to CasAuthenticationProvider that it reads the ticket (&ticket=eyJhbGciOiJIUzUxMiJ9.ZX...) received from de the cas? Any idea to do this?

Regards!

Michele Melluso

unread,
Jan 14, 2019, 10:23:13 AM1/14/19
to CAS Community
Hi,

we did it with java-jwt library. Taking inspiration from the readme, hope it helps:


regards
Michele

Xavier Rodríguez

unread,
Jan 15, 2019, 10:12:24 AM1/15/19
to CAS Community
Hi,

My question is if in this line:

       CasAuthenticationProvider provider = new CasAuthenticationProvider();

I have to modify the "CasAuthenticationProvider" to another similar: "JWTAuthenticationProvider"
 
       JWTAuthenticationProvider provider = new JWTAuthenticationProvider(..)

And I have to implement in this JWTAuthenticationProvider the  authenticate() method that only validate the "tiket" passed inthe request?

Thanks,

- Xavier -

El dilluns, 14 gener de 2019 16:23:13 UTC+1, Michele Melluso va escriure:

Michele Melluso

unread,
Jan 15, 2019, 11:15:35 AM1/15/19
to CAS Community
I think you should implement directly an AuthenticationProvider and place your custom code which validates the jwt ticket in the authenticate() method.

When using the Jwt as service ticket I guess there is no need to use any of CasAuthenticationProvider facilities, since you are not supposed to contact cas any longer ( https://apereo.github.io/cas/6.0.x/installation/Configure-ServiceTicket-JWT.html )

Hope it helps
Michele
Reply all
Reply to author
Forward
0 new messages