Created
July 2, 2015 14:48
-
-
Save matsimitsu/6f65157e15a86f64f25b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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