Tag: 身份validation

使用net / ldap登录LDAP登录

我试图让LDAP身份validation在Rails下工作。 我选择了net / ldap,因为它是一个原生的Ruby LDAP库。 我已经尝试了所有可能的东西,特别是来自http://net-ldap.rubyforge.org/classes/Net/LDAP.html的例子,但仍然无法使其工作。 有任何想法吗?

使用Devise进行API身份validation(Ruby on Rails)

我正在尝试使用设计配置:token_authenticatable在我的项目中通过json添加身份validation。 我有从本文中获取的工作sessions_controller #create代码 – http://blog.codebykat.com/2012/07/23/remote-api-authentication-with-rails-3-using-activeresource-and-devise / def create build_resource resource = User.find_for_database_authentication(:email => params[:email]) return invalid_login_attempt unless resource if resource.valid_password?(params[:password]) resource.ensure_authentication_token! #make sure the user has a token generated render :json => { :authentication_token => resource.authentication_token, :user_id => resource.id }, :status => :created return end end def invalid_login_attempt warden.custom_failure! render :json => { :errors => […]

修复Rails oauth facebook x-frame-options sameorigin错误

我不能为我的生活让我的Facebookcanvas应用程序显示。 Chrome控制台显示此错误,iframe中没有任何内容显示 – 它是空白的: Refused to display ‘http://mysite.dev/’ in a frame because it set ‘X-Frame-Options’ to ‘SAMEORIGIN’. 我正在使用Rails 4.0.0.rc1和omn​​iauth-facebook 1.4.1 , 以Facebook身份validation上的Railscast作为指南。 我没有使用任何Javascript代码,因为它是可选的,理想情况下应该只能在Facebook中访问应用程序。 的routes.rb match ‘auth/:provider/callback’, to: ‘sessions#create’, via: [:get, :post] match ‘auth/failure’, to: redirect(‘/’), via: [:get, :post] match ‘signout’, to: ‘sessions#destroy’, as: ‘signout’, via: [:get, :post] sessions_controller.rb class SessionsController < ApplicationController def create user […]

密码保护rails登台环境

我正在尝试找出保护我的临时环境的最佳方法。 目前我正在同一台服务器上运行暂存和生产。 我能想到的两个选择是: 使用rails摘要身份validation 我可以在application_controller.rb中放置这样的东西 # Password protection for staging environment if RAILS_ENV == ‘staging’ before_filter :authenticate_for_staging end def authenticate_for_staging success = authenticate_or_request_with_http_digest(“Staging”) do |username| if username == “staging” “staging_password” end end unless success request_http_digest_authentication(“Admin”, “Authentication failed”) end end 这是从Ryan Daigle的博客中扯下来的 。 我正在运行最新的Rails 2.3,所以我应该摆脱他们对此的安全问题。 使用Web服务器validation 我也可以使用.htaccess或apache权限实现这一点,但是它使我的服务器配置稍微复杂一些(我使用Chef,并且需要不同的apache配置用于登台/生产)。 现在我有第一个实现和工作,你看到它的问题吗? 我错过了一些明显的东西吗 提前致谢!

如何在AJAX中优雅地处理设计401的状态?

设计使用before_filter :authenticate_user! 仅限制对经过身份validation的用户的访问。 当未经身份validation的用户无论如何都试图访问受限制的页面时,设计会自动导致重定向到登录页面。 因此,尝试打开http:// localhost:3000 / users / edit将导致重定向到http:// localhost:3000 / users / sign_in 。 现在,如果我将链接http:// localhost:3000 / users / edit定义为:remote => true ,则devise将仅通过JS发出401状态代码 。 我如何优雅地处理这种情况并在覆盖或重定向中显示登录对话框, 因为非远程变体会这样做? 设计是否为我需要激活的情况提供默认策略?

如何在使用API​​密钥时跳过Devise身份validation?

我正在我的应用程序上使用Devise,并希望创建一个全局API密钥,可以访问任何人的帐户的JSON数据,而无需登录。 例如,假设我的API密钥是1234 ,我有两个用户创建了两个不同的餐厅。 用户1 – 餐厅1(/餐厅/ 1) 用户2 – 餐厅2(/餐厅/ 2) 我打开一个全新的浏览器,没有登录任何东西,我传入我的URL …/restaurants/2.json?api_key=1234 ,我应该能够访问该餐厅的JSON数据,而无需登录- 作为用户2 什么是最好的方法呢? 我已经按照Railscast#352保护API,所以我可以通过传入API密钥来访问JSON的东西,但我必须登录才能看到任何内容。 编辑1:使用CanCan 我应该提一下,我也在使用CanCan作为角色,但不确定在这种情况下是否会扮演任何角色(双关语)。 编辑2:使用API​​版本控制 我按照Railscast#350和#352教你如何创建REST API版本以及如何使用API​​密钥保护它。 这是我的controllers / api / v1 / restaurants / restaurants_controller.rb的样子: module Api module V1 class RestaurantsController < ApplicationController before_filter :restrict_access respond_to :json def index respond_with Restaurant.all end def show respond_with Restaurant.find(params[:id]) end private def […]

Rails:使用Authlogic进行基本身份validation

我正在使用Authlogic,我想在我的控制器中实现基本HTTP身份validation,以便我可以定义哪个操作需要身份validation。 我知道如何进行基本HTTP身份validationauthenticate_or_request_with_http_basic和before_filter,但我想在其他方面如何使用Authlogic插件实现它。 class ItemsController [:index, :create] … end

如何使用devise_token_auth和ActionCable来validation用户?

我有一个带有devise_token_auth gem身份validation的Rails 5 API。 现在我想要经过身份validation的用户进行个人聊天 我没有资产,因为我正在使用API​​,而前端是在本机应用程序中,我希望本机应用程序消息传递。 所以我如何使用devise_token_auth gemvalidation用户使用动作电缆进行个人消息传递

如何在用户注销后清除浏览器缓存,以防止通过“后退”按钮访问私人信息

用户退出后,如果他们点击后退按钮,他们可以在退出之前返回到他们所在的最后一页。 我正在处理的应用程序通常用于公共计算机(例如图书馆或计算机实验室),我想阻止用户查看以前用户会话中的任何内容。 我正在使用Rails 3和Devise,顺便说一下,虽然看起来这个问题会出现任何框架或登录机制。 解决方案是使用标头/元标记来禁用浏览器缓存吗? 有人知道解决这个问题的gem或教程吗? 期待您的建议。

在Rails中从Google / Yahoo检索OpenID AX属性

我在我的应用程序中使用rails插件open_id_authentication 。 这适用于MyOpenID,但是对Google进行身份validation我无法将电子邮件地址作为必需属性的一部分。 据我所知,Google忽略了sreg属性请求,并且只监听AX架构的电子邮件地址。 这是我的代码: def open_id_authentication(openid_url) #google only responds to AX for email, so we must provide that also authenticate_with_open_id(openid_url, :required => [:nickname, :email, ‘http://axschema.org/contact/email’]) do |result, identity_url, registration| if result.successful? @user = User.find_or_initialize_by_identity_url(identity_url) if @user.new_record? unless registration[’email’] || registration[‘http://axschema.org/contact/email’] failed_login “Your OpenID provider didn’t send us an email address.” return end #some providers […]