Skip to content

Instantly share code, notes, and snippets.

@matsimitsu
Created July 2, 2015 14:48
Show Gist options
  • Save matsimitsu/6f65157e15a86f64f25b to your computer and use it in GitHub Desktop.
Save matsimitsu/6f65157e15a86f64f25b to your computer and use it in GitHub Desktop.
module Authenticator
class Authentication
def initialize(app, options = {})
@app, @options = app, options
end
def call(env)
if authenticated?
@app.call(env)
else
# Read the body before returning data to passenger
env['rack.input'].read(1)
env['rack.input'].rewind
[
401,
{
'Content-Type'=>'text/plain',
'Content-Length' => '0',
'WWW-Authenticate' => 'Basic realm="App"'
},
[]
]
end
end
def authenticated?
false
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment