1.0.36 • Published 4 years ago

password-protected v1.0.36

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

Password Protected

Zero-config, lean Express middleware for password-protecting websites.

This is useful if you'd like to make any static website or express server password protected.

There are two other similar packages in NPM, but this one: 1. Works 2. Typescript 3. Better options, with strong defaults

Examples:

  1. Basic: examples/swagger
  2. With zeit now hosting: https://private-swagger.now.sh (src)

Basic Usage

import cookieParser from 'cookie-parser';
import express from 'express';
import shrinkRay from 'shrink-ray-current';
import passwordProtected from 'password-protected';

const app = express();
app.use(express.urlencoded({extended: true}));
app.use(cookieParser());
app.use(shrinkRay());
app.use(passwordProtected({}));
app.use(express.static(__dirname + "/private")); // Serve files from the private folder
app.listen(3000, () => {
    console.info("Express is listening at http://localhost:3000");
});

Options

All options are optional.

  • pageTitle: The html title and h2 tag to display on the page
  • password: Password for the website. Default = 'superpassword'
  • jwtSecret: A secret to sign/secure tokens. Default = 'supersecret'
  • hint: Display helpful text below the login form. Default is none.
  • jwtData: Extra data to store in the token.
  • loginHtmlTemplate: Replace the default login page with whatever you want. The only requirement is that it has a form with input name='password'.
1.0.36

4 years ago

1.0.35

4 years ago

1.0.34

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.32

4 years ago

1.0.31

4 years ago

1.0.30

4 years ago

1.0.26

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago