add a bunch of authentication stuff
This commit is contained in:
parent
996e59f49a
commit
aca83fa1ef
22 changed files with 681 additions and 28 deletions
|
@ -1,8 +1,26 @@
|
|||
using System.Security.Cryptography;
|
||||
using Foxchat.Core.Utils;
|
||||
using NodaTime;
|
||||
|
||||
namespace Foxchat.Identity.Database.Models;
|
||||
|
||||
public class Token
|
||||
public class Token : BaseModel
|
||||
{
|
||||
public Ulid Id { get; init; } = Ulid.NewUlid();
|
||||
public byte[] Hash { get; set; } = null!;
|
||||
public string[] Scopes { get; set; } = [];
|
||||
public Instant Expires { get; set; }
|
||||
|
||||
public Ulid AccountId { get; set; }
|
||||
public Account Account { get; set; } = null!;
|
||||
}
|
||||
|
||||
public Ulid ApplicationId { get; set; }
|
||||
public Application Application { get; set; } = null!;
|
||||
|
||||
public static (string, byte[]) Generate()
|
||||
{
|
||||
var token = CryptoUtils.RandomToken(48);
|
||||
var hash = SHA512.HashData(Convert.FromBase64String(token));
|
||||
|
||||
return (token, hash);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue