【问题标题】:Commentable plug-in with Spring Security LDAP带有 Spring Security LDAP 的可注释插件
【发布时间】:2011-09-07 00:07:41
【问题描述】:

我正在尝试使用 Burt Beckwith 的 spring 安全框架 ldap 插件运行可注释插件。

我发现了一个类似的问题here

唯一的区别似乎是我使用的是 LDAP,而 LDAP 用户详细信息没有 ID,或者我没有看到它。

我尝试将 grails.commentable.poster.evaluator 设置为

{com.companyname.sec.User.get(org.springframework.security.core.context.SecurityContextHolder.context.authentication.principal.id)}

还有

{com.companyname.sec.User.get(principal.id)}

我在上面提到的另一个问题中建议了这两个问题。我得到的是以下错误:

groovy.lang.MissingPropertyException: No such property: id for class: org.springframework.security.ldap.userdetails.LdapUserDetailsImpl

可能的解决方案:dn

这似乎建议使用 dn 字段,但由于这是一个字符串,并且 id 是一个 Long,我认为这不是正确的选择。那么,有没有办法配置 grails.commentable.poster.evaluator 让这两个插件一起工作,或者我需要修改其中一个以获得兼容的类型(即将可评论插件更改为使用字符串,然后从 LDAP 用户详细信息中获取用户名。)?

【问题讨论】:

    标签: grails-plugin spring-ldap


    【解决方案1】:

    不使用可评论但使用 spring-security-ldap 插件。

    对我来说,这个非常简单的复制粘贴解决方案很有效:

    Solution on Grails Jira by Burt

    【讨论】:

      【解决方案2】:

      使用

      {com.companyname.sec.User.findByUsername(principal.username)}
      

      {com.companyname.sec.User.findByUsername(org.springframework.security.core.context.SecurityContextHolder.context.authentication.principal.username)}
      

      【讨论】:

        【解决方案3】:

        这给了我以下错误:

        org.grails.comments.CommentException: No [grails.commentable.poster.evaluator] setting defined or the evaluator doesn't evaluate to an entity. Please define the evaluator correctly in grails-app/conf/Config.groovy or ensure commenting is secured via your security rules
        

        我读到这意味着没有 findByUsername 方法。那么,您是否建议我创建该方法以获得 id 值?我相应地假设,这意味着我需要将 ldap 用户插入到数据库中才能生成一个 id。

        【讨论】:

        • 在挖掘了一些之后,我最终修改了 Commentable 插件。似乎唯一的解决方案是将我的 ldap 用户持久保存到数据库以生成一个 id,或者修改 Commentable 插件以使用用户名而不是 id 工作。我选择了后一个选项,只是因为它是一个相对微不足道的变化。
        猜你喜欢
        • 2011-08-15
        • 2015-05-06
        • 2014-04-01
        • 2018-08-27
        • 2011-08-01
        • 2014-01-05
        • 2015-06-11
        • 2013-06-23
        • 2016-04-13
        相关资源
        最近更新 更多