athlan/revive-symfony-security-bundle

Google Web Designer 托管工具横幅

1.0.1 2016-07-13 20:04 UTC

This package is auto-updated.

Last update: 2024-08-29 04:37:32 UTC


README

travis license version

此包允许您通过提供 Revive Aderver 凭据来启用 Symfony Security 认证。

它允许您在 Symfony 框架中围绕 Revive 构建自定义工具。

安装

  1. 添加 composer 依赖项
    "require": {
        // ...

        "athlan/revive-symfony-security-bundle": "1.0.0"

        // ...
    },
  1. 将包添加到 AppKernel.php
    public function registerBundles()
    {
        $bundles = [
        
            // ...
            
            new Revive\ReviveAuthenticationBundle\ReviveAuthenticationBundle(),
            
            // ...

  1. 在您的容器中定义几个服务
services:
    # create user session repository service
    revive_user_sessions:
        parent: revive_authentication.repository.user_session.xml_rpc
        arguments:
            # you can provide here custom configured xml_rpc client or get the existing pre-configured one
            - "@revive_authentication.xml_rpc.client"

            # address to your Revive xml-rpc
            # Example: http://domain.com/www/api/v2/xmlrpc/
            # you can use parameter mechanism here
            - "%revive_service_url%"

    # create form-autehnticacor that exchanges UsernamePasswordToken from user provided form
    # to ReviveAuthenticationToken
    revive_authenticator:
        parent: revive_authentication.authenticator.login_form_authenticator
        arguments: ["@revive_user_sessions"]

    # create logout listener to destroy remote sessions (optional, but recommended)
    revive_authenticator_logout_handler:
        parent: revive_authentication.authenticator.logout_handler
        arguments: ["@revive_user_sessions"]

  1. 配置 security.yml
security:
    # regiter Revive user provider
    providers:
        revive:
            id: revive_authentication.user_provider.revive_user_prototype

    firewalls:
        main:
            anonymous: ~
            simple_form:
                # regiter Revive form authenticator
                authenticator: revive_authenticator
                check_path: /login
                login_path: /login
                csrf_token_generator: security.csrf.token_manager
            logout:
                path: /logout
                target: /
                handlers: [ revive_authenticator_logout_handler ]

    access_control:
        - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/, roles: IS_AUTHENTICATED_FULLY }