Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Dimitri Duszynski
CAS authentication in IFrame
April 30, 2008 1:24 AM
Answer

Dimitri Duszynski

Rank: New Member

Posts: 19

Join Date: March 18, 2008

Recent Posts

Hello everybody,

I have successfully integrating CAS with Liferay 5.0 but I would like that the login on CAS be performed in an IFrame rather than be redirect to the CAS login page and then redirect back to liferay.
So I have put an IFrame which point to the CAS login URL but when I submit the information, only the IFrame portlet tells me that I am successfully authenticated and I 'm always on the liferay login page.

How I can redirect the user successfully authenticated in Liferay ??

P.S : I found a solution here but I can't understand how to make it work : IFrame redirect Solution

Thanks,

Greetings
Dimitri Duszynski
RE: CAS authentication in IFrame
May 3, 2008 10:21 AM
Answer

Dimitri Duszynski

Rank: New Member

Posts: 19

Join Date: March 18, 2008

Recent Posts

Any ideas ???
Alvaro Manso
RE: CAS authentication in IFrame
May 5, 2008 12:56 AM
Answer

Alvaro Manso

Rank: Junior Member

Posts: 28

Join Date: February 29, 2008

Recent Posts

You have to modify the Cas-Server, in the last step of the login flow you have to resize the iframe with javascript for use the parent window.
Dimitri Duszynski
RE: CAS authentication in IFrame
May 8, 2008 4:46 AM
Answer

Dimitri Duszynski

Rank: New Member

Posts: 19

Join Date: March 18, 2008

Recent Posts

Hello,

Thanks for your reply.

After a few searches in the CAS-WEB folder, I've found the file login-webflow.xml but I don't know what I have to modify.
In the last state I have :
1
2<!-- The "redirect" end state allows CAS to properly end the workflow while still redirecting the
3user back to the service required -->
4<end-state id="redirect" view="bean:dynamicRedirectViewSelector" />


It's in this bean that I have to make changes ??

Thanks,

Greetings,
Alvaro Manso
RE: CAS authentication in IFrame
May 8, 2008 7:34 AM
Answer

Alvaro Manso

Rank: Junior Member

Posts: 28

Join Date: February 29, 2008

Recent Posts

I think you should ask in the CAS-DEV mailing list about this topic, anyway this is my what I did for the same problem.

If you search in cas-servlet.xml, you'll see that class for the bean dynamicRedirectViewSelector is org.jasig.cas.web.flow.DynamicRedirectViewSelector.

This is the original method that you have to modify in the class DynamicRedirectViewSelector :
 1
 2public ViewSelection makeEntrySelection(final RequestContext request) {
 3        final WebApplicationService service = WebUtils.getService(request);
 4        final String ticket = WebUtils.getServiceTicketFromRequestScope(request);
 5        final Response serviceResponse = service.getResponse(ticket);
 6            
 7        switch (serviceResponse.getResponseType()) {
 8            case POST:
 9                final Map<String, Object> model = new HashMap<String, Object>();
10                model.put("parameters", serviceResponse.getAttributes());
11                model.put("originalUrl", service.getId());
12                return new ApplicationView("postResponseView", model);
13               
14            default:
15                return new ExternalRedirect(service.getResponse(ticket).getUrl());
16        }
17    }

I my case, I debbuged the execution and my response type is never POST, so my execution go always for default
I change the default case of the switch:
 1
 2default:
 3               // original code
 4                //return new ExternalRedirect(service.getResponse(ticket).getUrl());
 5               
 6                /*
 7                 *Customized code for redirect the url to the top window.
 8                 */
 9         
10               final Map<String, Object> modelAux = new HashMap<String, Object>();
11                modelAux.put("service", service.getResponse(ticket).getUrl());
12                return new ApplicationView("redirectView", modelAux);         

I created a new view in WEB_INF/classes/protocol_view.properties
I added to the end of the file

1### Redirect View
2redirectView.(class)=org.springframework.web.servlet.view.JstlView
3redirectView.url=/WEB-INF/view/jsp/protocol/redirect.jsp


And this is my redirect.jsp
 1
 2<html>
 3<head>
 4<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 5
 6<script type="text/javascript">
 7function redirect(){
 8    window.top.location.href = document.redirect.service.value;
 9}
10
11</script>
12</head>
13<body onload="redirect()">
14    <form name="redirect" action="">
15        <input type="hidden" name="service" id="service" value="${service}" />
16    </form>
17</body>
18</html>


Recapping,
You have to:
Customize the org.jasig.cas.web.flow.DynamicRedirectViewSelector.
Create a new cas-server-corexxxx.jar and overwrite the old one (you'll find it in WEB-INF/lib)
Modify WEB-INF/classes/protocol_view.properties for adding your new view
Create the new view
Create the new cas-web.war
Deploy it

Hope it Helps!
Dimitri Duszynski
RE: CAS authentication in IFrame
May 9, 2008 2:00 AM
Answer

Dimitri Duszynski

Rank: New Member

Posts: 19

Join Date: March 18, 2008

Recent Posts

Hello,

Help me a lot to understand.

But that it works for you because for me the problem is still there.
I have put a println() in the modded DynamicRedirectViewSelector to see what happened but
I don't find this log in my tomcat console and only the iframe is still redirected. Its look like that I never go
to the method or the bean is never called ??
I have also read your post in the CAS-DEV mailing list.

Thanks,
Alvaro Manso
RE: CAS authentication in IFrame
May 13, 2008 12:31 AM
Answer

Alvaro Manso

Rank: Junior Member

Posts: 28

Join Date: February 29, 2008

Recent Posts

Maybe you are using a different authentication mode or something like that.... I don't know, sorry.
I'd try to debug the execution, If you are using Eclipse it is easy to use the debug option, you just need to start tomcat with the jpda option and debug the application as Java Remote Application, It will help you much more than the log.
dori wal wal
RE: CAS authentication in IFrame
September 23, 2008 7:17 AM
Answer

dori wal wal

Rank: New Member

Posts: 3

Join Date: September 23, 2008

Recent Posts

Hi

the problem that i have now is that only the cas portlet is refresh and user can see that his user/pwd are correct but the liferay home page is not render and user is still not log in to liferay

i looked at
http://www.liferay.com/web/guest/community/forums/-/message_boards/message/85547?_19_redirect=%2Fweb%2Fguest%2Fcommunity%2Fforums%3Fp_p_id%3D19%26p_p_lifecycle%3D0%26p_p_state%3Dmaximized%26p_p_mode%3Dview%26_19_struts_action%3D%252Fmessage_boards%252Fsearch%26_19_redirect%3D%252Fweb%252Fguest%252Fcommunity%252Fforums%26_19_breadcrumbsCategoryId%3D0%26_19_breadcrumbsMessageId%3D0%26_19_searchCategoryId%3D0%26_19_searchCategoryIds%3D0%26_19_threadId%3D0%26_19_tabs1TabsScroll%3D%26_19_keywords%3Diframe%2Bcas


And i didn't understand the step

"you must to set the service in CAS to a page which redirects to /c/portal/login."

i tried to put in the Enterprise admin counsel a value to the Service URL like

"http://localhost:8080/web/guest/home/dd.jsp"

but it looks like nothing happened i expected for an error because this page is not even exist !!!


can u please say how to set a value to that parameter and where in liferay i need to create that file

also i wanted to know if its needed to do all the server side steps
like changing DynamicRedirectViewSelector.java


thanks
Praj C
RE: CAS authentication in IFrame
February 25, 2009 9:16 AM
Answer

Praj C

Rank: New Member

Posts: 2

Join Date: February 25, 2009

Recent Posts

I came across the same problem, and here is how I fixed it.

Have the Liferay IFrame portlet point to CAS.
configure IFrame portlet as
Source URL : https://xyz:8444/cas-server-webapp-3.3.1/login?service=http://xyz:8080/c/portal/login

Since you specify the service URL for CAS, it will redirect you to the liferay home page on successful login.

Hope this helps !
Chandra Rajput
RE: CAS authentication in IFrame
August 13, 2010 1:59 PM
Answer

Chandra Rajput

Rank: New Member

Posts: 3

Join Date: June 3, 2010

Recent Posts

when i am doing this it goes into infinite loop. Please help
Balazs Zsoldos
RE: CAS authentication in IFrame
August 13, 2010 3:44 PM
Answer

Balazs Zsoldos

Rank: Junior Member

Posts: 41

Join Date: April 11, 2006

Recent Posts

Hi,

for me when I used IFrame only the following javascript worked (within the IFrame):

top.window.location = 'http://...';

This redirects the browser so if you change the code of CAS to redirect in this way that might helps.

Regards,
Balazs