Sha256: 8bbed68e96093d934a5c471ad9434bfbd711ab48bb36dd6830a83266be50c137

Contents?: true

Size: 443 Bytes

Versions: 3

Compression:

Stored size: 443 Bytes

Contents

module PasswordProtectedHelpers
  if ENV['HEADER_PASSWORDS']
    PW_ARRAY = ENV['HEADER_PASSWORDS'].split(',').collect{|pw| pw.strip}.freeze 
  else
    PW_ARRAY = [nil].freeze
  end

  def authenticate headers
    error!({:error => {
      :code => 'bad_password', 
      :message => 'bad password'}}
    ) unless PW_ARRAY.include? headers['Password']
  end

  # extend all endpoints to include this
  Grape::Endpoint.send :include, self
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
napa-0.1.2 lib/generators/templates/scaffold/lib/password_protected_helpers.rb
napa-0.1.1 lib/generators/templates/scaffold/lib/password_protected_helpers.rb
napa-0.1.0 lib/generators/templates/scaffold/lib/password_protected_helpers.rb