User Name in Cas Login Screen

37 views
Skip to first unread message

Shivam Thakur

unread,
Jun 7, 2021, 6:30:05 AM6/7/21
to CAS Community
Hi,

I have integrated CAS 5.2.4 with Keycloak as Delegate Authentication. When the user logins successfully the following message is displayed - 
"You, 7e2b774f-4586-4bd3-99aa-35c351edaebe have successfully logged into the Central Authentication Service."

This number is the user_id returned from Keycloak. 
I want to return user_name in place of user_id.

Can someone please guide me?

Thanks,
Shivam

Jeremiah Garmatter

unread,
Jun 7, 2021, 5:42:09 PM6/7/21
to CAS Community, shvm...@gmail.com
Hi Shavim,

I didn't use 5.2.4 so the names may be different. I've never used keycloak either, but maybe there is a way to change what value is released there instead of a CAS workaround.

A CAS workaround is to change the casGenericSuccessView.html file. You'll need to obtain the default casGenericSuccessView.html file, if you built CAS from one of the overlays you should be able to obtain the template by a built-in gradle or maven task I believe. I use gradle with the explodeWar task, then grab the view from ./build/cas-resources/templates/casGenericSuccessView.html and move it to ./src/main/resources/templates/ so any changes made will be applied on the next build.

Then change this line:
<p th:utext="#{screen.success.success(${authentication.principal.id})}">You, <strong>username</strong>, have successfully logged into the Central Authentication Service.
to
<p th:utext="#{screen.success.success(${authentication.principal.attributes.user_name})}">You, <strong>username</strong>, have successfully logged into the Central Authentication Service.
Or whatever your attribute is called when returned by keycloak.

and run "./gradlew clean build" or maven equivalent to rebuild the cas.war file.
Reply all
Reply to author
Forward
0 new messages