Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
141 lines (92 sloc) 2.56 KB

Haventec Authenticate sample server

This is a sample server to demonstrate how to communicate with the Haventec Authenticate server. This server is NOT intended to be used in a Production environment.

Getting Started

Download the sample server from GitHub Haventec

Prerequisites

Install NodeJS

Install NPM

Installing

Install the dependencies within the root folder

npm install

Configure the server

Create a config file (rename the template file)

Linux / Mac:

mv config.js.template config.js

Windows:

rem config.js.template config.js

Edit the config.js file

Linux / Mac:

vi config.js

Windows:

config.js

Add your API key

Your API key is available in Cloud Portal account under Applications

config.application.apiKey = 'xxxx-xxxx-xxxx-xxxx-xxxx';

Configure the mail server (Optional)

This is optional, if you do not configure your mail server the activation and reset codes will also be outputted to the server console (not recommended for Production)

This Sample server includes a mail module to send activation and reset codes to your users

You can run this sample server without the mail module

Leave the mail configurations blank if you do not want to send emails

config.mail.host = ''

If you wish to use the mail functionality and do not have an existing mail server, you can create one for free: https://support.google.com/a/answer/176600?hl=en

Testing your mail server

Call the test email endpoint

 http://localhost:8080/test-email?email=name@example.com

Running

Start the server

npm start 

Testing your server

Go to

http://localhost:8080/

Running on AWS Lambda

In the config file set:

config.aws.lambda = true;

Zip up the following files

zip -r htss.zip node_modules index.js config.js

Upload the htss.zip to your AWS Lambda function

Testing on AWS Lambda

Set the Lambda test event to

{
  "path": "/"
}

You should see a 200 response and no errors

To test your email set the Lambda test event to

{
  "path": "/test-email?email=your.email@example.com"
}

Built With

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details