kaliop/identitymanagementbundle

Kaliop 身份管理包

0.8.1 2018-06-24 12:37 UTC

This package is auto-updated.

Last update: 2024-08-29 03:47:37 UTC


README

一个专为定制用户认证场景设计的eZ5包

  • 通过用户的IP登录
  • 使用电子邮件而不是登录名登录用户
  • 从LDAP服务器(包括MS Active Directory)获取用户帐户
  • 从外部服务获取用户帐户(需要自定义代码)
  • 允许使用自定义的symfony登录处理器通过eZ后台办公登录

基本思想是,无需学习Symfony认证组件(防火墙/认证器/用户提供者/工厂)的复杂细节,就可以轻松交换/添加远程用户服务。

因此,eZP4中的“ldap登录处理器”逻辑被复制

  1. 当用户第一次尝试登录时,从远程系统检索其配置文件,并动态创建相应的eZ用户
  2. 当用户在第一次登录后尝试登录时,从远程系统检索其配置文件,并在需要时更新相应的eZ用户

还有一些很好的功能仍然缺失,但该包应该足以开始简单的LDAP集成。

欢迎贡献 :-)

允许通过电子邮件登录

  • 无需在“登录字段”中保存用户电子邮件即可完成此操作

  • 要激活它:在parameters.yml中启用以下参数

      parameters:
          # take over the default user provider - to log him in other ways than login field
          ezpublish.security.user_provider.class: Kaliop\IdentityManagementBundle\Security\User\Provider\EmailUser
          # take over the auth provider as well, in accord
          security.authentication.provider.dao.class: Kaliop\IdentityManagementBundle\Security\Authentication\Provider\RepositoryAuthenticationProvider
    

允许通过IP登录

  • 这是通过在security.yml的firewalls部分中名为ip_login的自定义防火墙实现的。防火墙依赖于一个单独的服务,将IP映射到用户帐户名称

  • 要激活它:...

通过远程服务(LDAP/Active Directory或其他)登录

  • 内置了对LDAP的支持,需要一些配置和最小PHP代码

  • 对于其他自定义外部服务,您需要编写更多的PHP代码

  • 这是通过在security.yml的firewalls部分中名为remoteuser_login的自定义防火墙实现的

  • 防火墙依赖于两个附加服务用于

    • 与远程Web服务通信
    • 在用户登录时创建(子类)Kaliop\IdentityManagementBundle\Security\User\RemoteUser的实例
    • 将该实例映射到eZPublish用户(在登录时动态创建/更新它们)

入门:集成LDAP目录

  1. 配置到LDAP服务器的连接,例如

     services:
         # The ldap client config
         my.ldap:
             class: Symfony\Component\Ldap\LdapClient
             arguments:
                 - ldap.server.com
                 - 636
                 - 3
                 - true
    
  2. 配置从LDAP服务器检索用户帐户信息,例如

     # The service used to communicate with the LDAP server
     my.ldap_auth.client:
         class: Kaliop\IdentityManagementBundle\Adapter\LDAP\Client
         arguments:
             # NB: here you can pass in either one ldap client, or an array of clients, to achieve high-availability
             - "@my.ldap"
             -
                 # the credentials used to serach the ldap
                 search_dn: Lookup.Service@domain.com
                 search_password: abcdefg
                 # the filter used to look up the user account
                 base_dn: dc=domain,dc=com,
                 filter: "(sAMAccountName={username})"
                 # The ldap attributes to retrieve to build the user profile.
                 # NB: by default, when the value of any of these changes, the ez user account is updated
                 attributes:
                     - displayname
                     - mail
                     - telephonenumber
                     - memberof
                     - thumbnailphoto
                     - title
                 # The name of the ldap attribute used to hold the user email
                 email_attribute: mail
                 # The name of attribute used to log-in to ldap and validate the password
                 ldap_login_attribute: mail
         calls:
             - [ setLogger, [ @?logger ] ]
    
  3. 创建一个处理类,该类将RemoteUser转换为eZ用户。从Kaliop\IdentityManagementBundle\Security\User\RemoteUserHandler中派生,实现setFieldValuesFromProfile和getGroupsFromProfile

  4. 将其声明为服务,例如

     # The service which creates repo users out of ldap users
     my.ldap_auth.remoteuser_handler:
         class: My\LdapAuthBundle\Adapter\LDAP\RemoteUserHandler
         arguments:
             - "@my.ldap_auth.client"
             - "@ezpublish.api.repository"
             -
                 user_contenttype: user
                 default_content_language: eng-GB
                 group_mapping:
                     "CN=LTD_Intranet_Administrator": 12
                     "CN=LTD_Intranet_CorpContentManager": 13
    
  5. 将您的新服务绑定到LDAP客户端返回的RemoteUser类

     parameters:
         kaliop_identity.remoteuser_service_map:
             Kaliop\IdentityManagementBundle\Adapter\LDAP\RemoteUser: my.ldap_auth.remoteuser_handler
    
  6. 设置防火墙定义以激活整个系统:在security.yml中

     ezpublish_front:
         pattern: ^/
         anonymous: ~
         # Allow users to log in via LDAP.
         # The name HAS TO BE 'remoteuser_login'
         remoteuser_login:
             # the service used to connect to the LDAP server
             client: my.ldap_auth.client
         form_login:
             require_previous_session: false
         logout: ~
    

允许远程服务登录到Legacy Admin界面

  1. 启用identitymangementextension扩展(包含在此包中)

  2. 如果您已将security.yml中的防火墙重命名为除了ezpublish_front之外的任何名称,请设置identitymanagement.ini.append.php

  3. 清除缓存,测试,完成!

高级用法

为非LDAP服务创建远程用户提供者服务

  1. 创建Kaliop\IdentityManagementBundle\Security\User\RemoteUser的子类

  2. 创建一个客户端类,实现ClientInterface接口(可以参考Kaliop\IdentityManagementBundle\Adapter\LDAP\Client类)

  3. 声明新的类为服务

  4. 在security.yml的firewall部分将服务ID放入remoteuser_login

  5. 创建一个处理类,它将RemoteUser转换为eZ用户,实现RemoteUserHandlerInterface接口(可能从Kaliop\IdentityManagementBundle\Security\User\RemoteUserHandler派生是一个好主意)

  6. 将其声明为服务

  7. 将其添加到参数kaliop_identity.remoteuser_service_map中的处理器映射中

逻辑流程如下

  • 当网站访客尝试登录时,客户端将查询远程系统,如果登录成功,将从获取的数据中构建并返回一个remoteUser对象
  • 紧接着,处理器将负责匹配remoteUser与eZ用户账户,如果需要则更新/创建它

License Latest Stable Version Total Downloads

Scrutinizer Code Quality SensioLabsInsight