我查看了有关OpenID实施的PowerSchool的文档。但是,我认为它错过了重要信息,即我们如何传递所需的属性。我已经研究了其他platforms中的示例实现。但是,它们似乎与文档所讨论的不同。
在这种情况下,如何在PHP中实现PowerSchool的Open ID。经过多次努力,我已经有第三方站点成功执行握手,但是,没有检索到任何属性值,也没有错误,即使在日志中也没有。
答案 0 :(得分:0)
PowerSchool的Open ID SSO(单点登录)目前仅在从PowerSchool网站发起请求时才有效。因此,首先要创建Open ID链接插件。
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://plugin.powerschool.pearson.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation='http://plugin.powerschool.pearson.com plugin.xsd'
name="Insert Your PluginsName"
version="1.0.0"
description="Insert a description here">
<!-- The host name without scheme i.e., https. This is the host with which PowerSchool will perform the handshake -->
<!-- and will pass the attributes to. -->
<!-- NOTE: This host must have a valid SSL for this to work. -->
<openid host="www.myopenid.com">
<links>
<link display-text="Insert links display text here"
title="Insert links title here"
path="/openidlogin">
<!-- The relative path to the hostname Open ID initiation is performed on the host specified above i.e., -->
<!-- www.myopenid.com/openidlogin -->
<ui_contexts>
<!-- You may add other user contexts too i.e., guardian etc -->
<ui_context id="admin.header" />
<ui_context id="admin.left_nav" />
</ui_contexts>
</link>
</links>
</openid>
<publisher name="XYZ">
<contact email="xyzAtmyopenId.com"/>
</publisher>
</plugin>
xyzps.com/admin/home.html
转到LightOpenID并将其添加到您的项目中。
在openid主机插件中提到的路径上,即/openidlogin
添加所需的属性并重定向到身份验证网址:
$openid = new LightOpenID("Insert hostname i.e., www.myopenid.com");
$openid->identity = $_GET['openid_identifier'];
$openid->required = array(
'email'=>'http://powerschool.com/entity/email'
);
$openid->returnUrl = 'Insert SSL enabled hostname i.e., https://www.myopenid.com/authenticateopenid';
header('Location: ' . $openid->authUrl());
在继续之前,我们需要修改LightOpenID,因为它在属性前加http://axschema.org/
,因此不会返回任何属性值。要做到这一点:
导航至LightOpenID.php
- &gt; axParams()
并更改
$this->aliases[$alias] = 'http://axschema.org/' . $field;
到
$this->aliases[$alias] = $field;
导航至LightOpenID.php
- &gt; getAxAttributes()
并更改
$key = substr($this->getItem($prefix . '_type_' . $key), $length);
到
$key = $this->getItem($prefix . '_type_' . $key);
在Open ID的返回网址中指定的路径,即authenticateopenid
,验证用户并检索其属性:
$openid = new LightOpenID("Insert hostname i.e., www.myopenid.com");
if ($openid->mode)
{
if ($openid->mode == 'cancel') {
echo "User has canceled authentication !";
} elseif ($openid->validate()) {
$data = $openid->getAttributes();
$email = $data['http://powerschool.com/entity/email'];
echo "</br>Email: " . $email . "</br>";
}
else {
echo "The user has not logged in";
}
}
else {
echo "Go to PowerSchool to log in.";
}