stolfam/ms-azure-sso-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

stolfam/ms-azure-sso-php

最新稳定版本:1.0.7

Composer 安装命令:

composer require stolfam/ms-azure-sso-php

包简介

Easy-to-use PHP connector for Microsoft Azure SSO authentication

README 文档

README

Install

composer require stolfam/ms-azure-sso-php

Nette

Neon config:

parameters:
    microsoft:
        azure:
            loginBaseUri: https://login.microsoftonline.com
            apiBaseUri: https://login.windows.net
            appId: xxx
            clientSecret: xxx
            tenantId: xxx
            redirectUri: http://localhost
            refreshTokenRotationTime: 60
            refreshTokenKey: storageKey
               
services:
    - Stolfam\MS\Azure\Client(%microsoft.azure%)

Use

Redirect to Login URL:

$client = new Client($arrayArgs);
$state = "abc123";
$loginUrl = $client->getLoginUrl($state)
// redirect to $loginUrl to invoke user authentication with MS AZure

Handle returned Authorization Code:

$code = $_GET['code'];
$state = $_GET['state']; // abc123

// set callback
$client->onAuthSuccess[] = function(UserProfile $userProfile) {
    // authentication successful
    // persist user data where you need
    echo $userProfile->id;
    echo $userProfile->name;
    echo $userProfile->email;
};

if($client->authorize($code)) {
    // success
    // i.e. redirect back to original page before login invoked
}

Handle expired login:

if(!$client->isSessionValid()) {
    // session expired
    // try to re-authorize
    $client->invokeReAuthorization();
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-09-12