Guest User

Untitled

a guest
May 26th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. # This method allows the app to figure out what username and password were passed
  2. # via basic http auth. Because calling #authenticate_or_request_with_http_basic will
  3. # fail if no password was sent, I had to hack in my own check (taken from the Rails
  4. # source) to make sure that they tried to auth.
  5.  
  6. def get_credentials
  7. log_it
  8.  
  9. # Grabbed from the rails source...if the user sent auth data...
  10. if ( request.env['HTTP_AUTHORIZATION'] ||
  11. request.env['X-HTTP_AUTHORIZATION'] ||
  12. request.env['X_HTTP_AUTHORIZATION'] ||
  13. request.env['REDIRECT_X_HTTP_AUTHORIZATION']
  14. ) then
  15. authenticate_or_request_with_http_basic do |username, password|
  16. @username = username
  17. @password = password
  18. end
  19. end
  20. true
  21. end
Add Comment
Please, Sign In to add comment