大佬教程收集整理的这篇文章主要介绍了ruby-on-rails – 在Ruby on Rails中,authenticate_with_http_basic做什么?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
它有什么作用?似乎能够使用来自http请求的login_name和密码,然后可以将它们与users表中的login_name和encrypted_password进行比较…但是这样,为什么甚至不存在一行描述?
class AdminController < ApplicationController before_filter :authenticate def authenticate authenticate_or_request_with_http_basic('Administration') do |username,password| username == 'admin' && password == 'password' end end end
此功能将请求基本的http身份验证用户名和密码,或者输入后,实际上会检查验证是否正确.换句话说,这个函数将调用authenticate_with_http_basic或者它将调用request_http_basic_authentication.你可以阅读更多关于它,并看到更多的例子here.你通常会调用authenticate_or_request_with_http_basic,而不是调用authenticate_with_http_basic或request_http_basic_authentication,因为前一个函数将适用于后者功能.
P.S:authenticate_with_http_basic不使用POST变量,它使用头信息来获取用户名和密码(request.env [‘http_AUTHORIZATION’]).您可以查看有关授权功能here的更多信息.
以上是大佬教程为你收集整理的ruby-on-rails – 在Ruby on Rails中,authenticate_with_http_basic做什么?全部内容,希望文章能够帮你解决ruby-on-rails – 在Ruby on Rails中,authenticate_with_http_basic做什么?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。