Add sessions management feature. #17056
We can start implementing the blazor and angular UI if the MVC UI if no problem.
- The
IdentitySessionClaimsPrincipalContributor
will generate a random GUID as asessionid
to add theClaimsPrincipal
, This usually happens when logging in to get the user's claims. - The
OnSignedIn
event ofIdentity
andProcessSignIn
event of openiddict will get thissessionid
and store it in the database(IdentitySession
table) - The dynamic claims system's
IdentitySessionDynamicClaimsPrincipalContributor
will ensure thesessionid
exists or sign out. - The
IdentitySessionChecker
will check thesessionid
that exists and update theLastAccessed
andIpAddress
to the cache. - The
IdentitySessionManager
is used to get one or a list of sessions and update theLastAccessed
andIpAddress
from the cache to the database. - We will remove the session when logging out.
- The
IdentitySessionCleanupBackgroundWorker
will remove the inactive sessions. - Once a new session has been created, we will remove the other sessions based on the
PreventConcurrentLogin
setting:
public enum IdentityProPreventConcurrentLoginBehaviour
{
Disabled = 0, // We will not remove other sessions
LogoutFromSameTypeDevices = 1, // We will remove all same Device's sessions.
LogoutFromAllDevices = 2 // Only one session can exist
}
The device type
Web: web applications based on cookies(identity) authentication,
Oauth: Web applications using OIDC authentication. Tiered app.
Mobile: Developers can customize the mapping of `Client_Id` to `Mobile` or any other type of application. See `ClientIdToDeviceMap` of `AbpAccountOpenIddictOptions`.
Resolve #12952
https://github.com/abpframework/abp/pull/18242
Setting:
Account:
Identity: