This example demonstrates how the sipgateio library can be integrated in a simple two-factor authentication service as shown on our two-factor authentication project page.
This README is a brief setup. For a more in-depth description take a look at our blog post on 2FA.
Traditionally authentication is simply performed by entering username/email and a secret password. This can be problematic when unauthorized actors get access to your credentials, since they can steal your identity. To increase security and avoid a single point of failure, two-factor authentication can be used. It sends a temporary secret over a second channel, like SMS or email. Both, the credentials and the temporary secret, are necessary for a successful login.
To be able to launch the example locally navigate to a directory where you want the example service to be stored. In a terminal you can clone the repository from GitHub and install all required dependencies using npm
.
git clone https://github.com/sipgate-io/io-labs-2fa-service.git
cd io-labs-2fa-service
npm install
Create the .env
file by copying the .env.example
. Set the values according to the comment above each variable.
The token should have the sessions:sms:write
scope. For more information about personal access tokens visit https://www.sipgate.io/rest-api/authentication\#personalAccessToken.
Run the application:
npm start
Alternatively, you can set the environment variables as part of the shell command:
SIPGATE_TOKEN_ID=your_token_id SIPGATE_TOKEN=your_token SIPGATE_SMS_EXTENSION=s0 npm start
You can access the example now in your browser on http://localhost:3000.