• Stars
    star
    113
  • Rank 310,115 (Top 7 %)
  • Language
    JavaScript
  • Created over 10 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An example Node/Express application demonstrating the use of JSON Web Tokens (JWT)

#An Node/Express Example of JWT (JSON Web Tokens)

This simple application is designed to demonstrate the principle of using JWT (JSON Web Tokens) as access tokens to protect an API.

For an overview of how it all works, read the tutorial - to follow shortly.

##Pre-requisites

Obviously you'll need Node and npm, and you also need MongoDB installed and running.

##Installing and Setting Up

Install the project dependencies:

npm install

Ensure Mongod is running, and seed the database:

node seed.js

This will create a single user:

Username: bob

Password: password

##Using It

To use it without a client application, use something like Postman, for Chrome or Poster, for Firefox.

Run the application:

node app.js

To get a token, make a GET request to:

http://localhost:3000/token

You'll need to set the headers:

username : bob

password : password

Make a note of the access token in the returned JSON.

Now try making a GET request to the following URL:

http://localhost:3000/secret

You should get a 401 Not Authorized.

However, if you set the access token; either as a GET parameter access_token or a header called x-access-token you should see the following:

Hello bob

That' it!

More Repositories

1

World-Flag-Sprites

A bunch of World flags as sprites; two styles, each with a range of sizes from 16 x 16px up to 64 x 64px
HTML
33
star
2

ocr-php-tesseract-example

A simple example application for performing Optical Character Recognition (OCR) using PHP
PHP
21
star
3

face-detection-nodejs

A simple example of a Node.js application for face detection
JavaScript
19
star
4

Drupal-Jekyll-Export

A simple Drupal module for exporting content into a format (Markdown only) suitable for Jekyll.
14
star
5

telephones-js

Some example code to demonstrate some of the ways you can deal with telephone numbers using JS and Node.js
JavaScript
12
star
6

geospatial-search-with-solr

A very simple example application which demonstrates the use of SOLR and Solarium for Geospatial search
PHP
12
star
7

Movie-Search

Part of a tutorial on using Solarium in conjunction with Apache SOLR.
PHP
12
star
8

driving-lesson-booking-widget

A widget for booking driving lessons, via the Acuity Scheduling API.
HTML
9
star
9

podcast-feed-parser

A PHP library for parsing podcast feeds
PHP
9
star
10

php-feed-writer

A PHP 7.1 + library for creating feeds (RSS, Atom, iTunes, Spotify etc)
PHP
8
star
11

ginit

"git init" on steroids
JavaScript
8
star
12

screenshotter

A PHP class for obtaining screenshots of websites / web pages. Behind the scenes it uses PhantomJS.
PHP
7
star
13

mobile-isbn-reader

A simple mobile application for reading an ISBN number from a book's barcode, then retrieving its rating from the Goodreads API.
JavaScript
5
star
14

less_concrete5

Server-side compiling for Less files within Concrete5.
PHP
4
star
15

block_extended_permissions

Extends Drupal 7's block permissions to make them more granular
PHP
4
star
16

raml-test-example

An example of how you can use RAML files when testing your API's.
PHP
4
star
17

weboftrust

Simple PHP Wrapper to the Web of Trust API (https://www.mywot.com/en/api) for getting reputation data about websites
PHP
3
star
18

manifest

A PHP library for building web application manifests
PHP
3
star
19

meta-tags

A PHP class for managing meta tags
PHP
3
star
20

image-uploads-dropzonejs-node-express

A simple example of an image upload facility using the Dropzone.js plugin on the client, and a simple Node.js/Express server-side component
HTML
3
star
21

no-follow-links

A really simple PHP class which takes some HTML, and adds rel=nofollow to any links
PHP
3
star
22

thai-cookery-school

A simple example of using Acuity Scheduling to help manage classes.
PHP
2
star
23

directory

A PHP class for manipulating a directory on a filesystem
PHP
2
star
24

Embeddable-Badges

A very simple example of generating embeddable "badges"; content which can be inserted into third-party websites.
PHP
2
star
25

laravel-jst

Generate JST templates (for Backbone apps, for example) from within Laravel.
PHP
2
star
26

legalpages

Drop-in legal pages (Privacy, Terms, Cookies) for Laravel 4 sites
PHP
2
star
27

Drupal-Markdownify

A simple wrapper module for using the Markdownify library in Drupal.
2
star
28

static-maps

A PHP class for generating static maps.
PHP
1
star
29

bmr

A small JS library for calculating BMR (Basal Metabolic Rate).
JavaScript
1
star
30

temporary-files

"Self-destructing" temporary files for Laravel (Work in progress)
PHP
1
star
31

capitalizer

A simple library for capitalizing strings intelligently.
PHP
1
star
32

laravel-cms

A lightweight, Markdown powered CMS add-on for Laravel.
PHP
1
star
33

Drupal-Followgram

Drupal module for grabbing Followgram feeds.
1
star
34

durations-js

JavaScript
1
star
35

jquery.password.js

A very simple, Bootstrap-friendly plugin for creating a "Show Password" button for a password field.
JavaScript
1
star
36

uk-postcodes

Makes working with (UK) Postcodes a breeze.
PHP
1
star
37

figdice-example-application

A simple application to demonstrate the FigDice templating engine.
PHP
1
star
38

vagrant-php5-phalcon-neo4j

A Vagrant setup which includes PHP5.5, Apache2, Phalcon and Neo4j
Ruby
1
star
39

Placefinder

Simple example of how the Yahoo! Placemaker service can be used to interpret place names.
PHP
1
star
40

laravel-email-checker

Check e-mail addresses to see if they're disposable, or issued by free providers
PHP
1
star