[英]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. 在PHP中,我们可以使用
$_SERVER['PHP_AUTH_PW']
从apache基本身份验证中获取用户输入的密码。
How do we go by doing this in Rails? 我们如何在Rails中做到这一点?
EDIT: $_SERVER['PHP_AUTH_USER']
is equivalent to request.env['REMOTE_USER']
. 编辑:
$_SERVER['PHP_AUTH_USER']
等同于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]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.