ruby-on-rails - 无法使用自定义设计策略
问题描述
我使用 devise 在我的 rails 应用程序上添加了一个身份验证层。我必须设置 LDAP 身份验证。因此,我创建了自己的策略,我从字面上遵循了这篇wiki 文章。但是,我收到了这个错误:
11: from /home/mcdostone/X/app/models/user.rb:3:in `<main>'
10: from /home/mcdostone/X/app/models/user.rb:4:in `<class:User>'
...
/home/mcdostone/.rvm/gems/ruby-2.5.1/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/active_support.rb:74:in `block in load_missing_constant': uninitialized constant Devise::Models::LdapAuthenticatable (NameError)
class User < ApplicationRecord
devise :ldap_authenticatable
end
解决方案
看起来那个wiki页面已经过时了。您现在需要一个LdapAuthenticatable
模块Devise::Models
以及Devise::Strategies
.
config/initializers/ldap_authenticatable.rb
module Devise
module Models
module LdapAuthenticatable
extend ActiveSupport::Concern
end
end
module Strategies
class LdapAuthenticatable < Authenticatable
... same as before ...
end
end
end
我真的建议您改用此gem,因为您需要进行许多调整才能使其正常工作。
推荐阅读
- java - 解析失败:Lcom/google/common/collect/ImmutableMap;在 com.my.app.di.DaggerMyApplicationComponent.getMapOfClassOfAndProviderOfFactoryOf(
- javascript - Firefox 遇到具体自定义选择框的问题
- r - R中stlm()函数中使用的默认模型
- java - Spring Security 主体改造
- javascript - 需要建议。如何使用 AJAX 验证表单而不是在服务器上造成额外负载?
- javascript - 使用 map 函数返回 jsx
- android - 如何在后台自定义打开/关闭推送通知并杀死
- python - tkinter 中的 refreshText 小部件
- ios - Objective-c 语法和 C 语法的不同结果
- angularjs - Angular cli:在 ngUpgrade 混合项目中包含 angularjs 组件样式