Skip to content
This repository has been archived by the owner on Nov 3, 2017. It is now read-only.

Configuring custom redirect urls for unauthorized services

dima767 edited this page Dec 16, 2012 · 2 revisions

Since version 1.0.5 of cas-addons there is an ability to configure a custom redirect URL that will be followed after a login web flow ends in the case where a registered service is configured with disabledServiceUrl extra attribute and has been disabled i.e. enabled=false

Configuration

  • Configure service(s) in servicesRegistry.conf
{
   "id":"1",
   "serviceId":"https://www.google.com",
   "name":"GOOGLE",
   "description":"Test Google service",
   "enabled":false,
   "extraAttributes":{                
       "disabledServiceUrl":"https://example.com/mySuperUnauthorizedWarningPage"
   }
}
  • Redefine the standard serviceAuthorizationCheck bean in WEB-INF/cas-servlet.xml
<bean id="serviceAuthorizationCheck" class="net.unicon.cas.addons.web.flow.ServiceAuthorizationCheckWithCustomView">
       <constructor-arg index="0" ref="servicesManager"/>
</bean>
  • Redefine the standard serviceAuthorizationCheck action state in WEB-INF/login-webflow.xml
<action-state id="serviceAuthorizationCheck">
    <evaluate expression="serviceAuthorizationCheck"/>
    <transition on="success" to="generateLoginTicket"/>
    <transition on="no" to="redirectToDisabledServiceUrl"/>
</action-state>
  • Add the definition of redirectToDisabledServiceUrl end state in WEB-INF/login-webflow.xml
<end-state id="redirectToDisabledServiceUrl" view="externalRedirect:${requestScope.disabledServiceUrl}" />
Clone this wiki locally