【发布时间】:2020-07-25 07:13:02
【问题描述】:
我开发了一个使用 asp.net 和 owin 与 Azure AD 集成的网站。我已在 AD 中将该应用程序注册为多租户应用程序,这意味着拥有工作或学校帐户的每个人都可以登录我的应用程序。很好,这就是我想要的,但是在用户通过身份验证后,我需要检查登录用户是否有权使用我的应用程序(他是否注册为用户?他有许可证吗?)推荐什么实现这一点的方法?我是否连接到 openid 连接中间件 SecurityTokenReceived 事件并在那里进行检查?
Notifications = new OpenIdConnectAuthenticationNotifications
{
SecurityTokenReceived = OnSececurityTokenReceived
}
private Task OnSececurityTokenReceived(SecurityTokenReceivedNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> context)
{
//check if this user is registered as a user of my app and has a valid license?;
return Task.FromResult(0);
}
或者有更好的方法吗?如果这是要走的路,如果不允许用户进入我的应用程序,我将如何处理它,我是否应该以某种方式中止登录过程并重定向到错误页面?
【问题讨论】:
标签: c# asp.net owin openid-connect owin-middleware