GSoC 2017 - Two-Factor Authentication

GSoC 2017 - Two-Factor Authentication

 

Target release

 

Project status

Completed

Document status

DRAFT

Document owner

 @Alex Ivanov

Overview

The goal of the project is to implement Two-Factor authentication for Fineract and add support for 2FA to the community-app and the Android client. With two-factor authentication enabled the system administrator will have the ability to configure how one time passwords are sent to the user - either via Email or SMS. The integration of two-factor authentication would improve the security of Fineract and its users.

During the project I will implement support for two-factor authentication into Fineract. The workflow of the process of generating and using one time passwords is described below. The existing supported front-end application(the community-app and the Android app) will be updated to support 2FA.

I would like to give as much flexibility as possible to the users and system administrator to allow for a flawless authentication without much hassle - we would allow the system administrator to select the delivery method of the one time passwords. Currently it is planned to support delivery via SMS / Email but the system should be made so it could be easily extended to support time-based one-time passwords(RFC 6238). 

Project details

Two-factor authentication workflow

 

  1. User authenticates via basic auth / Oauth2

  2. If successful, field(isTwoFactorAuthenticationRequired) indicates whether 2FA is enabled

  3. If 2FA is enabled, the client sends a request to get a list of available delivery methods to authenticated user(see Getting a list of delivery methods)

  4. The client sends a request to to generate & send OTP via their selected method(see Requesting OTP)

    1. OTP token is generated and saved in-memory

    2. Token is sent via SMS/Email bridge

    3. Information returned: OTP delivery method, delivery destination(email / phone number), OTP validity period

    4. User has at most one active OTP request. If another OTP is requested, all previous OTP requests are invalidated

  5. User receives token and the client sends it to an endpoint to validate it (see Validating OTP)

    1. If token is valid and hasn’t expired

    2. Information returned: access token, access token expiry time

  6. User sends the access token as a header(Fineract-Platform-TFA-Token) on every request

  7. User is allowed to have multiple two-factor access tokens:

    1. Can support multiple devices

  8. Client invalidates access token on logout / session end.(see Invalidating Access Token)

 

Fineract Implementation Details

Enabling Two-Factor Authentication

Two-Factor Authentication can be enabled by adding an active twofactor profile to Fineract(e.g. in application.properties or with a start parameter). -Ptwofactor=enabled parameter can be used with Gradle build job.

Bypassing two-factor authentication

Users that are granted the BYPASS_TWOFACTOR can bypass two-factor authentication. The permission has to be granted explicitly. User with ALL_FUNCTIONS permission but without BYPASS_TWOFACTOR would still be required to authenticate.

Configuration

Delivery methods and token parameters are configurable. Configuration is done via the configuration endpoint.

 

List of configuration parameters:

Name

Type

Default Value

Description

Notes

Name

Type

Default Value

Description

Notes

Email

otp-delivery-sms-enable

boolean

true

Whether to enable the email delivery method

Email delivery uses Email External Service configurations for mail sending. Please configure SMTP details before using email OTP delivery.

See External Services.

otp-delivery-email-subject

string

Fineract Two-Factor Authentication Token

Email subject - supports template data

otp-delivery-email-body

string

Hello {{username}}.\n\nYour OTP login token is {{token}}.

Email body - supports template data

Sms

otp-delivery-sms-enable

boolean

false

Whether to enable the email delivery method

SMS OTP delivery requires messaging gateway and SMS external service configured.

See Message Gateway Configuration - using a twilio account, SMS Campaigns.

otp-delivery-sms-provider

int

1

SMS provider ID

otp-delivery-sms-text

string

Your authentication token for Fineract is {{token}}.

SMS text - supports template data

Tokens

otp-token-length

int

5

character length of the OTP

 

otp-token-live-time

int

300

validity time of the OTP request in seconds

 

access-token-live-time

int

86400

validity time of standard access token in seconds

 

access-token-live-time-extended

int

604800

validity time of extended access token in seconds

 

 

Message parameters support template data. List of supported template parameters:

  • username, email, mobileno(if user has mobileno)

  • firstname, lastname

  • token, tokenlivetime

  • requestdate, requesttime

  • expiredate, expiretime

Comments