作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在我的应用程序中使用 open id,并且我已经成功地使用了 DotNetOpenId .
现在,谷歌为公司域名下的电子邮件和其他服务提供服务。 (例如 example@acompany.com)。有没有办法只对公司用户进行身份验证?
我知道我可以通过检查回复中的电子邮件地址来做到这一点。但我不认为这是一个好主意。如果用户未通过 acompany.com 以外的 Google 帐户进行身份验证,则更好。
请注意,我不知道 Open Authentication 或 DotNetOpenId 的内部逻辑。
编辑
默认谷歌的openId请求提示https://accounts.google.com/ServiceLogin?...
我可以手动将它(在浏览器中)更改为 https://accounts.google.com/a/iit.du.ac.bd/ServiceLogin?...
它有效(iit.du.ac.bd
是我学校的域名)
我试图创建请求
Identifier id1 = Identifier.Parse("https://www.google.com/a/iit.du.ac.bd");
Identifier id2= Identifier.Parse("https://www.google.com/a/iit.du.ac.bd/accounts/o8/id");
var openid = new OpenIdRelyingParty();
IAuthenticationRequest request1 = openid.CreateRequest(id1);
IAuthenticationRequest request2 = openid.CreateRequest(id2);
https://www.google.com/accounts/o8/id"
最佳答案
您对使用电子邮件地址作为过滤器的犹豫是绝对正确的。跟随你的直觉。 :)
您应该过滤 OP Endpoint。这不仅可以向您保证 Google 是提供商,而且 Google 为每个单独的域都有一个专用的 OP 端点,因此您可以检查它。
IAuthenticationResponse response = relyingParty.GetResponse();
if (response != null) {
if (response.Provider.Uri.AbsoluteUri == "http://google.com/o8/....?domain=yourcompany.com") {
// Allow it
} else {
// Disallow it
}
}
关于asp.net-mvc-3 - 谷歌 OpenId : Accept only users of a particular company,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11244077/
我是一名优秀的程序员,十分优秀!