2018-04-29 11:28:04 +02:00
|
|
|
using System.ComponentModel.DataAnnotations;
|
2020-06-27 14:55:16 +02:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2018-04-29 11:28:04 +02:00
|
|
|
|
|
|
|
namespace BTCPayServer.Data
|
|
|
|
{
|
|
|
|
public class APIKeyData
|
|
|
|
{
|
|
|
|
[MaxLength(50)]
|
2020-12-28 21:57:21 +01:00
|
|
|
public string Id { get; set; }
|
2018-04-29 11:28:04 +02:00
|
|
|
|
2020-12-28 21:57:21 +01:00
|
|
|
[MaxLength(50)]
|
|
|
|
public string StoreId { get; set; }
|
2020-02-24 14:36:15 +01:00
|
|
|
|
2020-12-28 21:57:21 +01:00
|
|
|
[MaxLength(50)]
|
|
|
|
public string UserId { get; set; }
|
2020-02-24 14:36:15 +01:00
|
|
|
|
|
|
|
public APIKeyType Type { get; set; } = APIKeyType.Legacy;
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2020-04-02 08:59:20 +02:00
|
|
|
public byte[] Blob { get; set; }
|
2020-02-24 14:36:15 +01:00
|
|
|
public StoreData StoreData { get; set; }
|
|
|
|
public ApplicationUser User { get; set; }
|
2020-02-25 14:43:53 +01:00
|
|
|
public string Label { get; set; }
|
2020-06-27 14:55:16 +02:00
|
|
|
|
2020-12-28 21:57:21 +01:00
|
|
|
|
2020-06-27 14:55:16 +02:00
|
|
|
internal static void OnModelCreating(ModelBuilder builder)
|
|
|
|
{
|
|
|
|
builder.Entity<APIKeyData>()
|
|
|
|
.HasOne(o => o.StoreData)
|
|
|
|
.WithMany(i => i.APIKeys)
|
|
|
|
.HasForeignKey(i => i.StoreId).OnDelete(DeleteBehavior.Cascade);
|
|
|
|
|
|
|
|
builder.Entity<APIKeyData>()
|
|
|
|
.HasOne(o => o.User)
|
|
|
|
.WithMany(i => i.APIKeys)
|
|
|
|
.HasForeignKey(i => i.UserId).OnDelete(DeleteBehavior.Cascade);
|
|
|
|
|
|
|
|
builder.Entity<APIKeyData>()
|
|
|
|
.HasIndex(o => o.StoreId);
|
|
|
|
}
|
2020-02-24 14:36:15 +01:00
|
|
|
}
|
2018-07-19 12:31:17 +02:00
|
|
|
|
2020-04-02 08:59:20 +02:00
|
|
|
public class APIKeyBlob
|
|
|
|
{
|
|
|
|
public string[] Permissions { get; set; }
|
2020-02-28 19:42:17 +01:00
|
|
|
public string ApplicationIdentifier { get; set; }
|
|
|
|
public string ApplicationAuthority { get; set; }
|
2020-06-28 10:55:27 +02:00
|
|
|
|
2020-04-02 08:59:20 +02:00
|
|
|
}
|
|
|
|
|
2020-02-24 14:36:15 +01:00
|
|
|
public enum APIKeyType
|
|
|
|
{
|
|
|
|
Legacy,
|
|
|
|
Permanent
|
2018-04-29 11:28:04 +02:00
|
|
|
}
|
|
|
|
}
|