Skip to content

vikasjayaram/auth0-node-api-sample

 
 

Repository files navigation

What is it?

A sample Resource API with CRUD ops protected by JWT scopes (access_token) & postgres backend The domain object (account) corresponds to a typical Auth0 Custom DB table and this API can therefore act as a webservice fronting Postgres for Custom DB HTTP endpoint access (from Rules, Custom DB Scripts or other webtasks).

Companion Repo

See auth0-react-redux-api-client

Running locally

To run the sample extension locally:

Rename .env.sample as .env and add the required values for each key value pair.

$ npm install
$ npm start

Alternatively, just do node server.js - useful for running in debug mode etc

Then go to http://localhost:3001/api/v1/accounts

To use as Custom DB

The endpoints include the REST endpoints to handle account management & custom signup requirements from within an application - see companion React-Redux project for insights on a UI layer to this API.

However, this project also includes endpoints for integration with the Auth0 Custom DB scripts. To run the API locally yet have it called from Auth0 Dashboard scripts, use ngrok to expose your locally running instance over the internet.

Install ngrok using npm i ngrok -g

To expose the running application over internet use:

ngrok http 3001 -bind-tls=false

Now use the generated endpoints in configuration.ENDPOINT etc of your custom db scripts.

Postgres Relational DB

This uses a very simple, single postgres table. Details as follows

select column_name, data_type, character_maximum_length
from INFORMATION_SCHEMA.COLUMNS where table_name = 'accounts';


id    character varying    255
email    character varying    255
password    character varying    255
nickname    character varying    255
employee_id    character varying    255
company_code    character varying    255
email_verified    character varying    255
createdAt    timestamp with time zone    
updatedAt    timestamp with time zone  


Deploying as Webtask

Rename .env.sample as .env and add the required values for each key value pair.

$ ./deploy 

Then go to your webtask URL endpoint + /api/v1/accounts

What is Auth0?

Auth0 helps you to:

  • Add authentication with multiple authentication sources, either social like Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, among others, or enterprise identity systems like Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider.
  • Add authentication through more traditional username/password databases.
  • Add support for linking different user accounts with the same user.
  • Support for generating signed Json Web Tokens to call your APIs and flow the user identity securely.
  • Analytics of how, when and where users are logging in.
  • Pull data from other sources and add it to the user profile, through JavaScript rules.

Create a free Auth0 Account

  1. Go to Auth0 and click Sign Up.
  2. Use Google, GitHub or Microsoft Account to login.

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.

Author

Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.

About

Sample secured node api using JWT token scopes verification (access_token

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 97.5%
  • Shell 2.5%