将Azure广告中的TYPO3 fe_用户与SAML2连接的最佳方式是什么?
我需要在TYPO3 intranet上实现SSO,其中fe_用户从Azure广告同步。平台将在V9中。 是否有我尚未找到的兼容扩展? 如果没有,用SAML2.0实现自动身份验证的最佳方法是什么? 提前感谢,,将Azure广告中的TYPO3 fe_用户与SAML2连接的最佳方式是什么?,typo3,azure-active-directory,saml-2.0,typo3-9.x,Typo3,Azure Active Directory,Saml 2.0,Typo3 9.x,我需要在TYPO3 intranet上实现SSO,其中fe_用户从Azure广告同步。平台将在V9中。 是否有我尚未找到的兼容扩展? 如果没有,用SAML2.0实现自动身份验证的最佳方法是什么? 提前感谢,, 瑞秋是的,我们解决了这个问题。我们使用SimpleSAMLphp实现身份验证,遵循这一伟大的教程: . 当您能够连接时,您只需实现一个流程,在获得saml用户属性时自动连接fe_用户 以下是该过程的简化摘要: 如果我们在未经身份验证的情况下访问TYPO3站点url,则重定向到如下脚本:
瑞秋是的,我们解决了这个问题。我们使用SimpleSAMLphp实现身份验证,遵循这一伟大的教程: . 当您能够连接时,您只需实现一个流程,在获得saml用户属性时自动连接fe_用户 以下是该过程的简化摘要: 如果我们在未经身份验证的情况下访问TYPO3站点url,则重定向到如下脚本:
// SimpleSamlPHP library
require_once (dirname(__FILE__) . /../../../../../../simplesamlphp/lib/_autoload.php');
//instanciation of a simple authentication
$as = new SimpleSAML_Auth_Simple('default-sp');
//requires authentication from Office 365
$as->requireAuth();
//retrieving information from the logged-in user
$attributes = $as->getAttributes();
//retrieve original url
$returnURL = $_GET['returnURL'];
//if a user is well connected
if($attributes){
//redirection to the TYPO3 site with the username
header('Location: /auth/?samlUident='.$attributes['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name'][0].'&recupURL='.$returnURL);
}
下面是对auth页所做工作的简化摘要:
//if a get saml is in the url
if(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('samlUident')){
//recovering username for TYPO3 authentication
$loginData = array(
'uname' => \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('samlUident'), //username
'status' => 'login'
);
//TYPO3 session creation
$frontendUserAuthentication = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Authentication\\FrontendUserAuthentication');
$frontendUserAuthentication->checkPid = false;
$info = $frontendUserAuthentication->getAuthInfoArray();
$user_db = $frontendUserAuthentication->fetchUserRecord($info['db_user'], $loginData['uname']);
//if a user exists
if ($user_db){
//authentication
$GLOBALS['TSFE']->fe_user->forceSetCookie = TRUE;
$GLOBALS['TSFE']->fe_user->dontSetCookie = false;
$GLOBALS['TSFE']->fe_user->start();
$GLOBALS['TSFE']->fe_user->createUserSession($user_db);
$GLOBALS['TSFE']->fe_user->user = $user_db;
$GLOBALS['TSFE']->fe_user->setAndSaveSessionData('dummy', TRUE);
$GLOBALS['TSFE']->fe_user->loginUser = 1;
}
}
干杯,
Rachel多亏了@Rakel(和其他人),我终于解决了SAML认证需求。尽管如此,我还是使用了一种稍有不同且更直接的方法,然后在她的解决方案中进行了描述
我使用身份验证服务来实现SAML登录过程。
为了处理SAML登录本身,我使用了库,这是我真正推荐的。它非常简单,所提供的用于测试SAML配置的前端非常方便,可以在不处理TYPO3的情况下测试Identity Provider(Idp)配置
详情请参阅:
首先,您需要创建一个扩展TYPO3\CMS\Core\Authentication\AuthenticationService的类。此类必须实现方法“getUser”和“authUser”
namespace Vendor\Extension\Service;
use SimpleSAML\Auth\Simple;
use TYPO3\CMS\Core\Authentication\AuthenticationService;
class SamlAuth extends AuthenticationService
{
public function getUser() {
// Create new Simple Auth with SimpleSamlPHP
$as = new Simple($config['sp']);
// Require authentication, this redirects you to the Idp and then comes back
$as->requireAuth();
// Get the attributes provides by your Idp
$attributes = $as->getAttributes();
// Please consult the API for details on fetchUserRecord
// Also the SAML attributes may vary depending on your Idp implementation
$user = $this->fetchUserRecord($attributes['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name'];
}
public function authUser(array $user): int {
return is_array($user) ? 200 : 0;
}
}
然后,您需要在扩展“ext_localconf.php”中注册该服务
请注意:
- 这只是我最终代码的过度简化版本。只是为了让你开始这个想法
- 此外,还需要正确配置SimpleSamlPHP。请查看他们的文档以了解详细信息李>
谢谢所有帮助我的人。非常感谢。你好,拉克尔。我应该和你在这里描述的一样。关于这个话题有什么提示或信息吗?你解决你的需求了吗?如果您能提供任何信息,我将不胜感激。谢谢克劳斯·克劳斯。是的,我们解决了这个问题。我们使用SimpleSAMLphp实现身份验证,遵循以下伟大的教程:。当您能够连接时,您只需实现一个过程,在获得saml用户属性时自动连接fe_用户。非常感谢你的帖子。我将在下周一详细调查此事,周五是我的休息日;-)。祝你周末愉快。再次感谢。您是如何将SimpleSamlPHP库集成到您的扩展中的?很抱歉回答得太晚。我使用了“SimpleSamlPHP”编写器库。
...
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addService(
'my_extension',
'auth',
Vendor\Extension\Service\SamlAuth::class,
[
'title' => 'Saml Authentication for Frontend Users',
'description' => 'Authenticates FeUsers via Saml',
'subtype' => 'authUserFE,getUserFE',
'available' => true,
'priority' => 80,
'quality' => 80,
'os' => '',
'exec' => '',
'className' => Vendor\Extension\Service\SamlAuth::class
]
);
...