All Projects → VirgilSecurity → Demo Twilio Backend Nodejs

VirgilSecurity / Demo Twilio Backend Nodejs

Licence: bsd-3-clause
A sample backend that demonstrates how to generate a Virgil JWT and Twilio token used for authentication with the Virgil and Twilio services

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Demo Twilio Backend Nodejs

Virgil Crypto Php
Virgil PHP Crypto Library is a high-level cryptographic library that allows you to perform all necessary operations for secure storing and transferring data and everything required to become HIPAA and GDPR compliant.
Stars: ✭ 22 (-82.81%)
Mutual labels:  cryptography, encryption, crypto, end-to-end-encryption
Darkwire.io
End-to-end encrypted instant web chat
Stars: ✭ 594 (+364.06%)
Mutual labels:  chat, cryptography, encryption, end-to-end-encryption
Securitydriven.inferno
✅ .NET crypto done right. Professionally audited.
Stars: ✭ 501 (+291.41%)
Mutual labels:  cryptography, encryption, crypto
Securefs
Filesystem in userspace (FUSE) with transparent authenticated encryption
Stars: ✭ 518 (+304.69%)
Mutual labels:  cryptography, encryption, crypto
Acra
Database security suite. Database proxy with field-level encryption, search through encrypted data, SQL injections prevention, intrusion detection, honeypots. Supports client-side and proxy-side ("transparent") encryption. SQL, NoSQL.
Stars: ✭ 726 (+467.19%)
Mutual labels:  cryptography, encryption, crypto
Cryfs
Cryptographic filesystem for the cloud
Stars: ✭ 1,560 (+1118.75%)
Mutual labels:  cryptography, encryption, crypto
S2n Tls
s2n : an implementation of the TLS/SSL protocols
Stars: ✭ 4,029 (+3047.66%)
Mutual labels:  cryptography, encryption, crypto
Maskbook
The portal to the new, open internet. ([I:b])
Stars: ✭ 691 (+439.84%)
Mutual labels:  cryptography, encryption, crypto
Branca
🔑 Secure alternative to JWT. Authenticated Encrypted API Tokens for Go.
Stars: ✭ 147 (+14.84%)
Mutual labels:  jwt, cryptography, crypto
Fhe Toolkit Linux
IBM Fully Homomorphic Encryption Toolkit For Linux. This toolkit is a Linux based Docker container that demonstrates computing on encrypted data without decrypting it! The toolkit ships with two demos including a fully encrypted Machine Learning inference with a Neural Network and a Privacy-Preserving key-value search.
Stars: ✭ 1,123 (+777.34%)
Mutual labels:  cryptography, encryption, crypto
Featherduster
An automated, modular cryptanalysis tool; i.e., a Weapon of Math Destruction
Stars: ✭ 876 (+584.38%)
Mutual labels:  cryptography, encryption, crypto
Brandis
Brandis: End-to-end encryption for everyone
Stars: ✭ 77 (-39.84%)
Mutual labels:  demo, encryption, end-to-end-encryption
Awesome Cryptography
A curated list of cryptography resources and links.
Stars: ✭ 3,475 (+2614.84%)
Mutual labels:  cryptography, encryption, crypto
virgil-sdk-cpp
Virgil Core SDK allows developers to get up and running with Virgil Cards Service API quickly and add end-to-end security to their new or existing digital solutions to become HIPAA and GDPR compliant and more.
Stars: ✭ 18 (-85.94%)
Mutual labels:  cryptography, encryption, end-to-end-encryption
Capillary
Capillary is a library to simplify the sending of end-to-end encrypted push messages from Java-based application servers to Android clients.
Stars: ✭ 445 (+247.66%)
Mutual labels:  cryptography, crypto, end-to-end-encryption
Discordcrypt
End-To-End File & Message Encryption For Discord
Stars: ✭ 150 (+17.19%)
Mutual labels:  messenger, cryptography, encryption
Cli
🧰 A zero trust swiss army knife for working with X509, OAuth, JWT, OATH OTP, etc.
Stars: ✭ 2,151 (+1580.47%)
Mutual labels:  jwt, cryptography, encryption
Go Jose
An implementation of JOSE standards (JWE, JWS, JWT) in Go
Stars: ✭ 1,849 (+1344.53%)
Mutual labels:  jwt, encryption, crypto
Cryptogotchas
A collection of common (interesting) cryptographic mistakes.
Stars: ✭ 118 (-7.81%)
Mutual labels:  cryptography, encryption, crypto
0fc
Anonymous web chat server, built on top of Themis/WebThemis
Stars: ✭ 98 (-23.44%)
Mutual labels:  chat, cryptography, encryption

Twilio Sample Backend for Node.js

This repository contains a sample backend code that demonstrates how to combine Virgil and Twilio JWT generation, which are used for authentication with the Virgil and Twilio services.

Do not use this authentication in production. Requests to a /virgil-jwt and /twilio-jwt endpoints must be allowed for authenticated users. Use your application authorization strategy.

Prerequisites

Set up and run demo

Clone

Clone the repository from GitHub.

$ git clone https://github.com/VirgilSecurity/twilio-sample-backend-nodejs.git

Get Virgil Credentials

If you don't have an account yet, sign up for one using your e-mail.

You can download a ready-to-use .env file

  1. Navigate to the Virgil Dashboard -> Your Application -> E3Kit Section.
  2. Generate .env in the .env file section.
  3. Download the generated file, paste it into the project root folder and rename it to .env.

Or you can add the parameters manually:

To generate a Virgil JWT the following values are required:

Variable Name Description
APP_ID ID of your Virgil Application.
APP_KEY Private key of your App that is used to sign the JWTs.
APP_KEY_ID ID of your App Key. A unique string value that identifies your account in the Virgil Cloud.
  1. Copy and rename .env.example to .env.
  2. Create Application in the Virgil Dashboard, copy its APP_ID to the .env file;
  3. Create App Key and save its private key value to APP_KEY line in the .env file;
  4. Copy ID of the created key to APP_KEY_ID line in the .env file;

Get Twilio Credentials

To generate a Twilio JWT the following values are required:

Variable Name Description
TWILIO_ACCOUNT_SID Your primary Twilio account identifier - find this in the console here.
TWILIO_API_KEY_SID SID of Twilio Api Key. Used for authentication on Twilio services. Generated with TWILIO_API_SECRET
TWILIO_API_SECRET Twilio API key secret: generate one here
TWILIO_SERVICE_SID A service instance where all the data for our application is stored and scoped. Generate one in the console here.

Add this parameters to your .env file.

Install Dependencies and Run the Server

$ npm install
$ npm run start

Now, use your client code to make a request to get a JWT from the sample backend that is working on http://localhost:3000.

Along with the backend we provide a demonstration of a simple client chat interacting with Virgil API, which you can see if you navigate to http://localhost:3000 at your browser. The sample chat code is located in the the public directory.

Demo screenshot

Specification

/authenticate endpoint

This endpoint is an example of users authentication. It takes user identity and responds with unique token.

POST https://localhost:3000/authenticate HTTP/1.1
Content-type: application/json;

{
    "identity": "string"
}

Response:

{
    "authToken": "string"
}

/virgil-jwt endpoint

This endpoint checks whether a request is authenticated by an authorization header. It takes user's authToken, finds related user identity and generates a virgilToken (which is JSON Web Token) with this identity in a payload. Use this token to make authorized API calls to Virgil Cloud.

GET https://localhost:3000/virgil-jwt HTTP/1.1
Content-type: application/json;
Authorization: Bearer <authToken>

Response:

{
    "virgilToken": "string"
}

/twilio-jwt endpoint

Same as Virgil token endpoint Twilio endpoint should be protected and responds with twilioToken.

GET https://localhost:3000/twilio-jwt HTTP/1.1
Content-type: application/json;
Authorization: Bearer <authToken>

Response:

{
    "twilioToken": "string"
}

Virgil JWT Generation

To generate a Virgil JWT, you need to use the JwtGenerator class from the Virgil SDK.

const virgilCrypto = new VirgilCrypto();

const generator = new JwtGenerator({
  appId: process.env.APP_ID,
  apiKeyId: process.env.API_KEY_ID,
  apiKey: virgilCrypto.importPrivateKey(process.env.API_PRIVATE_KEY),
  accessTokenSigner: new VirgilAccessTokenSigner(virgilCrypto)
});

Then you need to provide an HTTP endpoint which will return the JWT with the user's identity as a JSON.

For more details take a look at the virgilToken.js file.

License

This library is released under the 3-clause BSD License.

Support

Our developer support team is here to help you. Find out more information on our Help Center.

You can find us on Twitter or send us email [email protected].

Also, get extra help from our support team on Slack.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].