Sha256: 963426d3629fdcf84b9b59d33b94751cb79667319c5ca7b71ee4c8506e9f306e

Contents?: true

Size: 431 Bytes

Versions: 4

Compression:

Stored size: 431 Bytes

Contents

module PasswordProtectedHelpers
  if ENV['HEADER_PASSWORDS']
    PW_ARRAY = ENV['HEADER_PASSWORDS'].split(',').map { |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

4 entries across 4 versions & 1 rubygems

Version Path
napa-0.1.7 lib/generators/templates/scaffold/lib/password_protected_helpers.rb
napa-0.1.6 lib/generators/templates/scaffold/lib/password_protected_helpers.rb
napa-0.1.4 lib/generators/templates/scaffold/lib/password_protected_helpers.rb
napa-0.1.3 lib/generators/templates/scaffold/lib/password_protected_helpers.rb