Code Monkey home page Code Monkey logo

middleman-gibberish's Introduction

NAME

middleman-gibberish

SYNOPSIS

password protected senstive web content with javascript only.

the implementation is serverless and works even on s3.

DESCRIPTION

middleman-gibberish encrypts senstive content at build time, before deployment, and wraps it with a teeny script that will prompt the user to enter a password in order to decrypt and display it. it relies on the excellent, openssl compatible, gibberish implementations for ruby and javascript:

please note that the encryption is done in ruby, the decryption is done in javascript and is therefore quite safe.

PSEUDO-CODE

  # in ruby - at build time

  file = 'index.html'

  content = IO.binread(file)

  encrypted = encrypt(content, password)

  script = <<-____
      var encrypted = #{ encrypted.to_json };
      var cookie = #{ file.to_json };

      var password = (
        get_cookie(cookie) ||
        prompt('entre teh sekrit p@ssw0rd: ')
      );

      decrypted = decrypt(encrypted);

      set_cookie(cookie, password);

      document.write(decrypted);
  ____

  IO.binwrite("index.html", "<script>#{ script }</script>")

  # and then deploy 'index.html'

INSTALL

gem install middleman-gibberish

EXAMPLES

http://ahoward.github.io/middleman-gibberish/ (password=gibberish)

USAGE

# activate the extenstion

  activate :gibberish do |gibberish|
  # set the default password

    gibberish.password = 'gibberish'

  # encrypt a page with the default password

    gibberish.encrypt 'foo.html'

  # encrypt a page with a different password

    gibberish.encrypt 'bar.html', 'p@55w0rd'

  # encrypt at set of pages with the default password

    gibberish.encrypt 'seKrit/**/**'

  # encrypt at set of pages with a different password

    gibberish.encrypt 'kayne/**/**', 'i can hold my liquor'
  end

NOTES

  • the DSL refers to files RELATIVE TO THE BUILD DIRECTORY, thus you may have to say
    gibberish.encrypt '/about-us/index.html'

vs.

    gibberish.encrypt '/about-us'

if you activated directory indexes.

  • gibberish encrypts only in the build directory via an after_build callback. this means you won't see encrypted content in development mode running middleman server: you will only see encrypted content in the build directory after running middleman build

  • if you change your config/password and rebuild it'll just work. even for people with previously set cookies.

  • cookies expire in 1 day. in a future release this'll be configurable.

  • the sytanx for what to encrypt is a file glob not regular expression. it is always interpreted relative to the build_dir of your app

DEPENDENCIES

middleman-gibberish relies on the gibberish gem, and that is handled the normal/rubygem way.

middleman-gibberish also relies on the following three javascript libs at runtime for it to function

  • jquery.js
  • jquery.cookie.js
  • gibberish.js

all three are included in this repo. if your application has checked them into source/gibberish/javascripts then they will be used, otherwise the lib uses versions hosted on github's CDN here:

if you decide to use local copies, make sure the names match exactly, that is to say, you must have jquery.js and not jquery-1.2.3.4.js in source/javascripts. if you aren't in the habbit of using symlinks it'd be a good time to figure that out.

middleman-gibberish's People

Contributors

ahoward avatar milesmatthias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

middleman-gibberish's Issues

Mixed content error on https site.

Since the resolution of issue #7 has not yet been published, I'm pointing directly to this repo. However, the logic behind determining usage of local vs external js assets is flawed.
Particularly this:
http://d.pr/i/Xv6QYM+

Should be easy fix but it seems like there is already some work that has been started to refactor that so I dont want to interfere. Just filing this for people having the same issue.

Gibberish always building off of /build/ regardless of build_dir

Hey there,

I have set :build_dir, 'my_build_folder' in my config.rb file to something other than the default build folder, but gibberish seems to always look at the build folder regardless.

Looking at the code: File.join(@app.root, 'build') โ€” could you switch build and source to read off of the :build_dir environment instead?

Thanks!

No idea what I'm doing here.

Could you post the Middleman source code for the example you put up? That would be helpful in figuring out what I'm missing in my own project.

Thanks!

undefined method `enc' for #<Gibberish::AES:0x00000006b32f80>

Hi,

I am trying to password protect my slate documentation using gibberish but each time I run bundle exec middleman build I get the following error:

undefined method `enc' for #Gibberish::AES:0x00000006b32f80

I honestly have no idea what the cause for this is. Please advise

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.