Documentation

(jvx:server:security)

Multi-factor authentication

This is an old revision of the document!


A modern authentication system offers more than one check for user verification. A simple mechanism is username/password check. But the problem is often that it's not secure enough because if someone knows your username/password combination, doors are open. So an additional check is necessary to get better security. There are different techniques like:

  • enter a verification code, sent to a custom email address
  • use an app to confirm (often used for online banking)
  • use another authentication provider like Auth0, Okta, Google, …

Sure, the list is not complete but it covers common solutions.

The authentication mechanism of JVx is flexible. The default security managers are ready to use and offer base checks. The framework supports different databases and also xml files for user management. It's easy to create your own security manager if you need specific checks. If you require multi-factor authentication for your application. it's also possible with JVx because it's already built-in. JVx contains a standard implementation for common multi-factor authentication mechanism'. As usual, it's supported to implement your own multi-factor authentication.

The configuration is simple. Just wrap your existing security manager:

before:

<securitymanager>
  <class>com.sibvisions.rad.server.security.XmlSecurityManager</class>
  <userfile>users.xml</userfile>
</securitymanager>

after:

<securitymanager>
  <class>com.sibvisions.rad.server.security.mfa.MFASecurityManager</class>
  <mfa enabled="true">
    <class>com.sibvisions.rad.server.security.XmlSecurityManager</class>
    <authenticator>
      <class>com.sibvisions.rad.server.security.mfa.auth.TextInputMFAuthenticator</class>
      <!-- 
        use an implementation of: com.sibvisions.rad.server.security.mfa.auth.IPayloadNotificationHandler
        <notificationhandler></notificationhandler>
      -->
    </authenticator>
  </mfa>
  <userfile>users.xml</userfile>
</securitymanager>

The important thing is the authenticator. The TextInputMFAuthenticator creates a password/code for confirmation. It sends the code via notificationhandler. The default implementation sends an email. It's possible to create your own notification handler to send the code as SMS or use a different communication channel.

The default implementation is com.sibvisions.rad.server.security.mfa.auth.DefaultTextInputNotificationHandler. It reads the mail server configuration from config.xml:

<mail>
  <smtp>
    <host>mail.server.com</host>
    <port>587</port>
    <username>user</username>
    <password>pwd</password>
    <tlsenabled>true</tlsenabled>
    <defaultsender>Noreply <noreply@server.com></defaultsender>
  </smtp>
</mail>

The email is configured as template. The standard templates are located in package /com/sibvisions/rad/server/security/mfa/auth/. If you create custom templates, define your own package via searchpath:

<authenticator>
  <searchpath>com/myapp/mfa/auth</searchpath>
</authenticator

The template mechanism loads different files. The first one is the translation file and the second one is the template html:

  • package/translation_mfa_<language_code>.xml
  • package/translation_mfa.xml (fallback: if no language specific xml file was found)
  • package/confirmationcode_<language_code>.html
  • package/confirmationcode.html (fallback: if no language specific html file was found)

The template should contain placeholders: [CONFIRMATION_CODE], [TIMEOUT].
This placehoders will be replaced with generated values.

If no template was found, a standard email with following text will be sent:

Confirmation code: [CONFIRMATION_CODE] is valid for [TIMEOUT] seconds
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information