【问题标题】:Configuring authorization for JNDILdapRealm in Shiro在 Shiro 中为 JNDILdapRealm 配置授权
【发布时间】:2015-09-09 15:40:00
【问题描述】:

我的问题其实就是这个问题:Shiro JndiLdapRealm authorization against LDAP

总而言之,Shiro documentation 声明:

如果您希望基于 LDAP 架构执行授权,您必须继承该架构 (JNDILdapRealm) 并覆盖该方法 (doGetAuthorizationInfo) 以反映您组织的数据模型。

我对公认的解决方案感到困惑,因为 searchBase 是未定义的,而且它似乎是 ActiveDirectoryRealm 的一部分,而不是 JndiLdapRealm。 getRoleNamesForGroups 也未定义,但我假设在我的映射中组名是角色名。

我正在尝试获取映射 ldap 组的授权 -> Forumsys's Test Ldap Server 的 shiro 角色,然后在 doGetAuthorizationInfo 中返回这些角色。我用来配置我的子类 LdapRealm(它扩展了 JndiLdapRealm,并且适用于身份验证)的代码如下:

LdapRealm ldapRealm = new LdapRealm();
ldapRealm.setUserDnTemplate("uid={0},dc=example,dc=com");
JndiLdapContextFactory cf1 = new JndiLdapContextFactory();
cf1.setUrl("ldap://ldap.forumsys.com:389");
ldapRealm.setContextFactory(cf1);

有没有人提供功能授权代码的示例?或者是否对其他问题的已接受答案进行简单修改?

或者,有没有办法让 Forumsys 的测试服务器与 ActiveDirectoryRealm 一起工作(据我了解,它实现了授权)?

【问题讨论】:

  • 为我在 forumsys 上获得适合我的 setUserDnTemplate 竖起大拇指!

标签: java active-directory ldap jndi shiro


【解决方案1】:

所以,我想这个问题的答案是:授权将取决于 ldap 服务器如何存储角色,以及您希望如何感知角色。 Jxplorer 有助于了解结构是什么。

为了让它与 forumsys 一起工作,搜索库应该是“dc=example,dc=com”,而不是检查“memberOf”,它应该检查“ou”

【讨论】:

  • 我还将进一步跟进并在 Forumsys 上说:“用户使用组上的 uniqueMember 属性连接到他们的组,并且不直接生活在组 (ou) 下,因为他们在某些 LDAP 配置中做。”,这是另一个混​​淆点。该报价来自Forumsys page 的 cmets
猜你喜欢
  • 2012-08-23
  • 2014-07-26
  • 2015-12-24
  • 2016-09-28
  • 1970-01-01
  • 2015-12-01
  • 2012-05-11
  • 2014-12-01
  • 2014-06-02
相关资源
最近更新 更多