定制 qbnk/frontend-components-aad-oidc 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

qbnk/frontend-components-aad-oidc

Composer 安装命令:

composer require qbnk/frontend-components-aad-oidc

包简介

Azure AD OpenID Connect (hybrid flow), part of Frontend Components for Slim-based frontends.

README 文档

README

A part of the qbnk/frontend-components package.
This package contains an Azure AD Open ID connect apdater, which is used to log the user in via Azure AD, using the Open ID Connect hybrid flow.

Hybrid flow works a bit different than the normal authentication flows, since it does not require an access token. Instead an ID token is fetched, and the user is verified via that token. This means that anyone with a Microsoft account can possibly log in to the site, and it is therefore crucial that there is a defined list of tenant IDs that the user can belong to in order for the login to function.

By using the hybrid flow, there is no need for a client secret, only client ID. Because of this, no access token can be fetched.

In Azure AD, a return URL (i.e. where the id token is sent after a successful login) must be defined.
This is set automatically by the adapter, and will be the sites URL followed by /oidc/token_verification

Define the adapter in your dependencies

Frontendcomponentsaadoidc now supports Open ID Connect b2c as of version 1.0.7. Specify the needed values in your config file.

use QBNK\FrontendComponents\Auth\Adapter\OIDC;

$container[QB_AUTH_OIDC] = function(ContainerInterface $container) use ($app) {
    $settings = $container->get(QB_SETTINGS)[QB_AUTH_OIDC];
    return new OIDC($app, $settings);
};

Don't forget to register the routes in your routes.php file.

$app->getContainer()->get(QB_AUTH_OIDC)->registerRoutes($app);

Sample settings

$settings = [
    'allowedTenants' => [
        'tenant 1',
        'tenant 2',
    ],
    'allowedIssuer' => ['https://mediaportal.qbank.se'],
    'allowedAudience' => ['audience 1'],
    'clientId' => !empty($_ENV['QBANK_API_CLIENT_ID']) ? $_ENV['QBANK_API_CLIENT_ID'] : '',
    'allowExternalUsers' => true,
    'internalEmailAddresses' => ['customer.com'],
    'groupMapping' => [
        'defaultInternalUserGroups' => ['Group name' => 1],
        'defaultExternalUserGroups' => ['Group name' => 2],
    ],
    'b2c' => true,
    'p' => 'B2C_1A_SIGNUP_SIGNIN',
    'scopes' => ['openid'],
    'tenant' => 'tenantName',
    'pathAuthorize' => "/oauth2/v2.0/authorize",
    'pathToken' => "/oauth2/v2.0/token",
    'QBankUserLookup' => true, // Will try to find a user with the OIDC username in QBank, and add the user to the Identity Session
    'urlLogin' => 'https://customer.b2clogin.com/', // if using 2bc
    'defaultAlgorithm' => '', // if using 2bc
    'allowedTenants' => ['Tenant ID'],
    'usernameClaim' => 'email', // set username from claims
    'allowedIssuer' => ['customer login url'],
    'allowedAudience' => [],
    'QBankUserLookup' => true,
    'includeUserDataCookie' => true // When session is stored in cookie
];

When performing a login, call the adapater's authenticate method.

/** @var \QBNK\FrontendComponents\Auth\Adapter\OIDC $oidc */
$oidc = $this->app->getContainer()->get(QB_AUTH_OIDC);
$returnTo = 'return url';
$params = []; // Ignored
$oidc->authenticate($returnTo, $params);

Logging the user out is just unsetting the current session. Redirect the user to the logout route

$this->app->getContainer()->get(QB_ROUTER)->pathFor(OIDC::ROUTE_LOGOUT);

NB: This package currently does not support creating QBank users.

qbnk/frontend-components-aad-oidc 适用场景与选型建议

qbnk/frontend-components-aad-oidc 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 152 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 10 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 qbnk/frontend-components-aad-oidc 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 qbnk/frontend-components-aad-oidc 我们能提供哪些服务?
定制开发 / 二次开发

基于 qbnk/frontend-components-aad-oidc 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 152
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-10-20