npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lee-wfaa/gatsby-plugin-password-protect

v1.0.1

Published

Add client-side password protection.

Downloads

57

Readme

Gatsby Plugin Password Protect

A client-side password protection plugin.

IMPORTANT Because this is client-side only, there is no way to 100% protect your password from unwanted visitors. This plugin was built to prevent the casual visitor from viewing content.

Installation

  1. Currently, this plugin is meant to be used locally until a more secure version is released. To install, simply place the code in your site's plugins folder in the root of your project.

Your directory structure will look similar to this:

/my-gatsby-site
├── gatsby-config.js
└── /src
    └── /pages
        └── /index.js
├── /plugins
    └── /gatsby-plugin-password-protect
├── gatsby-browser.js
├── gatsby-node.js
├── gatsby-ssr.js
├── index.js
├── package.json
└── README.md
  1. Include the plugin in a Gatsby site

Inside of the gatsby-config.js file of your site, include the plugin in the plugins array:

module.exports = {
  plugins: [
    // other gatsby plugins
    // ...
    {
      resolve: 'gatsby-plugin-password-protect',
      options: {
        /** ...plugin options **/
      },
    },
  ],
}

Build Process

After updating code in the /src directory, simply run npm run build to create the 3 necessary files in the root directory:

  1. gatsby-node.js
  2. gastby-browser.js
  3. gatsby-ssr.js

These files are required to run the plugin in your Gatsby site.

Plugin Options

enabled

Turns on/off the password protection. This must be explicitly set to true or "true" to activate password protection.

Field type: Boolean

Default value: false

{
  resolve: `gatsby-plugin-password-protect`,
  options: {
    enabled: true // or 'true'
  }
}

password

The password to protect your site with. The password must be at three characters long and is required when enabled equals true.

Field type: String

{
  resolve: `gatsby-plugin-password-protect`,
  options: {
    password: 'password!'
  }
}

expiration

The expiration time, in seconds, for a valid session. Default value is 24 hours.

Field type: Number

Default value: 86400

{
  resolve: `gatsby-plugin-password-protect`,
  options: {
    expiration: 172800
  }
}

storageKey

The name of the local storage key where your session will be stored.

Field type: String

Default value: gppp

{
  resolve: `gatsby-plugin-password-protect`,
  options: {
    storageKey: 'local-storage-key'
  }
}

publicKey

A random string used for client-side encryption of your session. This is required when enabled equals true. This can be changed at anytime, however, it will invalidate all current sessions.

Field type: String

{
  resolve: `gatsby-plugin-password-protect`,
  options: {
    publicKey: 'MO|-#l 2#4v%q^&-IHgA0,,aWF-sWYA{!/=jR]3{>SlX90Z-4SQ,F2xyX7<%X,/+'
  }
}

loadingMessage

The message to appear when validating the current session.

Field type: String

Default value: Authenticating

{
  resolve: `gatsby-plugin-password-protect`,
  options: {
    loadingMessage: 'Validing your session...'
  }
}

loginHeading

The heading of the login form.

Field type: String

Default value: This site is password protected

{
  resolve: `gatsby-plugin-password-protect`,
  options: {
    loginHeading: 'Validing your session...'
  }
}

loginButtonText

The login submit button text.

Field type: String

Default value: View site

{
  resolve: `gatsby-plugin-password-protect`,
  options: {
    loginButtonText: 'Validing your session...'
  }
}