You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.9 KiB
2.9 KiB
LINGYUN.Abp.Identity.Session.AspNetCore
Identity service user session extension module.
Interface Description
AbpSessionMiddleware extracts sessionId from user token in the request pipeline as a global session identifier, which can be used to log out sessions
Note: When anonymous users access, the request CorrelationId is used as the identifier; When CorrelationId does not exist, use random Guid.NewGuid().
HttpContextDeviceInfoProvider extracts device identification from request parameters
Due to module responsibility separation principle, please do not confuse with LINGYUN.Abp.Identity.AspNetCore.Session module
HttpContextDeviceInfoProvider is used to handle session IP address location parsing
IsParseIpLocation will parse the geographical location of session IP when enabled IgnoreProvinces are provinces that need to be ignored when parsing geographical locations, usually China's municipalities LocationParser customizes the geographical location data that needs to be processed
Features
- Provides session management functionality in AspNetCore environment
- Supports extracting device identification information from requests
- Supports IP geolocation parsing
- Depends on AbpAspNetCoreModule, AbpIP2RegionModule, and AbpIdentitySessionModule
Configuration Options
AbpIdentitySessionAspNetCoreOptions
{
"Identity": {
"Session": {
"AspNetCore": {
"IsParseIpLocation": false, // Whether to parse IP geographic information, default: false
"IgnoreProvinces": [ // Provinces to ignore, default includes China's municipalities
"Beijing",
"Shanghai",
"Tianjin",
"Chongqing"
]
}
}
}
}
Basic Usage
- Configure IP geolocation parsing
Configure<AbpIdentitySessionAspNetCoreOptions>(options =>
{
options.IsParseIpLocation = true; // Enable IP geolocation parsing
options.IgnoreProvinces.Add("Hong Kong"); // Add provinces to ignore
options.LocationParser = (locationInfo) =>
{
// Custom geolocation parsing logic
return $"{locationInfo.Country}{locationInfo.Province}{locationInfo.City}";
};
});
- Use device information provider
public class YourService
{
private readonly IDeviceInfoProvider _deviceInfoProvider;
public YourService(IDeviceInfoProvider deviceInfoProvider)
{
_deviceInfoProvider = deviceInfoProvider;
}
public async Task<DeviceInfo> GetDeviceInfoAsync()
{
return await _deviceInfoProvider.GetDeviceInfoAsync();
}
}
Configuration Usage
[DependsOn(typeof(AbpIdentitySessionAspNetCoreModule))]
public class YouProjectModule : AbpModule
{
// other
}