市值: $2.194T -0.11%
成交额(24h): $64.9084B 1.19%
  • 市值: $2.194T -0.11%
  • 成交额(24h): $64.9084B 1.19%
  • 恐惧与贪婪指数:
  • 市值: $2.194T -0.11%
加密货币
话题
百科
资讯
加密话题
视频
热门新闻
加密货币
话题
百科
资讯
加密话题
视频
bitcoin
bitcoin

$87959.907984 USD

1.34%

ethereum
ethereum

$2920.497338 USD

3.04%

tether
tether

$0.999775 USD

0.00%

xrp
xrp

$2.237324 USD

8.12%

bnb
bnb

$860.243768 USD

0.90%

solana
solana

$138.089498 USD

5.43%

usd-coin
usd-coin

$0.999807 USD

0.01%

tron
tron

$0.272801 USD

-1.53%

dogecoin
dogecoin

$0.150904 USD

2.96%

cardano
cardano

$0.421635 USD

1.97%

hyperliquid
hyperliquid

$32.152445 USD

2.23%

bitcoin-cash
bitcoin-cash

$533.301069 USD

-1.94%

chainlink
chainlink

$12.953417 USD

2.68%

unus-sed-leo
unus-sed-leo

$9.535951 USD

0.73%

zcash
zcash

$521.483386 USD

-2.87%

加密货币新闻

如何由客户为我的 SaaS 应用程序配置 SAML 配置

2024/05/27 05:03

对于我的 SaaS 应用程序,我想由客户配置 SAML 配置。我希望能够更改我的 Symfony One Login Bundle 的配置,以适应客户的需求配置。

如何由客户为我的 SaaS 应用程序配置 SAML 配置

This guide will help you configure SAML SSO for your Symfony application on a per-customer basis. You'll need to adjust the configuration of the Symfony One Login Bundle to match the specific requirements of each customer.

本指南将帮助您根据每个客户为 Symfony 应用程序配置 SAML SSO。您需要调整 Symfony One Login Bundle 的配置以满足每位客户的特定要求。

First, determine the appropriate bundle based on your Symfony version:

首先,根据您的 Symfony 版本确定合适的包:

* For Symfony 6, install the nbgrp/onelogin-saml-bundle from GitHub.

* 对于 Symfony 6,从 GitHub 安装 nbgrp/onelogin-saml-bundle。

* For earlier Symfony versions, start with the hslaovich/OneloginSamlBundle from GitHub.

* 对于早期的 Symfony 版本,请从 GitHub 上的 hslaovich/OneloginSamlBundle 开始。

Next, add the default configuration. If this step is skipped, the application will fail to function properly. Edit the config/packages/nbgrp_onelogin_saml.yaml file as follows:

接下来,添加默认配置。如果跳过此步骤,应用程序将无法正常运行。编辑 config/packages/nbgrp_onelogin_saml.yaml 文件,如下所示:

```yaml

````yaml

nbgrp_onelogin_saml:

nbgrp_onelogin_saml:

idp:

国内流离失所者:

default:

默认:

settings:

设置:

assertionConsumerService:

断言消费者服务:

url: '%env(SAML_ASSERTION_CONSUMER_SERVICE)%'

url: '%env(SAML_ASSERTION_CONSUMER_SERVICE)%'

issuer: '%env(SAML_ISSUER)%'

颁发者:“%env(SAML_ISSUER)%”

spEntityId: '%env(SAML_SP_ENTITY_ID)%'

spEntityId: '%env(SAML_SP_ENTITY_ID)%'

x509cert: '%env(SAML_X509_CERT)%'

x509cert: '%env(SAML_X509_CERT)%'

```

````

Update the config/packages/security.yaml file as well:

同时更新 config/packages/security.yaml 文件:

```yaml

````yaml

security:

安全:

encoders:

编码器:

Symfony\Component\Security\Core\User\User: plaintext

Symfony\Component\Security\Core\User\User:明文

providers:

提供者:

saml:

萨姆尔:

nbgrp_onelogin_saml

nbgrp_onelogin_saml

firewalls:

防火墙:

main:

主要的:

saml:

萨姆尔:

path: ^/saml

路径:^/saml

provider: saml

提供商:saml

entry_point: nbgrp_onelogin_saml_entry_point

入口点:nbgrp_onelogin_saml_entry_point

logout_entry_point: nbgrp_onelogin_saml_logout_entry_point

注销入口点:nbgrp_onelogin_saml_logout_entry_point

logout_success_handler: nbgrp_onelogin_saml_logout_success_handler

logout_success_handler:nbgrp_onelogin_saml_logout_success_handler

logout:

登出:

path: ^/logout$

路径:^/注销$

```

````

The nbgrp/onelogin-saml-bundle utilizes compilerpass to inject configuration into a registry in an array indexed by idp, which is then used throughout the application. We'll override this functionality and load the configuration dynamically from the database based on the hostname.

nbgrp/onelogin-saml-bundle 利用compilerpass 将配置注入到由 idp 索引的数组中的注册表中,然后在整个应用程序中使用该注册表。我们将覆盖此功能并根据主机名从数据库动态加载配置。

Create a new service in the api/config/services.yaml file:

在 api/config/services.yaml 文件中创建一个新服务:

```yaml

````yaml

services:

服务:

app.saml_configuration_loader:

app.saml_configuration_loader:

class: App\Security\SamlConfigurationLoader

类:App\Security\SamlConfigurationLoader

arguments:

论点:

- '@doctrine.orm.default_entity_manager'

- '@doctrine.orm.default_entity_manager'

```

````

Override relevant portions of the bundle:

覆盖捆绑包的相关部分:

Those files will be overridden to enable dynamic configuration of the login controller, metadata, and authenticator.

这些文件将被覆盖,以启用登录控制器、元数据和身份验证器的动态配置。

Login Controller

登录控制器

Override the api/vendor/nbgrp/onelogin-saml-bundle/src/Controller/Login.php file to utilize our configuration.

覆盖 api/vendor/nbgrp/onelogin-saml-bundle/src/Controller/Login.php 文件以利用我们的配置。

In the __construct method, we autowire and add our service.

在 __construct 方法中,我们自动装配并添加我们的服务。

```php

````php

use App\Security\SamlConfigurationLoader;

使用App\Security\SamlConfigurationLoader;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

使用 Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

use Symfony\Component\DependencyInjection\ContainerInterface;

使用 Symfony\Component\DependencyInjection\ContainerInterface;

use Symfony\Component\HttpFoundation\Request;

使用 Symfony\Component\HttpFoundation\Request;

use Symfony\Component\HttpFoundation\Response;

使用 Symfony\Component\HttpFoundation\Response;

use Symfony\Component\Routing\Annotation\Route;

使用 Symfony\Component\Routing\Annotation\Route;

use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;

使用 Symfony\Component\Security\Http\Authentication\AuthenticationUtils;

class LoginController extends AbstractController

LoginController 类扩展 AbstractController

{

{

private $samlConfigurationLoader;

私人$samlConfigurationLoader;

public function __construct(ContainerInterface $container, SamlConfigurationLoader $samlConfigurationLoader)

公共函数 __construct(ContainerInterface $container, SamlConfigurationLoader $samlConfigurationLoader)

{

{

parent::__construct($container);

父级::__construct($container);

$this->samlConfigurationLoader = $samlConfigurationLoader;

$this->samlConfigurationLoader = $samlConfigurationLoader;

}

}

*/

public function login(AuthenticationUtils $authenticationUtils, Request $request): Response

公共函数登录(AuthenticationUtils $authenticationUtils,请求$request):响应

{

{

$host = $request->server->get('HTTP_HOST');

$host = $request->server->get('HTTP_HOST');

$samlSettings = $this->samlConfigurationLoader->getSettingsFromHost($host);

$samlSettings = $this->samlConfigurationLoader->getSettingsFromHost($host);

// ...

// ...

}

}

}

}

```

````

Metadata

元数据

Line 19: Add our service.

第 19 行:添加我们的服务。

```php

````php

use App\Security\SamlConfigurationLoader;

使用App\Security\SamlConfigurationLoader;

use Symfony\Component\DependencyInjection\ContainerInterface;

使用 Symfony\Component\DependencyInjection\ContainerInterface;

class MetadataController extends Controller

类 MetadataController 扩展了 Controller

{

{

public static function create(ContainerInterface $container): MetadataController

公共静态函数创建(ContainerInterface $container):MetadataController

{

{

$samlConfigurationLoader = $container->get(SamlConfigurationLoader::class);

$samlConfigurationLoader = $container->get(SamlConfigurationLoader::class);

return new self($samlConfigurationLoader);

返回新的 self($samlConfigurationLoader);

}

}

public function __invoke(Request $request): Response

公共函数 __invoke(Request $request): 响应

{

{

$host = $request->server->get('HTTP_HOST');

$host = $request->server->get('HTTP_HOST');

$samlSettings = $this->samlConfigurationLoader->getSettingsFromHost($host);

$samlSettings = $this->samlConfigurationLoader->getSettingsFromHost($host);

// ...

// ...

}

}

}

}

```

````

免责声明:info@kdj.com

所提供的信息并非交易建议。根据本文提供的信息进行的任何投资,kdj.com不承担任何责任。加密货币具有高波动性,强烈建议您深入研究后,谨慎投资!

如您认为本网站上使用的内容侵犯了您的版权,请立即联系我们(info@kdj.com),我们将及时删除。

2026年07月31日 发表的其他文章