OmniAuth 选项哈希

发布于 2024-11-13 10:07:53 字数 354 浏览 1 评论 0原文

我正在编写自己的 CAS 策略,我希望用户将我的策略传递给他们的专有名称(来自他们的证书)。根据我的理解,我的策略的用户可以传递这样的选项,

use OmniAuth::Strategies::CAS::MyStrategy :setup => true

我假设在我的策略的初始化方法中的选项标签中,我将有一个关键设置 =>真实的价值。这会传递给 CAS 类(通过 super 方法)等等。用户是否可以传递这样的选项:dn => retrieve_dn_method 来执行我上面所说的操作吗?如果是这样,父类会如何处理他们不期望的选项?

或者是否有另一种方式将选项传递到我需要验证的策略中?

I am writing my own CAS strategy and I would like the user to pass my strategy their distinguished name (from their cert). From my understanding, a user of my strategy can pass options like this

use OmniAuth::Strategies::CAS::MyStrategy :setup => true

I'm assuming in the options tag within my strategy's initialize method, I will have a key setup => value of true. This gets passed along to the CAS class (via the super method) and so forth. Could the user pass an option like this :dn => retrieve_dn_method to do what I've stated above? If so, what would the parent classes do with an option they're not expecting?

Or is there another way of passing options into my strategy that I need to authenticate?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

酷遇一生 2024-11-20 10:07:53

我认为 :setup 选项不会出现在传递到策略初始化方法中的选项哈希中。将 :setup 设置为 true 仅允许策略用户在其代码中创建设置方法以在身份验证之前完成任务。但基于此:
https://github.com/intridea/omniauth/wiki/Dynamic-Providers您的策略的用户应该能够通过以下方式设置此人的可分辨名称:

class SessionsController < ApplicationController
  def setup
    request.env['omniauth.strategy'].options[:dn] = user_dn
    render :text => "Setup complete.", :status => 404
  end
end

I don't think the :setup option will be present in the options hash which is passed into your strategy's initialize method. Setting :setup to true only allows the user of the strategy to create a setup method in their code to accomplish a task before authenticating. But based off of this:
https://github.com/intridea/omniauth/wiki/Dynamic-Providers users of your strategy should be able to set the person's distinguished name in this way:

class SessionsController < ApplicationController
  def setup
    request.env['omniauth.strategy'].options[:dn] = user_dn
    render :text => "Setup complete.", :status => 404
  end
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文