gl-events/sylius-admin-saml-plugin
Composer 安装命令:
composer require gl-events/sylius-admin-saml-plugin
包简介
SAML auth SSO plugin for Sylius.
关键字:
README 文档
README
Features
This plugin allow your admin users to sign in with SAML providers (Google, Azure, Okta, etc.)
Installation
- Add the bundle to your
composer.jsonfile:
composer require gl-events/sylius-admin-saml-plugin composer require onelogin/php-saml
- Add the plugin class to your
config/bundles.phpfile:
return [ ... GlEvents\SyliusAdminSamlPlugin\GlEventsSyliusAdminSamlPlugin::class => ['all' => true], ];
- Import the plugin defaults (registers the SSO button hook and the login-page Twig globals):
# config/packages/gl_events_sylius_admin_saml.yaml imports: - { resource: "@GlEventsSyliusAdminSamlPlugin/config/config.yaml" }
- Configure the plugin. Everything is set through the bundle configuration, no dedicated env vars are required. Generate the SP private key with
openssl genpkey -algorithm RSA -out private.key:
# config/packages/gl_events_sylius_admin_saml.yaml gl_events_sylius_admin_saml: idp: entity_id: 'https://idp.example.com/metadata' sso_url: 'https://idp.example.com/sso' slo_url: 'https://idp.example.com/slo' # optional certificate: 'MIID...' sp: private_key: | -----BEGIN PRIVATE KEY----- ... -----END PRIVATE KEY----- identifier_key: 'email' # SAML attribute holding the admin user email proxy_vars: false # true when behind an SSL-terminating reverse proxy admin_login: true # show the traditional Sylius admin login form sso_login: true # show the SSO login button
Every setting is optional and defaults to an empty string (proxy_vars to false, admin_login/sso_login to true); a missing SAML setting simply makes the SSO login fail at runtime (flash + redirect back to the login page), it never breaks the app boot. Any value may still reference an env var if you prefer, e.g. certificate: '%env(SAML_IDP_CERTIFICATE)%'.
-
Wrap the traditional admin login form so it can be toggled with
admin_login.The plugin does not override the core Sylius admin login hooks (a plugin must never override the host app's defaults). Gate the whole form with a single hook override in
config/packages/sylius_twig_hooks.yaml:
sylius_twig_hooks: hooks: 'sylius_admin.security.login.page.content': form: template: '@GlEventsSyliusAdminSamlPlugin/Security/login/page/content/form/_traditional.html.twig' context: wrapped: '@SyliusAdmin/security/login/page/content/form.html.twig'
This wraps the entire <form> (fields + CSRF) in the admin_login condition, so in SSO-only mode the form disappears cleanly. The SSO button hook is provided by the plugin on the sibling sylius_admin.security.login.page.content hook, so it stays visible regardless.
- Add in your
config/security.yamlfile:
providers: saml_provider: id: gl_events.saml_plugin.provider.saml_user firewalls: saml: pattern: ^/saml stateless: true custom_authenticator: gl_events.saml_plugin.security.saml_authenticator main: lazy: true provider: saml_provider access_control: - { path: "%sylius.security.admin_regex%/saml", role: ROLE_SUPER_ADMIN } - { path: "%sylius.security.admin_regex%/login/saml", role: PUBLIC_ACCESS } - { path: "%sylius.security.admin_regex%/login/saml/logout", role: PUBLIC_ACCESS } - { path: "%sylius.security.admin_regex%/login/saml/acs", role: PUBLIC_ACCESS } - { path: "%sylius.security.admin_regex%/login/saml/sls", role: PUBLIC_ACCESS } - { path: "%sylius.security.admin_regex%/login/saml/metadata", role: PUBLIC_ACCESS }
- Add in your
config/routes.yamlfile:
glevents_sylius_admin_saml_plugin: resource: "@GlEventsSyliusAdminSamlPlugin/config/routing.yaml"
- If your application runs behind a reverse proxy (load balancer, Kubernetes ingress, etc.) that terminates SSL, set
proxy_vars: truein yourgl_events_sylius_admin_samlconfig:
gl_events_sylius_admin_saml: proxy_vars: true
This tells the onelogin/php-saml library to read X-Forwarded-Proto, X-Forwarded-Host and X-Forwarded-Port headers when building the current URL for SAML response validation. Without this, the library detects http:// instead of https:// and rejects the SAML response with an error like "The response was received at http://... instead of https://...".
Also verify your Symfony trusted_proxies and trusted_headers settings so that $request->getScheme() also returns the correct scheme, see: https://symfony.com/doc/current/deployment/proxies.html#but-what-if-the-ip-of-my-reverse-proxy-changes-constantly
- You are now ready to go ! 🚀
Credits
Developed by GL Events.
gl-events/sylius-admin-saml-plugin 适用场景与选型建议
gl-events/sylius-admin-saml-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.41k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2024 年 11 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「SSO」 「sylius」 「saml」 「sylius-plugin」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gl-events/sylius-admin-saml-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gl-events/sylius-admin-saml-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gl-events/sylius-admin-saml-plugin 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Implementation of the Omnibus Directive for Sylius application.
Bulk export of sylius resources
Sylius plugin that integrates Addwish
Setono example plugin for Sylius.
Will translate fragments of text automatically
Use price tiers in your Sylius store.
统计信息
- 总下载量: 3.41k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-27
