<bean id="authenticationManager" class="org.jasig.cas.authentication.PolicyBasedAuthenticationManager"> <constructor-arg> <map> <!-- | IMPORTANT | Every handler requires a unique name. | If more than one instance of the same handler class is configured, you must explicitly | set its name to something other than its default name (typically the simple class name). --> <entry key-ref="proxyAuthenticationHandler" value-ref="proxyPrincipalResolver" /> <!-- <entry key-ref="primaryAuthenticationHandler" value-ref="primaryPrincipalResolver" /> --> <entry key-ref="hfcAuthenticationHandler" value-ref="primaryPrincipalResolver" /> <entry key-ref="hfcAuthenticationHandler2" value-ref="primaryPrincipalResolver" /> </map> </constructor-arg>
<!-- Uncomment the metadata populator to capture the password. <property name="authenticationMetaDataPopulators"> <util:list> <bean class="org.jasig.cas.authentication.CacheCredentialsMetaDataPopulator"/> </util:list> </property> -->
<!-- | Defines the security policy around authentication. Some alternative policies that ship with CAS: | | * NotPreventedAuthenticationPolicy - all credential must either pass or fail authentication | * AllAuthenticationPolicy - all presented credential must be authenticated successfully | * RequiredHandlerAuthenticationPolicy - specifies a handler that must authenticate its credential to pass --> <property name="authenticationPolicy"> <bean class="org.jasig.cas.authentication.RequiredHandlerAuthenticationPolicy" c:requiredHandlerName="hfcAuthenticationHandler" p:tryAll="false"/> </property> <!-- <property name="authenticationPolicy"> <bean class="org.jasig.cas.authentication.AnyAuthenticationPolicy" /> </property> --> </bean>
<bean id="hfcAuthenticationHandler" class="ch.cas.authentication.handler.HFCAuthenticationHandler" p:name="hfcAuthenticationHandler"> </bean> <bean id="hfcAuthenticationHandler2" class="ch.cas.authentication.handler.HFCAuthenticationHandler2" p:name="hfcAuthenticationHandler2"> </bean>
<bean id="serviceRegistryDao" class="org.jasig.cas.services.JsonServiceRegistryDao" c:configDirectory="${service.registry.config.location}" />--
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.
Visit this group at http://groups.google.com/a/apereo.org/group/cas-user/.
On Dec 2, 2015, at 3:43 AM, Artur Stöcklin <source...@gmail.com> wrote:Hi MisaghThank you for your reply.I do not understand. What is then the value of the "requiredHandlers" attribute in the service json file?In my case, if I define the requiredHandler as "hfcAuthenticationHandler2" which during authentication throws an AuthenticationException (login failed), but my other AuthenticationHandler "hfcAuthenticationHandler" returns success, the CAS Client user will be anyway logged in. What is then the sense of defining the requiredHandlers on the service itself?
Share logs please.
From: Claude Viéville [mailto:claude....@univ-lille1.fr]
Sent: Monday, June 13, 2016 11:19 AM
To: jasig-cas-user <jasig-c...@googlegroups.com>
Cc: cas-...@apereo.org; mmoa...@unicon.net
Subject: Re: [cas-user] JSON Service for CAS Client does not follow success message of required Handler
Hello Community,
I would like to continue this discussion as I think I have observed the same behavior.
Cas Version 4.2
Tomcat 8
In my case, Cas is configured with jpaServiceRegistryDao instead of jsonServiceRegistryDao.
I also have 2 UserNamePasswordHandlers declared in deployerConfigContext.xml (ldapAuthenticationHandler and L1ldapAuthenticationHandler)
<util:map id="authenticationHandlersResolvers">
<entry key-ref="ldapAuthenticationHandler" value="#{null}" />
<entry key-ref="L1ldapAuthenticationHandler" value="#{null}" />
<entry key-ref="proxyAuthenticationHandler" value-ref="proxyPrincipalResolver" />
</util:map>
I declared the anyAuthenticationPolicy
<alias name="anyAuthenticationPolicy" alias="authenticationPolicy" />said by
And this factory :
<alias name="requiredHandlerAuthenticationPolicyFactory" alias="authenticationPolicyFactory" />
Moreover, the boolean tryAll is set to true to enforce PolicyBasedAuthenticationManager to try all the handler before returning.
The policy could be written like that : with the credential submitted by the web form, try to authenticate with the two handlers and if, for a given service (let say S) the handler ldapAuthenticationHandler is satisfied then return true
But, as Artur said in this thread the behavior is not the one I hope. Only the first handler is tried and the authentication result is always false.
To day,I inspected the code and It seems that I could be an error : the policy returns true only if number of success added to number of failures equals number of credentials BUT NUMBER OF CREDENTIALS IS ALWAYS 1.
Do you thing it is an error or I made a misunderstanding.?
I followed my investgation by modifying the code of the PolicyBasedAuthenticationManager in order to add to the builder one credential by handler s upporting the credential (in my case 2. And, making that, the authentication process works fine in the different cas I tested !
Here is the piece of cod I modified
protected AuthenticationBuilder authenticateInternal(final Collection<Credential> credentials)
throws AuthenticationException {
final AuthenticationBuilder builder = new DefaultAuthenticationBuilder(NullPrincipal.getInstance());
/* initialize builder with credential only if it is unique for each handler supporting this type of Credential
* as to ensure authentication.credentials.size() == total of authentication attemps !
*/
if(credentials.size()==1) {
Credential credential = (Credential)(credentials.toArray()[0]);
for (final Map.Entry<AuthenticationHandler, PrincipalResolver> entry : this.handlerResolverMap.entrySet()) {
if(entry.getKey().supports(credential)) builder.addCredential(new BasicCredentialMetaData(credential));
}
} else {
for (final Credential c : credentials) {
builder.addCredential(new BasicCredentialMetaData(c));
}
}
Do you think I am in the truth or I am completly wrong ?
Thank you for your answer
Have a good day,
Claude
You wrote L1LdapAuthenticationHandler.java, correct? Can you share it as a gist, etc?
From: Claude Viéville [mailto:claude....@univ-lille1.fr]
Sent: Monday, June 20, 2016 7:03 AM
To: CAS Community <cas-...@apereo.org>
Cc: mmoa...@unicon.net
Subject: Re: [cas-user] JSON Service for CAS Client does not follow success message of required Handler
Hello Misagh,
OK, this got interesting J I was hoping I could blame your handler for doing something weird but offhand I don’t see much. So go ahead and submit and issue please, and attach your overlay to the issues project.