Last week, I have written a tutorial
how to integrate Pentaho to CAS. Now I want to share about .NET application to CAS. For me it is important because it is useless to integrate Pentaho to CAS if we don't have other application to be integrated with. I'm doing Pentaho integration to CAS to integrate MaxLogistix: a low cost cloud warehouse management system (WMS) that my team developed. The goal is we want to integrate Pentaho to our application (in my case that application is MaxLogistix) without passing username and password parameter. I have explained this in previous tutorials:
- Embed Pentaho Report Viewer to Web Application
- Integrating Pentaho to CAS
This tutorial is based on tutorial and sample from
https://www.everit.biz/web/guest/everit-blog/-/blogs/single-sign-out-with-cas-in-net and improved some codes to make it working perfectly.
Jasig has already released its .NET CAS client provider. You can check it from
Jasig official .NET CAS Client. But in my case I can't use it because I'm not using pure ASP .NET form. Furthermore I'm not using ASP .NET tag at all because I'm using
Castle Framework especially
Monorail and
ActiveRecord. I must use different approach to integrate MaxLogistix to CAS. Then I found and tried this wonderful
.NET CAS tutorial. The result is.... it's working!
When I open
http://localhost:50780/default.aspx from my web browser, I'm redirected to CAS login screen
https://localhost:8443/cas/login?service=http://localhost:50780/CASLogin.aspx. Login service is working well.
Login from CAS bring me to
http://localhost:50780/default.aspx and it shows welcoming screen and Pentaho Report Viewer that I embed using iframe.
|
Pentaho Report Viewer in .NET using CAS |
|
I also open Pentaho and it shows Home screen, not login screen. Seems CAS working well.
Is it done? Not yet because I haven't tried single sign out. Let's try single sign out. I log out directly from CAS server.
And I refresh Pentaho Home screen, I'm redirected to CAS login screen.
|
Pentaho Logged Out from CAS |
|
BUT... when I refreshed
http://localhost:50780/default.aspx, I got
INTERESTING view. I wasn't redirected to CAS login screen and still in welcome screen, but the embedded Pentaho Report Viewer showed CAS login screen.
The question is... was I logged out or still logged in CAS? The answer is I was already logged out from CAS. Open
https://localhost:8443/cas and it will bring you to login screen.
Furthermore, I always got this error when I was debugging this sample
After spent several hours debugging and learning this source code, I found two things that made these two problems.
- When CAS logging out, .NET sample application still hold its ticket in its session so that it won't bring us to login screen. The solution is adding several codes to remove ticket from session when get logout request from CAS.
- There is an overlap event between checking ticket function and other function. When checking ticket function triggered (via timer), another function hasn't finished its process. The error is created because a function is trying to read a variable that locked in another function. The solution for this problem is adding exception handler that do nothing when this overlap event happened.
I added several codes to original sample codes and redid the same steps (login and logout). Tada.. now .NET sample application also logged out when I log out from CAS.
Now we can embed Pentaho dashboard and report viewer using CAS perfectly ;)
My sample code doesn't use URL Rewrite so that it won't be displayed in other browser but Chrome. You can use URL Rewrite I wrote about in
Embed Pentaho Report Viewer.
No comments:
Post a Comment