belvg/sso-fpbundle

与 knpuniversity/oauth2-client-bundle 集成以提供服务

安装: 82

依赖: 0

建议者: 0

安全: 0

星星: 0

观察者: 1

分支: 0

类型:symfony-bundle

1.5.0 2023-12-12 15:58 UTC

This package is not auto-updated.

Last update: 2024-10-01 19:40:50 UTC


README

配置路由

将文件 src/config/sso_fp.yaml 复制到 config/routes

配置 knp_client 扩展包

将文件 src/config/knpu_oauth2_client.yaml 复制到 config/packages/knpu_oauth2_client.yaml

安全

src/config/security.yaml 中添加以下行

    providers:
        # used to reload user from session & other features (e.g. switch_user)
        app_user_provider:
            id: SSO\FpBundle\Provider\FactoryPortalUserProvider 
    firewalls:
        main:
            lazy: true
            provider: app_user_provider
            custom_authenticators:
                - SSO\FpBundle\Security\FactoryPortalAuthenticator
            logout:
                path: app_logout
                target: factory_portal_logout
# add to access_controll section
    access_control:
      # - { path: ^/admin, roles: ROLE_ADMIN }
      # - { path: ^/profile, roles: ROLE_USER }
      - { path: ^/connect/factoryportal, roles: PUBLIC_ACCESS }
      - { path: ^/fp_logout, roles: PUBLIC_ACCESS }
      - { path: ^/connect/factoryportal/check, roles: PUBLIC_ACCESS }
      - { path: ^/, roles: IS_AUTHENTICATED_FULLY }

服务

config/service.yaml 中添加以下行

    SSO\FpBundle\Provider\FactoryOauth2ClientProvider:
        arguments:
            $options: { clientId: '%env(OAUTH_FACTORY_PORTAL_ID)%', clientSecret: '%env(OAUTH_FACTORY_PORTAL_SECRET)%' }
        public: true
#
    app.factory.provider:
        alias: SSO\FpBundle\Provider\FactoryOauth2ClientProvider
#
#
#
    KnpU\OAuth2ClientBundle\Client\OAuth2Client:
        arguments:
            $provider: '@app.factory.provider'

配置环境变量

OAUTH_FACTORY_PORTAL_ID='<factory_portal_id>'
OAUTH_FACTORY_PORTAL_SECRET='<factory_portal_secret>'