Created
November 1, 2014 15:34
-
-
Save mpugach/0622dc8b1139d678f781 to your computer and use it in GitHub Desktop.
Rails basic auth
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
| class ApplicationController < ActionController::Base | |
| before_filter :enable_http_auth, if: :use_http_auth? | |
| private | |
| def use_http_auth? | |
| Rails.env.production? | |
| end | |
| def enable_http_auth | |
| authenticate_or_request_with_http_basic('Application') do |name, password| | |
| name == 'ved_akadem' && password == 'secret123!' | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment