简体   繁体   English

IdentityServer3中的回调,可访问当前的ASP.NET身份会话ID

[英]Callback in IdentityServer3, with current ASP.NET Identity Session ID available to access

I am implementing a Single Sign On (SSO) solution using IdentityServer3. 我正在使用IdentityServer3实现单点登录(SSO)解决方案。 I have ASP.NET 4.5.2 (MVC) application that hosts IdenitityServer. 我有承载IdenitityServer的ASP.NET 4.5.2(MVC)应用程序。 I have requirement to track all signed in users and store their activity in a database. 我需要跟踪所有已登录的用户并将其活动存储在数据库中。 That is at sign in time in my custom Identity Server, I need to record the issued ASP.NET Identitiy Session ID along with the user's Id. 那是在我的自定义Identity Server中登录时,我需要记录发布的ASP.NET Identitiy Session ID以及用户的ID。 Then, when one of the client applications is used, it sends a signal to my custom Identitiy Server. 然后,当使用其中一个客户端应用程序时,它将向我的自定义身份服务器发送信号。 The signal contains that ASP.NET identity Session. 该信号包含该ASP.NET身份会话。 This signal is used to detect activity across all clients, and hence my custom Identitiy Server can extend the validity of the user's session. 此信号用于检测所有客户端上的活动,因此我的自定义Identitiy Server可以扩展用户会话的有效性。 Note that this logic is needed in case the user decides to sign in to another client. 请注意,如果用户决定登录另一个客户端,则需要此逻辑。

The technical challenge I face now is to find a place in Identity Server, that happens just after local sign in, and contains the current ASP.NET Identitiy session id. 我现在面临的技术挑战是在Identity Server中找到一个位置,该位置恰好在本地登录后发生,并包含当前的ASP.NET Identitiy会话ID。

So far I have found the following function in the custom IUserService that I could implement: 到目前为止,我已经在可以实现的自定义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);

In my custom IUserService, I have injected the IOwinContext, but as the comment states, this function is invoked before the user gets IdentityServer cookie issued. 在我的自定义IUserService中,我已经注入了IOwinContext,但是正如注释所指出的,在用户获得IdentityServer cookie发出之前,将调用此函数。

I have browsed IdentityServer3's documentation , and could not find a single place, where on can plug custom code in the pipeline, that executes after a full sign in has happened. 我浏览了IdentityServer3的文档 ,找不到一个可以在管道中插入自定义代码的位置,该位置在完全登录后执行。 I need such place, so that I can write to my database that a new user is currently signed in, and which ASP.NET identitiy session id belongs to him. 我需要一个这样的位置,以便可以将当前已登录新用户以及属于他的ASP.NET身份会话ID写入数据库。

Look into the IEventService -- this provides you with strongly-typed, activity related notifications of activity in IdentityServer. 查看IEventService -这为您提供了IdentityServer中与活动相关的强类型活动通知。 https://identityserver.github.io/Documentation/docsv2/configuration/events.html https://identityserver.github.io/Documentation/docsv2/configuration/events.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IdentityServer3 的 ASP.NET Identity 插件 UI (IdentityManager) 在部署到 Azure (WebApp) 后不起作用 - ASP.NET Identity plugin UI (IdentityManager) for IdentityServer3 not working after deploying to Azure (WebApp) 如何将IdentityServer3添加到现有的基于ASP.Net Identity的项目中? - How do I go about adding IdentityServer3 to an existing ASP.Net Identity based project? Asp.Net Identity 2 用户信息如何映射到 IdentityServer3 配置文件声明 - How does Asp.Net Identity 2 User Info get mapped to IdentityServer3 profile claims 通过angular2中的IdentityServer3进行身份验证,并从asp.net mvc4访问webapi - Authentication via IdentityServer3 in angular2 and access to webapi from asp.net mvc4 ASP.Net MVC IdentityServer3破坏了我的webapi路由 - ASP.Net MVC IdentityServer3 broke my webapi routing 将 ASP.NET 角色授权与 IdentityServer3 隐式流结合使用 - Using ASP.NET Role Authorisation with IdentityServer3 implicit flow ASP.NET Core 3.1 MVC AddOpenIDConnect 与 IdentityServer3 - ASP.NET Core 3.1 MVC AddOpenIDConnect with IdentityServer3 IdentityServer4 Asp.Net 核心身份 - IdentityServer4 Asp.Net Core Identity IdentityServer4 与 ASP.NET 身份 - IdentityServer4 with ASP.NET Identity 在 ASP.NET Identity 2.0 中获取当前用户 id - Get current user id in ASP.NET Identity 2.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM