简体   繁体   中英

What is the ruby on rails equivalent for $_SERVER['PHP_AUTH_PW']?

In PHP, we can use $_SERVER['PHP_AUTH_PW'] to get the password entered by the user from apache basic authentication.

How do we go by doing this in Rails?

EDIT: $_SERVER['PHP_AUTH_USER'] is equivalent to request.env['REMOTE_USER'] .

What eventually did it for me is this:

require 'base64'

user_pass = Base64.decode64(request.authorization.split(' ')[1])
username = user_pass.split(':')[0]
password = user_pass.split(':')[1]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM