Getting Custom Attribute from Login Page to Custom Authentication Handler

59 views
Skip to first unread message

Jordan

unread,
Jul 20, 2016, 5:42:24 AM7/20/16
to CAS Community
Hi,

I have a (hopefully) simple question.

I've created a Custom Authentication Handler & Credential Class to carry out authentication against a third party application, but to also ask the user for a One Time Password (for 2 Factor Authentication).

So I'm looking to add a new field to the login page so the user provides:
  1. Username
  2. Password
  3. One Time Password

I've managed to edit the JSP to do this. The flow is getting to my Authentication Handler, where I'm getting an error that the One Time Password value is empty.

I know my credential class is being loaded properly (I've checked the logs) and its definitely hitting my Custom Authentication handled (Again I get logs from it).


So it looks like my custom parameter in the JSP isn't being passed to my Credential Class. I think this means I need to modify the login webflow to pass this new variable into the "credential" object which is passed onwards, but I'm not too sure how to do this.


Can anyone help?


XML Changes I've made so far:

  1. Edited deployerConfigContext.xml to use my new Authentication Handler
  2. Edited top line of login-webflow.xml to use my new Credential Class

Thanks

Jordan

unread,
Jul 20, 2016, 6:45:00 AM7/20/16
to CAS Community
Just a quick follow-up.

I managed to sort this out. For some reason the Username / Password are set on the Credential object automatically (maybe because I inherited from UsernamePasswordCredential?) but I need to set my custom attribute myself.
This assumes you called the variable 'oneTimePassword' in your JSP:

    <view-state id="viewLoginForm" view="casLoginView" model="credential">
       
<binder>
           
<binding property="username" required="true"/>
           
<binding property="password" required="true"/>
           
<binding property="oneTimePassword" required="true"/>
           
<!--
            <binding property="rememberMe" />
            -->

       
</binder>
       
<on-entry>
            <evaluate expression="credential.setOneTimePassword(requestParameters.oneTimePassword)"/>
           
<set name="viewScope.commandName" value="'credential'"/>

           
<!--
            <evaluate expression="samlMetadataUIParserAction" />
            -->

       
</on-entry>
       
<transition on="submit" bind="true" validate="true" to="realSubmit"/>
   
</view-state>

Thanks
Reply all
Reply to author
Forward
0 new messages