Omniauth-Ldap Ruby 无效凭证
我是来自萨尔茨堡的学生。
我正在尝试使用omnitauth-ldap通过ldap创建登录可能性,当我输入用户名和密码时,它会使用message=invalid_credentials
重定向到/auth/failure
,但我不这样做不知道为什么。 Facebook、Twitter 和 BrowserID 登录正常。
- Ruby 版本:1.9.2
- Omni-Auth 版本:1.0.1
- Omniauth-Ldap 版本:1.0.2omniauth.rb
users_controller.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :browser_id
provider :facebook, '34234234234', '23423421234123412342134'
provider :twitter, 'dfgsdfgsdfg', '2334sadfasdfasdf'
provider :ldap, :title => 'FH-Authentifizierung',
:host => 'denise.core.fh-salzburg.ac.at',
:port => 636,
:method => :plain,
:base => 'o=fh-salzburg.ac.at,o=FHS',
:uid => 'uid',
:password => "password",
:try_sasl => false,
:bind_dn => "anonymous"
end
服务器
class UsersController < ApplicationController
def create
auth = request.env["omniauth.auth"]
user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth)
session[:user_id] = user.id
redirect_to request.referer, :notice => "Herzlich Willkommen!"
end
def destroy
session[:user_id] = nil
redirect_to request.referer, :notice => "Du wurdest erfolgreich abgemeldet!"
end
end
输出
Started POST "/auth/ldap/callback" for 127.0.0.1 at 2012-01-03 21:59:35 +0100
Started GET "/auth/failure?message=ldap_error" for 127.0.0.1 at 2012-01-03 21:59:35 +0100
Started GET "/auth/failure?message=invalid_credentials" for 127.0.0.1 at 2012-01-03 21:59:35 +0100
Started GET "/auth/failure?message=invalid_credentials" for 127.0.0.1 at 2012-01-03 21:59:35 +0100
I am student from salzburg.
I am trying to create a login possibility via ldap with omnitauth-ldap, when I enter username and password it is redirecting to /auth/failure
with message=invalid_credentials
and I don't know why. Facebook-, Twitter- and BrowserID-Login is working.
- Ruby-Version: 1.9.2
- Omni-Auth-Version: 1.0.1
- Omniauth-Ldap-Version: 1.0.2
omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :browser_id
provider :facebook, '34234234234', '23423421234123412342134'
provider :twitter, 'dfgsdfgsdfg', '2334sadfasdfasdf'
provider :ldap, :title => 'FH-Authentifizierung',
:host => 'denise.core.fh-salzburg.ac.at',
:port => 636,
:method => :plain,
:base => 'o=fh-salzburg.ac.at,o=FHS',
:uid => 'uid',
:password => "password",
:try_sasl => false,
:bind_dn => "anonymous"
end
users_controller.rb
class UsersController < ApplicationController
def create
auth = request.env["omniauth.auth"]
user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth)
session[:user_id] = user.id
redirect_to request.referer, :notice => "Herzlich Willkommen!"
end
def destroy
session[:user_id] = nil
redirect_to request.referer, :notice => "Du wurdest erfolgreich abgemeldet!"
end
end
server-output
Started POST "/auth/ldap/callback" for 127.0.0.1 at 2012-01-03 21:59:35 +0100
Started GET "/auth/failure?message=ldap_error" for 127.0.0.1 at 2012-01-03 21:59:35 +0100
Started GET "/auth/failure?message=invalid_credentials" for 127.0.0.1 at 2012-01-03 21:59:35 +0100
Started GET "/auth/failure?message=invalid_credentials" for 127.0.0.1 at 2012-01-03 21:59:35 +0100
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您查看 omniauth-ldap 代码 你会看到bind_dn和password用于身份验证,因此它们需要有效。如果您想要匿名访问,请忽略这两个参数,或将 :allow_anonymous 设置为 true。
If you look at the omniauth-ldap code you will see that bind_dn and password are used for authentication, so they need to be valid. If you want anonymous access omit those two parameters, or set :allow_anonymous to true.