IdentityServer3 中的回调,当前 ASP.NET Identity Session ID 可供访问
Callback in IdentityServer3, with current ASP.NET Identity Session ID available to access
我正在使用 IdentityServer3 实施单点登录 (SSO) 解决方案。我有托管 IdenitityServer 的 ASP.NET 4.5.2 (MVC) 应用程序。我需要跟踪所有登录用户并将他们的 activity 存储在数据库中。那是在我的自定义身份服务器中登录时,我需要记录发布的 ASP.NET 身份会话 ID 以及用户的 ID。然后,当使用其中一个客户端应用程序时,它会向我的自定义身份服务器发送一个信号。该信号包含 ASP.NET 身份会话。此信号用于检测所有客户端的 activity,因此我的自定义身份服务器可以延长用户会话的有效性。请注意,如果用户决定登录到另一个客户端,则需要此逻辑。
我现在面临的技术挑战是在 Identity Server 中找到一个位置,它发生在本地登录之后,并且包含当前 ASP.NET Identitiy 会话 ID。
到目前为止,我在自定义 IUserService 中发现了以下我可以实现的函数:
// Summary:
// This method is called prior to the user
// being issued a login cookie for IdentityServer.
//
// Parameters:
// context:
// The context.
public virtual Task PostAuthenticateAsync(PostAuthenticationContext context);
在我的自定义 IUserService 中,我注入了 IOwinContext,但正如评论所述,此函数在用户获取 IdentityServer cookie 发布之前被调用。
我浏览了 IdentityServer3 的 documentation,但找不到一个地方可以在管道中插入自定义代码,在完全登录发生后执行。我需要这样的地方,这样我就可以向我的数据库写入一个新用户当前已登录,并且 ASP.NET identitiy session id 属于他。
查看 IEventService——这为您提供了 IdentityServer 中 activity 的强类型 activity 相关通知。 https://identityserver.github.io/Documentation/docsv2/configuration/events.html
我正在使用 IdentityServer3 实施单点登录 (SSO) 解决方案。我有托管 IdenitityServer 的 ASP.NET 4.5.2 (MVC) 应用程序。我需要跟踪所有登录用户并将他们的 activity 存储在数据库中。那是在我的自定义身份服务器中登录时,我需要记录发布的 ASP.NET 身份会话 ID 以及用户的 ID。然后,当使用其中一个客户端应用程序时,它会向我的自定义身份服务器发送一个信号。该信号包含 ASP.NET 身份会话。此信号用于检测所有客户端的 activity,因此我的自定义身份服务器可以延长用户会话的有效性。请注意,如果用户决定登录到另一个客户端,则需要此逻辑。
我现在面临的技术挑战是在 Identity Server 中找到一个位置,它发生在本地登录之后,并且包含当前 ASP.NET Identitiy 会话 ID。
到目前为止,我在自定义 IUserService 中发现了以下我可以实现的函数:
// Summary:
// This method is called prior to the user
// being issued a login cookie for IdentityServer.
//
// Parameters:
// context:
// The context.
public virtual Task PostAuthenticateAsync(PostAuthenticationContext context);
在我的自定义 IUserService 中,我注入了 IOwinContext,但正如评论所述,此函数在用户获取 IdentityServer cookie 发布之前被调用。
我浏览了 IdentityServer3 的 documentation,但找不到一个地方可以在管道中插入自定义代码,在完全登录发生后执行。我需要这样的地方,这样我就可以向我的数据库写入一个新用户当前已登录,并且 ASP.NET identitiy session id 属于他。
查看 IEventService——这为您提供了 IdentityServer 中 activity 的强类型 activity 相关通知。 https://identityserver.github.io/Documentation/docsv2/configuration/events.html