开放 ID 实施 PowerSchool PHP
Open ID Implementation PowerSchool PHP
我查看了 PowerSchool 关于 OpenID implementation. However, I believe it misses out on vital information i.e., how do we pass the required attributes. I have looked into sample implementations in other platforms 的文档。但是,它们似乎与文档所谈论的不同。
在这种情况下,我该如何在 PHP 中实施 PowerSchool 的开放 ID。经过一番努力,我已经让第 3 方网站成功执行握手,但是,没有检索到任何属性值,也没有错误,甚至在日志中也没有。
PowerSchool 的 Open ID SSO(单点登录)当前仅在从 PowerSchool 的站点发起请求时才有效。因此,从创建 Open ID link 插件开始。
SSO Link 插件
<?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>
- 将以上内容另存为 XML 文件。
- 转到管理站点,即
xyzps.com/admin/home.html
- 导航到系统 -> 系统设置 -> 插件管理配置 -> 安装 -> 安装插件 -> 启用插件。
- 插件现在应该在 ui_contexts 中提供的上下文中可见,即管理 header 和左侧导航。
LightOpenID
前往 LightOpenID 并将其添加到您的项目中。
使用 PowerSchool 和属性请求进行身份验证
在 openid 主机插件中提到的路径上,即 /openidlogin
添加所需的属性并重定向到身份验证 url:
$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
在继续之前,我们需要修改 LightOpenID,因为它在属性前加上 http://axschema.org/
前缀,因此不会 returned 属性值。为此:
导航至 LightOpenID.php
-> axParams()
并更改
$this->aliases[$alias] = 'http://axschema.org/' . $field;
到
$this->aliases[$alias] = $field;
导航至 LightOpenID.php
-> getAxAttributes()
并更改
$key = substr($this->getItem($prefix . '_type_' . $key), $length);
到
$key = $this->getItem($prefix . '_type_' . $key);
验证并检索用户的属性
在 Open ID 的 return URL 中指定的路径上,即 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.";
}
我查看了 PowerSchool 关于 OpenID implementation. However, I believe it misses out on vital information i.e., how do we pass the required attributes. I have looked into sample implementations in other platforms 的文档。但是,它们似乎与文档所谈论的不同。
在这种情况下,我该如何在 PHP 中实施 PowerSchool 的开放 ID。经过一番努力,我已经让第 3 方网站成功执行握手,但是,没有检索到任何属性值,也没有错误,甚至在日志中也没有。
PowerSchool 的 Open ID SSO(单点登录)当前仅在从 PowerSchool 的站点发起请求时才有效。因此,从创建 Open ID link 插件开始。
SSO Link 插件
<?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>
- 将以上内容另存为 XML 文件。
- 转到管理站点,即
xyzps.com/admin/home.html
- 导航到系统 -> 系统设置 -> 插件管理配置 -> 安装 -> 安装插件 -> 启用插件。
- 插件现在应该在 ui_contexts 中提供的上下文中可见,即管理 header 和左侧导航。
LightOpenID
前往 LightOpenID 并将其添加到您的项目中。
使用 PowerSchool 和属性请求进行身份验证
在 openid 主机插件中提到的路径上,即 /openidlogin
添加所需的属性并重定向到身份验证 url:
$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
在继续之前,我们需要修改 LightOpenID,因为它在属性前加上 http://axschema.org/
前缀,因此不会 returned 属性值。为此:
导航至
LightOpenID.php
->axParams()
并更改$this->aliases[$alias] = 'http://axschema.org/' . $field;
到
$this->aliases[$alias] = $field;
导航至
LightOpenID.php
->getAxAttributes()
并更改$key = substr($this->getItem($prefix . '_type_' . $key), $length);
到
$key = $this->getItem($prefix . '_type_' . $key);
验证并检索用户的属性
在 Open ID 的 return URL 中指定的路径上,即 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.";
}