Fetching user IP in CAS

176 views
Skip to first unread message

Vikash Chandra Ansh

unread,
Jul 2, 2021, 10:21:05 AM7/2/21
to cas-...@apereo.org
Hi All,

Hope you are well. I have a small query. 
I have integrated a java application with CAS. Now I want the IP addresses of the users who are accessing my application.
Is it feasible in CAS to track this? I beleive in CAS we can track the IP or NLB of client application. Please advise

My cas version is 6.1

Thanks and regards
Vikash Chandra

Stewart

unread,
Jul 2, 2021, 11:23:23 AM7/2/21
to cas-...@apereo.org
Hi Vikash,

I'm sure there is a more elegant solutions than what I'll suggest (I'm just an amateur...).    Why not parse CAS logs for the Service Access Granted stanza, it contains the IP address?  Of course if you have lots of traffic, it might be more efficient to parse the application's server logs....

Best Regards,

Stewart

--
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
---
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/CA%2BdrvxhsoCSrqsNWU-A5fCdPeMWV7AiN05%3DTM8-a0Wd0K8yuFA%40mail.gmail.com.

Vikash Chandra Ansh

unread,
Jul 2, 2021, 12:08:07 PM7/2/21
to cas-...@apereo.org
Hi Stewart

Thanks for your reply.But in logs I can find the NLB url . What I am expecting is ,from which remote source (like personal machine IP), the user is accessing the NLB url.

Thanks and regards

Stewart

unread,
Jul 2, 2021, 12:28:18 PM7/2/21
to cas-...@apereo.org
Sure, takes a bit of parsing, but you should see something like this in your logs:

=============================================================
WHO: audit:unknown
WHAT: [result=Service Access Granted,service=https://myapp.mydomain.com/login..,principal=SimplePrincipal(id=user),requiredAttributes={}]
ACTION: SERVICE_ACCESS_ENFORCEMENT_TRIGGERED
APPLICATION: CAS
WHEN: Fri Jul 02 09:00:58 PDT 2021
CLIENT IP ADDRESS: xx.xx.xxx
SERVER IP ADDRESS: xxx.xx.xxx.xxx
=============================================================


Vikash Chandra Ansh

unread,
Jul 3, 2021, 5:19:35 AM7/3/21
to cas-...@apereo.org
Sorry Stewart,

You haven't got my query. Ok let suppose CAS server has ip 192.18.10.2 and my application IP is 168.17.102.11. Now a user from IP 10.2.3.6 is accessing my application. 

So in audit log I could find the client IP as 168.17.102.11 not the user personal Ip
 and sever Ip as 192.18.10.2.

I want the user IP 10.2.3.6. Can we able to track this in CAS?

THANKS 

Stewart

unread,
Jul 3, 2021, 7:43:00 AM7/3/21
to cas-...@apereo.org
Hi Vikash,

Apologies if I missed something here, on our installation we see end user ip addresses in the CLIENT IP line of the cas.log, not application IPs.   

Now you’ve got me curious…since you’re seeing different,  how is your app integrated/authenticating with CAS?   (For example, we use CAS via mod_auth_cas, phpCAS, and a few others — these all cause a redirection to our login page, and the CLIENT IP shows up with the end users IP)

Best Regards,

Stewart

King, Robert

unread,
Jul 5, 2021, 9:18:42 AM7/5/21
to cas-...@apereo.org

Really depends on the configuration of your CAS server.  Is it running on a servlet container, embedded or docker container?

 

For our particular case we use Tomcat as a servlet container and we had to enabled the remote ip valve in the server.xml configuration file.

 

https://groups.google.com/a/apereo.org/g/cas-user/c/5FCYwTROMz4/m/bE1suoR3AwAJ

Reply all
Reply to author
Forward
0 new messages