Skip to content

Commit

Permalink
added trusted authn web flow
Browse files Browse the repository at this point in the history
  • Loading branch information
SavvasMisaghMoayyed committed Nov 24, 2015
1 parent 5d411e7 commit f04bc85
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 25 deletions.
16 changes: 2 additions & 14 deletions cas-server-documentation/installation/Trusted-Authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,10 @@ Update `deployerConfigContext.xml` according to the following template:

{% highlight xml %}
...
<entry key-ref="trustedHandler" value-ref="trustedPrincipalResolver" />
<entry key-ref="principalBearingCredentialsAuthenticationHandler"
value-ref="trustedPrincipalResolver" />
<util:list id="authenticationMetadataPopulators">
<ref bean="successfulHandlerMetaDataPopulator" />
</util:list>
...
{% endhighlight %}

## Configure Webflow Components
Add an additional state to `login-webflow.xml`:

{% highlight xml %}
<action-state id="remoteAuthenticate">
<evaluate expression="principalFromRemoteAction" />
<transition on="success" to="sendTicketGrantingTicket" />
<transition on="error" to="viewLoginForm" />
</action-state>
{% endhighlight %}

Replace references to `viewLoginForm` in existing states with `remoteAuthenticate`.
6 changes: 6 additions & 0 deletions cas-server-support-trusted-webflow/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

description = 'Apereo CAS WS-Federation Webflow Support'
dependencies {
compile project(':cas-server-core-webflow')
compile project(':cas-server-support-trusted')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.jasig.cas.web.flow;

import org.springframework.stereotype.Component;
import org.springframework.webflow.engine.ActionState;
import org.springframework.webflow.engine.Flow;
import org.springframework.webflow.engine.TargetStateResolver;
import org.springframework.webflow.engine.Transition;
import org.springframework.webflow.engine.TransitionableState;

import java.util.Iterator;

/**
* The {@link TrustedAuthenticationWebflowConfigurer} is responsible for
* adjusting the CAS webflow context for trusted authn integration.
*
* @author Misagh Moayyed
* @since 4.2
*/
@Component("trustedWebflowConfigurer")
public class TrustedAuthenticationWebflowConfigurer extends AbstractCasWebflowConfigurer {

@Override
protected void doInitialize() throws Exception {
final Flow flow = getLoginFlow();
final ActionState actionState = createActionState(flow, "remoteAuthenticate", createEvaluateAction("principalFromRemoteUserAction"));
actionState.getTransitionSet().add(createTransition(TRANSITION_ID_SUCCESS, TRANSITION_ID_SEND_TICKET_GRANTING_TICKET));
actionState.getTransitionSet().add(createTransition(TRANSITION_ID_ERROR, getStartState(flow).getId()));
setStartState(flow, actionState);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.jasig.cas.authentication.principal.PersonDirectoryPrincipalResolver;
import org.jasig.cas.authentication.Credential;
import org.springframework.stereotype.Component;

/**
* Extracts the Principal out of PrincipalBearingCredential. It is very simple
Expand All @@ -11,6 +12,7 @@
* @author Andrew Petro
* @since 3.0.0.5
*/
@Component("trustedPrincipalResolver")
public final class PrincipalBearingPrincipalResolver extends PersonDirectoryPrincipalResolver {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.jasig.cas.web.support.WebUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import org.springframework.webflow.execution.RequestContext;

Expand All @@ -21,6 +22,7 @@
* @author Scott Battaglia
* @since 3.0.0.5
*/
@Component("principalFromRemoteUserAction")
public final class PrincipalFromRequestRemoteUserNonInteractiveCredentialsAction
extends AbstractNonInteractiveCredentialsAction {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.jasig.cas.web.support.WebUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.webflow.execution.RequestContext;

import javax.servlet.http.HttpServletRequest;
Expand All @@ -19,8 +20,9 @@
* it could not find any credentials.
*
* @author Scott Battaglia
* @since 3.0.0.5
* @since 3.0.5
*/
@Component("principalFromRemoteUserPrincipalAction")
public final class PrincipalFromRequestUserPrincipalNonInteractiveCredentialsAction
extends AbstractNonInteractiveCredentialsAction {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,4 @@
http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd">


<bean id="principalFromRemoteAction"
class="org.jasig.cas.adaptors.trusted.web.flow.PrincipalFromRequestRemoteUserNonInteractiveCredentialsAction"
p:centralAuthenticationService-ref="centralAuthenticationService" />

<bean id="trustedHandler"
class="org.jasig.cas.adaptors.trusted.authentication.handler.support.PrincipalBearingCredentialsAuthenticationHandler" />

<bean id="trustedPrincipalResolver"
class="org.jasig.cas.adaptors.trusted.authentication.principal.PrincipalBearingPrincipalResolver" />

</beans>
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ include ':cas-server-support-wsfederation-webflow'
include ':cas-server-support-radius'
include ':cas-server-support-spnego'
include ':cas-server-support-trusted'
include ':cas-server-support-trusted-webflow'
include ':cas-server-support-x509'
include ':cas-server-support-oauth'
include ':cas-server-support-pac4j'
Expand Down

0 comments on commit f04bc85

Please sign in to comment.