do sessions in memory and also fix glaring security hole
This commit is contained in:
parent
7b6c155a73
commit
f48b421500
31 changed files with 441 additions and 440 deletions
14
Femto.Modules.Auth/Models/Session.cs
Normal file
14
Femto.Modules.Auth/Models/Session.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using static System.Security.Cryptography.RandomNumberGenerator;
|
||||
|
||||
namespace Femto.Modules.Auth.Models;
|
||||
|
||||
public class Session(Guid userId, bool isStrong)
|
||||
{
|
||||
public string Id { get; } = Convert.ToBase64String(GetBytes(32));
|
||||
public Guid UserId { get; } = userId;
|
||||
public DateTimeOffset Expires { get; } = DateTimeOffset.UtcNow + TimeSpan.FromMinutes(15);
|
||||
|
||||
public bool ExpiresSoon => this.Expires < DateTimeOffset.UtcNow + TimeSpan.FromMinutes(5);
|
||||
public bool IsStronglyAuthenticated { get; } = isStrong;
|
||||
public bool IsExpired => this.Expires < DateTimeOffset.UtcNow;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue