-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(identity): calculate session expiration time from identity claim…
… principal
- Loading branch information
Showing
6 changed files
with
108 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...GYUN.Abp.Identity.Domain/System/Security/Principal/AbpClaimsIdentityExpiraInExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using JetBrains.Annotations; | ||
using System.Linq; | ||
using System.Security.Claims; | ||
using Volo.Abp; | ||
|
||
namespace System.Security.Principal; | ||
public static class AbpClaimsIdentityExpiraInExtensions | ||
{ | ||
public static long? FindExpirainTime([NotNull] this ClaimsPrincipal principal) | ||
{ | ||
return principal.FindLongClaimValue("exp"); | ||
} | ||
|
||
public static long? FindIssuedTime([NotNull] this ClaimsPrincipal principal) | ||
{ | ||
return principal.FindLongClaimValue("iat"); | ||
} | ||
|
||
public static long? FindLongClaimValue([NotNull] this ClaimsPrincipal principal, string claimType) | ||
{ | ||
Check.NotNull(principal, nameof(principal)); | ||
|
||
var longValueOrNull = principal.Claims?.FirstOrDefault(c => c.Type == claimType); | ||
if (longValueOrNull == null || longValueOrNull.Value.IsNullOrWhiteSpace()) | ||
{ | ||
return null; | ||
} | ||
|
||
if (long.TryParse(longValueOrNull.Value, out var longValue)) | ||
{ | ||
return longValue; | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ssion.AspNetCore/LINGYUN/Abp/Identity/Session/AspNetCore/IP2RegionLocationInfoProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters