Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Page Properties


Target release
Project status

Status
colourGreen
titleIn progress

Document status
Status
titleDRAFT
Document owner Alex Ivanov


...

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

...

NameTypeDefault ValueDescriptionNotes
Email
otp-delivery-sms-enablebooleantrueWhether 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-subjectstringFineract Two-Factor Authentication TokenEmail subject - supports template data
otp-delivery-email-bodystringHello {{username}}.\n\nYour OTP login token is {{token}}.Email body - supports template data
Sms
otp-delivery-sms-enablebooleanfalseWhether to enable the email delivery method

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

See Message Gateway Configuration, SMS Campaigns.

otp-delivery-sms-providerint1SMS provider ID
otp-delivery-sms-textstringYour authentication token for Fineract is {{token}}.SMS text - supports template data
Tokens
otp-token-lengthint

5

character length of the OTP
otp-token-live-timeint300validity time of the OTP request in seconds
access-token-live-timeint86400validity time of standard access token in seconds
access-token-live-time-extendedint604800validity 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

API Endpoints

There are 3 endpoints that serve two-factor authentication requests:

...

Example RequestExample Response

POST /api/v1/twofactor/validate?token=YYYYY


Arguments:

  • token(string) - mandatory, the OTP to validate
{
    "token": "cb0bb6e33fc540709d50a16eb2e555f9",
    "validFrom": 1501530702801,
    "validTo": 1501617102801
}


Invalidating Access Token
Anchor
api_invalidate
api_invalidate

Invalidates an active access token.

Requires fully authenticated user.


Example RequestExample Response

POST /api/v1/twofactor/invalidate


{
    "token": "fa368f984b0d4e96a73ea57dca4e110d"
}
{
    "resourceIdentifier": "fa368f984b0d4e96a73ea57dca4e110d"
}


Anchor
api_configure
api_configure

...