Omniauth-Ldap Ruby 无效凭证

发布于 2024-12-23 18:26:02 字数 1750 浏览 1 评论 0原文

我是来自萨尔茨堡的学生。
我正在尝试使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

失去的东西太少 2024-12-30 18:26:02

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文