Git Product home page Git Product logo

lockup's Introduction

Lockup Shield

Lockup

Gem Version Build Status

A simple gem to more elegantly place a staging server or other in-progress rails application behind a basic codeword. It’s easy to implement, share with clients/collaborators, and more beautiful than the typical password-protection sheet.

“Can I come into your fort?”

“…what’s the codeword?”

(currently used in production with Rails 3.X, Rails 4.X, Rails 5.X, and Rails 6.X)

Demos and more information.

Installation

  1. Add this line to your application’s Gemfile:
gem 'lockup'
  1. Define a codeword (see Usage below).

  2. Mount the engine in your application’s routes file (usually first, for best results):

mount Lockup::Engine, at: '/lockup'

Usage

To set a codeword, define LOCKUP_CODEWORD in your environments/your_environment.rb file like so:

ENV['LOCKUP_CODEWORD'] = 'secret'

If you think you might need a hint:

ENV['LOCKUP_HINT'] = 'Something that you do not tell everyone.'

If you’re using Rails >= 4.1 or Rails >= 5.2, you can add your Lockup Codeword via Rails Secrets or Rails Credentials functionality in your secrets.yml or credentials.yml.enc file, respectively:

lockup_codeword: 'love'
lockup_hint: 'Pepé Le Pew'

Alternately, Rails Credentials in >= 5.2 may be organized under the lockup namespace:

lockup:
  codeword: 'love'
  hint: 'Pepé Le Pew'

If you’re using Figaro, set your Lockup codeword and hint (optional) in your application.yml file:

lockup_codeword: 'love'
lockup_hint: 'Pepé Le Pew'

Codewords are not case-sensitive, by design. Keep it simple.

Advanced Usage

Use Lockup around a specific controller:

  1. Follow the installation instructions above.

  2. In your application_controller.rb file, add:

skip_before_action :check_for_lockup, raise: false
  1. In the controller(s) you would like to restrict:
before_action :check_for_lockup

Link it with no typing:

http://somedomain.com/or_path/?lockup_codeword=love

The visitor is redirected and the cookie is set without them ever seeing the Lockup splash page.

(Lockup also makes a rudimentary attempt based on user agent to block major search engine bots/crawlers from following this link and indexing the site, just in case it ever gets out into the wild.)

Set a custom lifetime for cookie

The cookie set by Lockup defaults to 5 years. If you want to set a shorter amount of time, you can specify a number of weeks:

ENV['COOKIE_LIFETIME_IN_WEEKS'] = 4

cookie_lifetime_in_weeks: 4

Design Customization

If you would like to change the content or design of the lockup page, you can create the directories app/views/layouts/lockup and app/views/lockup/lockup and populate them with the default content from here, and then customize as desired.

Contribute

Pull requests are quite welcome.

Project Site (with Demo)

lockup.interdiscipline.com

lockup's People

Contributors

gblakeman avatar danrabinowitz avatar guaguasi avatar ledermann avatar mackermedia avatar ndbroadbent avatar afomera avatar dankimio avatar keymastervn avatar gcebrian-rbi avatar justinjruby avatar mvanh avatar maksimf avatar reagent avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.