From 3de2489b8a5ce376aef0db2354837339d100a65c Mon Sep 17 00:00:00 2001 From: chris Date: Sat, 7 Jun 2025 13:49:37 +0200 Subject: [PATCH] add authority, role and groups --- .../Invoker.cs | 10 +- .../Controllers/AuthorityController.cs | 30 + .../Controllers/GroupController.cs | 34 + .../Controllers/RoleController.cs | 29 + .../Security/GetTokensCommandHandler.cs | 2 +- .../Services/InitService.cs | 410 ++++- .../TestController.cs | 76 +- .../Database/ApplicationContext.cs | 2 +- .../Database/CoreContext.cs | 216 ++- .../Entities/App/AppEntity.cs | 12 + .../Entities/App/AppSubjectRelationEntity.cs | 12 +- ...RelationInternalAuthorityRelationEntity.cs | 29 - .../Entities/Security/AuthorityEntity.cs | 27 - .../Entities/Security/AuthorityType.cs | 7 - ...ctRelationInternalAuthorityRelationData.cs | 8 + ...RelationInternalAuthorityRelationEntity.cs | 12 + ...nInternalAuthorityRelationVersionEntity.cs | 13 + .../Obsolete/TenantSubjectRoleRelationData.cs | 8 + .../TenantSubjectRoleRelationEntity.cs | 11 + .../TenantSubjectRoleRelationVersionEntity.cs | 13 + .../Security/Permission/AuthorityEntity.cs | 13 + .../Security/Permission/Data/AuthorityData.cs | 8 + .../Security/Permission/Data/AuthorityType.cs | 7 + .../Permission/Data/CategorizedNameData.cs | 9 + .../Data/DescribedCategorizedNameData.cs | 6 + ...cribedCategorizedNameWithVisibilityData.cs | 8 + .../Permission/Data/GlobalAuthorityData.cs | 6 + .../Security/Permission/Data/GroupData.cs | 3 + .../Security/Permission/Data/RoleData.cs | 3 + .../Permission/GlobalAuthorityEntity.cs | 5 + .../Security/Permission/GroupEntity.cs | 15 + .../Relation/GroupRoleRelationData.cs | 7 + .../Relation/GroupRoleRelationEntity.cs | 10 + .../Relation/GroupSubjectRelationData.cs | 7 + .../Relation/GroupSubjectRelationEntity.cs | 11 + .../Relation/RoleAuthorityRelationData.cs | 7 + .../Relation/RoleAuthorityRelationEntity.cs | 10 + .../RoleGlobalAuthorityRelationData.cs | 7 + .../RoleGlobalAuthorityRelationEntity.cs | 10 + .../Relation/RoleSubjectRelationData.cs | 7 + .../Relation/RoleSubjectRelationEntity.cs | 11 + .../Security/Permission/RoleEntity.cs | 16 + .../Version/AuthorityVersionEntity.cs | 14 + .../Version/GroupRoleRelationVersionEntity.cs | 15 + .../GroupSubjectRelationVersionEntity.cs | 15 + .../Permission/Version/GroupVersionEntity.cs | 14 + .../RoleAuthorityRelationVersionEntity.cs | 15 + ...oleGlobalAuthorityRelationVersionEntity.cs | 15 + .../RoleSubjectRelationVersionEntity.cs | 15 + .../Permission/Version/RoleVersionEntity.cs | 14 + ...RelationInternalAuthorityRelationEntity.cs | 28 - .../Entities/{Base => Subject}/SubjectData.cs | 0 .../Entities/Subject/SubjectEntity.cs | 3 + .../Entities/Tenant/TenantEntity.cs | 4 + .../{Base => Tenant}/TenantRelationData.cs | 0 .../Tenant/TenantSubjectRelationEntity.cs | 12 +- .../Attributes/AuthorityAttribute.cs | 19 + .../Attributes/GlobalAuthorityAttribute.cs | 19 + .../MasterData/Attributes/GroupAttribute.cs | 18 + .../Attributes/HasAuthoritiesAttribute.cs | 18 + .../HasGlobalAuthoritiesAttribute.cs} | 8 +- .../HasRolesAttribute.cs} | 8 +- .../MasterData/Attributes/RoleAttribute.cs | 9 + .../Atttibutes/MasterAuthorityAttribute.cs | 14 - .../Atttibutes/MasterGroupAttribute.cs | 14 - .../Atttibutes/MasterRoleAttribute.cs | 14 - .../MasterData/Authorities.cs | 141 ++ .../MasterData/{MasterGroups.cs => Groups.cs} | 34 +- .../MasterData/MasterAuthorities.cs | 59 - .../MasterData/MasterRoles.cs | 66 - .../MasterData/Roles.cs | 100 ++ .../Migrations/20240903154112_sus.Designer.cs | 663 -------- .../Migrations/20240903154112_sus.cs | 592 ------- .../20240914003536_addTokens.Designer.cs | 716 --------- .../Migrations/20240914003536_addTokens.cs | 62 - .../20240914005530_affwaf.Designer.cs | 716 --------- .../Migrations/20240914005530_affwaf.cs | 173 --- .../20240914012943_fawfghh.Designer.cs | 716 --------- .../Migrations/20240914012943_fawfghh.cs | 173 --- .../20240914014850_gjjjjjj.Designer.cs | 716 --------- .../Migrations/20240914014850_gjjjjjj.cs | 22 - .../20240914224344_jsoikgsoieg.Designer.cs | 719 --------- .../Migrations/20240914224344_jsoikgsoieg.cs | 30 - .../20240919005908_afwawfawf.Designer.cs | 730 --------- .../Migrations/20240919005908_afwawfawf.cs | 35 - .../20240919010339_ffffff.Designer.cs | 729 --------- .../Migrations/20240919010339_ffffff.cs | 29 - .../20240919010748_jm├ñpromh.Designer.cs | 730 --------- .../Migrations/20240919010748_jm├ñpromh.cs | 29 - .../20240919012025_fghdhhzttr.Designer.cs | 719 --------- .../Migrations/20240919012025_fghdhhzttr.cs | 35 - .../20240921214234_kl├╢hmpdmpmgr.Designer.cs | 726 --------- .../20240921214234_kl├╢hmpdmpmgr.cs | 44 - .../20250525155339_cringe1.Designer.cs | 718 --------- .../Migrations/20250525155339_cringe1.cs | 30 - .../20250525162427_cringe2.Designer.cs | 718 --------- .../Migrations/20250525162427_cringe2.cs | 230 --- .../20250525174938_addIsMaster.Designer.cs | 724 --------- .../Migrations/20250525174938_addIsMaster.cs | 44 - ...0530220220_updateTokenMetadata.Designer.cs | 731 --------- .../20250530220220_updateTokenMetadata.cs | 44 - .../20250530223053_addBaseAddress.Designer.cs | 739 --------- .../20250530223053_addBaseAddress.cs | 44 - .../20250530235831_tokenType.Designer.cs | 739 --------- .../Migrations/20250530235831_tokenType.cs | 42 - .../20250607014754_Init.Designer.cs | 1363 +++++++++++++++++ .../Migrations/20250607014754_Init.cs | 1192 ++++++++++++++ .../ApplicationContextModelSnapshot.cs | 864 +++++++++-- .../Suspectus.Gandalf.Palantir.Data.csproj | 4 + .../GrAuthorizeAttribute.cs | 1 + .../GandalfRebornJwtTokenAuthSchemeHandler.cs | 110 +- 111 files changed, 4819 insertions(+), 14474 deletions(-) create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Api/Controllers/AuthorityController.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Api/Controllers/GroupController.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Api/Controllers/RoleController.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/AppUserRelationInternalAuthorityRelationEntity.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/AuthorityEntity.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/AuthorityType.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/AppSubjectRelationInternalAuthorityRelationData.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/AppSubjectRelationInternalAuthorityRelationEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/AppSubjectRelationInternalAuthorityRelationVersionEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/TenantSubjectRoleRelationData.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/TenantSubjectRoleRelationEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/TenantSubjectRoleRelationVersionEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/AuthorityEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/AuthorityData.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/AuthorityType.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/CategorizedNameData.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/DescribedCategorizedNameData.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/DescribedCategorizedNameWithVisibilityData.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/GlobalAuthorityData.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/GroupData.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/RoleData.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/GlobalAuthorityEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/GroupEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupRoleRelationData.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupRoleRelationEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupSubjectRelationData.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupSubjectRelationEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleAuthorityRelationData.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleAuthorityRelationEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleGlobalAuthorityRelationData.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleGlobalAuthorityRelationEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleSubjectRelationData.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleSubjectRelationEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/RoleEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/AuthorityVersionEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/GroupRoleRelationVersionEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/GroupSubjectRelationVersionEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/GroupVersionEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleAuthorityRelationVersionEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleGlobalAuthorityRelationVersionEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleSubjectRelationVersionEntity.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleVersionEntity.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/TenantSubjectRelationInternalAuthorityRelationEntity.cs rename src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/{Base => Subject}/SubjectData.cs (100%) rename src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/{Base => Tenant}/TenantRelationData.cs (100%) create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/AuthorityAttribute.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/GlobalAuthorityAttribute.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/GroupAttribute.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/HasAuthoritiesAttribute.cs rename src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/{Atttibutes/HasMasterAuthoritiesAttribute.cs => Attributes/HasGlobalAuthoritiesAttribute.cs} (52%) rename src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/{Atttibutes/HasMasterRolesAttribute.cs => Attributes/HasRolesAttribute.cs} (51%) create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/RoleAttribute.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/MasterAuthorityAttribute.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/MasterGroupAttribute.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/MasterRoleAttribute.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Authorities.cs rename src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/{MasterGroups.cs => Groups.cs} (55%) delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/MasterAuthorities.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/MasterRoles.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Roles.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240903154112_sus.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240903154112_sus.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914003536_addTokens.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914003536_addTokens.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914005530_affwaf.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914005530_affwaf.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914012943_fawfghh.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914012943_fawfghh.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914014850_gjjjjjj.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914014850_gjjjjjj.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914224344_jsoikgsoieg.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914224344_jsoikgsoieg.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919005908_afwawfawf.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919005908_afwawfawf.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010339_ffffff.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010339_ffffff.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010748_jm├ñpromh.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010748_jm├ñpromh.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919012025_fghdhhzttr.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919012025_fghdhhzttr.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240921214234_kl├╢hmpdmpmgr.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240921214234_kl├╢hmpdmpmgr.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525155339_cringe1.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525155339_cringe1.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525162427_cringe2.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525162427_cringe2.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525174938_addIsMaster.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525174938_addIsMaster.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530220220_updateTokenMetadata.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530220220_updateTokenMetadata.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530223053_addBaseAddress.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530223053_addBaseAddress.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530235831_tokenType.Designer.cs delete mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530235831_tokenType.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250607014754_Init.Designer.cs create mode 100644 src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250607014754_Init.cs diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Abstractions/Invoker.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Abstractions/Invoker.cs index accddb6..4a9be23 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Abstractions/Invoker.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Abstractions/Invoker.cs @@ -31,15 +31,17 @@ public partial class Invoker SubjectId = sub.GetValueOrDefault(), TenantAuthorityDictionary = claimsPrincipal.Claims .Where(x => TenantAuthorityRegex().IsMatch(x.Type)) + .GroupBy(x => AppAuthorityRegex().Match(x.Type).Groups["id"].Value) .ToImmutableDictionary( - x => TenantAuthorityRegex().Match(x.Type).Groups["id"].Value, - x => claimsPrincipal.Claims.Where(y => y.Type == x.Type).Select(y => y.Value).ToHashSet() + x => x.Key, + x => x.Select(y => y.Value).ToHashSet() ), AppAuthorityDictionary = claimsPrincipal.Claims .Where(x => AppAuthorityRegex().IsMatch(x.Type)) + .GroupBy(x => AppAuthorityRegex().Match(x.Type).Groups["id"].Value) .ToImmutableDictionary( - x => AppAuthorityRegex().Match(x.Type).Groups["id"].Value, - x => claimsPrincipal.Claims.Where(y => y.Type == x.Type).Select(y => y.Value).ToHashSet() + x => x.Key, + x => x.Select(y => y.Value).ToHashSet() ), IsAuthenticated = claimsPrincipal.Identity.IsAuthenticated }; diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Api/Controllers/AuthorityController.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Api/Controllers/AuthorityController.cs new file mode 100644 index 0000000..05d40ef --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Api/Controllers/AuthorityController.cs @@ -0,0 +1,30 @@ +using HashidsNet; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Suspectus.Gandalf.Palantir.Data.Database; + +namespace Suspectus.Gandalf.Palantir.Api.Controllers; + +[ApiController] +[Route("api/[controller]")] +[Authorize] +public class AuthorityController : ControllerBase +{ + private readonly ApplicationContext _context; + private readonly IHashids _hashids; + + public AuthorityController(ApplicationContext context, IHashids hashids) + { + _context = context; + _hashids = hashids; + } + + [HttpGet] + public async Task Get(CancellationToken cancellationToken) + { + var authorities = await _context.Authorities.ToListAsync(cancellationToken: cancellationToken); + var globalAuthorities = await _context.GlobalAuthorities.ToListAsync(cancellationToken: cancellationToken); + return Ok(new {authorities, globalAuthorities}); + } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Api/Controllers/GroupController.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Api/Controllers/GroupController.cs new file mode 100644 index 0000000..0302b8f --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Api/Controllers/GroupController.cs @@ -0,0 +1,34 @@ +using HashidsNet; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Suspectus.Gandalf.Palantir.Data.Database; + +namespace Suspectus.Gandalf.Palantir.Api.Controllers; + +[ApiController] +[Route("api/[controller]")] +[Authorize] +public class GroupController : ControllerBase +{ + private readonly ApplicationContext _context; + private readonly IHashids _hashids; + + public GroupController(ApplicationContext context, IHashids hashids) + { + _context = context; + _hashids = hashids; + } + + [HttpGet] + public async Task Get(CancellationToken cancellationToken) + { + var groups = await _context.Groups + .Include(x => x.Roles) + .ThenInclude(x => x.Authorities) + .Include(x => x.Roles) + .ThenInclude(x => x.GlobalAuthorities) + .ToListAsync(cancellationToken: cancellationToken); + return Ok(groups); + } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Api/Controllers/RoleController.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Api/Controllers/RoleController.cs new file mode 100644 index 0000000..77702a1 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Api/Controllers/RoleController.cs @@ -0,0 +1,29 @@ +using HashidsNet; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using Suspectus.Gandalf.Palantir.Data.Database; + +namespace Suspectus.Gandalf.Palantir.Api.Controllers; + +[ApiController] +[Route("api/[controller]")] +[Authorize] +public class RoleController : ControllerBase +{ + private readonly ApplicationContext _context; + private readonly IHashids _hashids; + + public RoleController(ApplicationContext context, IHashids hashids) + { + _context = context; + _hashids = hashids; + } + + [HttpGet] + public async Task Get(CancellationToken cancellationToken) + { + var roles = await _context.Roles.ToListAsync(cancellationToken: cancellationToken); + return Ok(roles); + } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Api/Handlers/Security/GetTokensCommandHandler.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Api/Handlers/Security/GetTokensCommandHandler.cs index 8fb5cb8..60b6c26 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Api/Handlers/Security/GetTokensCommandHandler.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Api/Handlers/Security/GetTokensCommandHandler.cs @@ -111,7 +111,7 @@ public class TokenRequestCommandHandler(TimeProvider timeProvider, IHashids hash if (decodedToken.Exp is null || decodedToken.Exp?.ToUniversalTime() <= timeProvider.GetUtcNow()) return "One does not simply provide an expired token.".AsErrorResult(); - var refreshTokenMetadata = await context.TokenMetadata.SingleOrDefaultAsync(x => x.Id == hashids.DecodeSingleLong(decodedToken.Sub), cancellationToken: cancellationToken); + var refreshTokenMetadata = await context.TokenMetadata.SingleOrDefaultAsync(x => x.Id == hashids.DecodeSingleLong(decodedToken.Id), cancellationToken: cancellationToken); if (refreshTokenMetadata is null) { diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Api/Services/InitService.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Api/Services/InitService.cs index e67534b..08eaab1 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Api/Services/InitService.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Api/Services/InitService.cs @@ -6,6 +6,9 @@ using Suspectus.Gandalf.Palantir.Api.Commands; using Suspectus.Gandalf.Palantir.Data.Database; using Suspectus.Gandalf.Palantir.Data.Entities.App; using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; using Suspectus.Gandalf.Palantir.Data.Entities.Subject; using Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn; using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; @@ -16,13 +19,17 @@ namespace Suspectus.Gandalf.Palantir.Api.Services; public class InitService { private const string HousemasterUserName = "housemaster"; - + private readonly ApplicationContext _applicationContext; private readonly IMediator _mediator; private readonly IConfiguration _configuration; private readonly ILogger _logger; private readonly InvokerContext _invokerContext; + private long _masterSubjectId; + private long _masterTenantId; + private long _masterAppId; + public InitService(ApplicationContext applicationContext, IMediator mediator, IConfiguration configuration, ILogger logger, InvokerContext invokerContext) { _applicationContext = applicationContext; @@ -31,18 +38,18 @@ public class InitService _logger = logger; _invokerContext = invokerContext; } - - + + private static string GeneratePassword(int length = 20) { const string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; var random = new Random(); return new string( Enumerable.Repeat(0, length) - .Select(_ => chars[random.Next(chars.Length)]).ToArray() + .Select(_ => chars[random.Next(chars.Length)]).ToArray() ); } - + private async Task InitializeDatabaseAsync() { await _applicationContext.Database.EnsureCreatedAsync(); @@ -52,18 +59,24 @@ public class InitService private async Task InitializeMaster() { var baseAddress = _configuration.GetValue("BaseUrl") ?? "https://localhost:7269"; - var masterTenant = await _applicationContext.Tenants.SingleOrDefaultAsync(x => x.IsMaster); + var existingMasterTenant = await _applicationContext.Tenants + .Include(x => x.Apps) + .SingleOrDefaultAsync(x => x.IsMaster); - if (masterTenant is not null) + if (existingMasterTenant is not null) { var existingMasterApp = await _applicationContext.Apps .Include(x => x.Tenant) - .SingleAsync(x => x.TenantId == masterTenant.Id); + .SingleAsync(x => x.TenantId == existingMasterTenant.Id); + + _masterSubjectId = existingMasterTenant.OwnerId; + _masterTenantId = existingMasterTenant.Id!.Value; + _masterAppId = existingMasterTenant.Apps.Where(x => x.Name == "Master").Select(x => x.Id!.Value).FirstOrDefault(); if (existingMasterApp.BaseAddress == baseAddress) return; - + existingMasterApp.BaseAddress = baseAddress; - + _invokerContext.Invoker = new Invoker { SubjectId = existingMasterApp.Tenant!.OwnerId, @@ -71,11 +84,12 @@ public class InitService AppAuthorityDictionary = new Dictionary>(), IsAuthenticated = true }; - + await _applicationContext.SaveChangesAsync(); + return; } - + var masterTenantPassword = GeneratePassword(); var masterTenantPasswordHashResult = await _mediator.Send(new HashPasswordCommand { RawPassword = masterTenantPassword }); @@ -102,7 +116,7 @@ public class InitService _applicationContext.Subjects.Add(housemasterUser); await _applicationContext.SaveChangesAsync(); - + _invokerContext.Invoker = new Invoker { SubjectId = housemasterUser.Id!.Value, @@ -110,15 +124,15 @@ public class InitService AppAuthorityDictionary = new Dictionary>(), IsAuthenticated = true }; - - masterTenant = new TenantEntity + + var masterTenant = new TenantEntity { Visibility = EntityVisibility.Active, Name = "Master", IsMaster = true, OwnerId = housemasterUser.Id!.Value, }; - + _applicationContext.Tenants.Add(masterTenant); await _applicationContext.SaveChangesAsync(); @@ -129,19 +143,19 @@ public class InitService Name = "Master", BaseAddress = baseAddress }; - + _applicationContext.Apps.Add(masterApp); await _applicationContext.SaveChangesAsync(); - + var appSubjectRelation = new AppSubjectRelationEntity { AppId = masterApp.Id!.Value, SubjectId = housemasterUser.Id!.Value }; - + _applicationContext.AppSubjectRelations.Add(appSubjectRelation); await _applicationContext.SaveChangesAsync(); - + _logger.LogInformation($""" ----- Housemaster initial login information ----- username: {housemasterUser.Name} @@ -149,21 +163,359 @@ public class InitService Please change the password after the first login. ------------------------------------------------- """); + + _masterSubjectId = housemasterUser.Id!.Value; + _masterTenantId = masterTenant.Id!.Value; + _masterAppId = masterApp.Id!.Value; } - - private async Task InitializeMasterAuthorities() + + private readonly Dictionary _globalAuthorityNameToIdMap = new(); + private readonly Dictionary _authorityNameToIdMap = new(); + private readonly Dictionary _roleNameToIdMap = new(); + private readonly Dictionary _groupNameToIdMap = new(); + private List _deletedGlobalAuthorities = []; + + private async Task InitializeAuthorities() { - var authorities = MasterAuthorities.GetAllAuthorities(); - var roles = MasterRoles.GetAllRoles(); - var groups = MasterGroups.GetAllGroups(); - - //TODO: Add a check to see if the authorities, roles, and groups already exist in the database. + var globalAuthorities = Authorities.GetAllGlobalAuthorities(); + var authorities = Authorities.GetAllAuthorities(); + + foreach (var authority in globalAuthorities) + { + var entity = await _applicationContext.GlobalAuthorities.SingleOrDefaultAsync(x => + (x.Name == authority.Name || x.Name == authority.OldName) + && + x.Type == authority.Type); + + if (entity is null) + { + entity = new GlobalAuthorityEntity + { + Name = authority.Name, + CategoryPath = authority.Path ?? "Other", + Description = authority.Description, + Type = authority.Type + }; + + _applicationContext.GlobalAuthorities.Add(entity); + + _logger.LogInformation("Added global authority: Type: {Type} Name: {Name} Path: {Path} Description: {Description}", entity.Type, entity.Name, entity.CategoryPath, entity.Description); + } + else + { + entity.Name = authority.Name; + entity.CategoryPath = authority.Path ?? "Other"; + entity.Description = authority.Description; + entity.Type = authority.Type; + + _logger.LogInformation("Updated global authority: Id: {Id} Type: {Type} Name: {Name} Path: {Path} Description: {Description}", entity.Id, entity.Type, entity.Name, entity.CategoryPath, entity.Description); + } + + await _applicationContext.SaveChangesAsync(); + + _globalAuthorityNameToIdMap.TryAdd(GetDictionaryKey(entity.Type, entity.Name), entity.Id!.Value); + } + + _deletedGlobalAuthorities = await _applicationContext.GlobalAuthorities + .Where(x => !globalAuthorities.Select(y => y.Name).Contains(x.Name)) + .ToListAsync(); + + foreach (var authority in authorities) + { + var entity = await _applicationContext.Authorities.SingleOrDefaultAsync(x => + (x.Name == authority.Name || x.Name == authority.OldName) + && + x.Type == authority.Type); + + if (entity is null) + { + entity = new AuthorityEntity + { + Name = authority.Name, + CategoryPath = authority.Path ?? "Other", + Description = authority.Description, + Type = authority.Type, + TenantId = _masterTenantId, + AppId = authority.Type == AuthorityType.App ? _masterAppId : null, + Visibility = EntityVisibility.Active + }; + + _applicationContext.Authorities.Add(entity); + + _logger.LogInformation("Added authority: Type: {Type} Name: {Name} Path: {Path} Description: {Description}", entity.Type, entity.Name, entity.CategoryPath, entity.Description); + } + else + { + entity.Name = authority.Name; + entity.CategoryPath = authority.Path ?? "Other"; + entity.Description = authority.Description; + entity.Type = authority.Type; + entity.TenantId = _masterTenantId; + entity.AppId = authority.Type == AuthorityType.App ? _masterAppId : null; + entity.Visibility = EntityVisibility.Active; + + _logger.LogInformation("Updated authority: Id: {Id} TenantId: {TenantId} AppId: {AppId} Type: {Type} Name: {Name} Path: {Path} Description: {Description}", entity.Id, entity.TenantId, entity.AppId, entity.Type, entity.Name, + entity.CategoryPath, entity.Description); + } + + await _applicationContext.SaveChangesAsync(); + + _authorityNameToIdMap.TryAdd(GetDictionaryKey(entity.Type, entity.Name, entity.Type == AuthorityType.Tenant ? entity.TenantId : entity.AppId), entity.Id!.Value); + } + + var deletedAuthoritiesQuery = _applicationContext.Authorities + .Where(x => !authorities.Select(y => y.Name).Contains(x.Name)); + + var deletedAuthorities = await deletedAuthoritiesQuery.ToListAsync(); + + foreach (var entity in deletedAuthorities) + { + _logger.LogInformation("Soft deleted global authority: Id: {Id} Type: {Type} Name: {Name} Path: {Path} Description: {Description}", entity.Id, entity.Type, entity.Name, entity.CategoryPath, entity.Description); + } + + await deletedAuthoritiesQuery.ExecuteUpdateAsync(setter => setter.SetProperty(p => p.Visibility, EntityVisibility.Removed)); } - + + private async Task InitializeRoles() + { + var roles = Roles.GetAllRoles(); + + foreach (var role in roles) + { + var entity = await _applicationContext.Roles.SingleOrDefaultAsync(x => + (x.Name == role.Name || x.Name == role.OldName) + && + x.Type == role.Type); + + if (entity is null) + { + entity = new RoleEntity + { + Name = role.Name, + CategoryPath = role.Path ?? "Other", + Description = role.Description, + Type = role.Type, + TenantId = _masterTenantId, + AppId = role.Type == AuthorityType.App ? _masterAppId : null, + Visibility = EntityVisibility.Active + }; + + _applicationContext.Roles.Add(entity); + + _logger.LogInformation("Added role: Type: {Type} Name: {Name} Path: {Path} Description: {Description}", entity.Type, entity.Name, entity.CategoryPath, entity.Description); + } + else + { + entity.Name = role.Name; + entity.CategoryPath = role.Path ?? "Other"; + entity.Description = role.Description; + entity.Type = role.Type; + entity.TenantId = _masterTenantId; + entity.AppId = role.Type == AuthorityType.App ? _masterAppId : null; + entity.Visibility = EntityVisibility.Active; + + _logger.LogInformation("Updated role: Id: {Id} TenantId: {TenantId} AppId: {AppId} Type: {Type} Name: {Name} Path: {Path} Description: {Description}", entity.Id, entity.TenantId, entity.AppId, entity.Type, entity.Name, + entity.CategoryPath, entity.Description); + } + + await _applicationContext.SaveChangesAsync(); + + _roleNameToIdMap.TryAdd(GetDictionaryKey(entity.Type, entity.Name, entity.Type == AuthorityType.Tenant ? entity.TenantId : entity.AppId), entity.Id!.Value); + } + + foreach (var role in roles) + { + var roleId = _roleNameToIdMap[GetDictionaryKey(role.Type, role.Name, role.Type == AuthorityType.Tenant ? _masterTenantId : _masterAppId)]; + + await _applicationContext.RoleAuthorityRelations + .Where(x => x.RoleId == roleId) + .ExecuteDeleteAsync(); + + await _applicationContext.RoleGlobalAuthorityRelations + .Where(x => x.RoleId == roleId) + .ExecuteDeleteAsync(); + + var globalAuthorityRelations = role.GlobalAuthorities + .Select(x => new RoleGlobalAuthorityRelationEntity + { + RoleId = roleId, + GlobalAuthorityId = _globalAuthorityNameToIdMap[GetDictionaryKey(role.Type, x)], + }) + .ToList(); + + var authorityRelations = role.Authorities + .Select(x => new RoleAuthorityRelationEntity + { + RoleId = roleId, + AuthorityId = _authorityNameToIdMap[GetDictionaryKey(role.Type, x, role.Type == AuthorityType.Tenant ? _masterTenantId : _masterAppId)], + }) + .ToList(); + + _applicationContext.AddRange(globalAuthorityRelations); + _applicationContext.AddRange(authorityRelations); + + await _applicationContext.SaveChangesAsync(); + } + + var deletedRolesQuery = _applicationContext.Roles + .Where(x => !roles.Select(y => y.Name).Contains(x.Name)); + + var deletedRoles = await deletedRolesQuery.ToListAsync(); + + foreach (var entity in deletedRoles) + { + _logger.LogInformation("Soft deleted role authority: Id: {Id} Type: {Type} Name: {Name} Path: {Path} Description: {Description}", entity.Id, entity.Type, entity.Name, entity.CategoryPath, entity.Description); + } + + await deletedRolesQuery.ExecuteUpdateAsync(setter => setter.SetProperty(p => p.Visibility, EntityVisibility.Removed)); + } + + private async Task InitializeGroups() + { + var groups = Groups.GetAllGroups(); + + foreach (var group in groups) + { + var entity = await _applicationContext.Groups.SingleOrDefaultAsync(x => + (x.Name == group.Name || x.Name == group.OldName) + && + x.Type == group.Type + ); + + if (entity is null) + { + entity = new GroupEntity + { + Name = group.Name, + CategoryPath = group.Path ?? "Other", + Description = group.Description, + Type = group.Type, + TenantId = _masterTenantId, + AppId = group.Type == AuthorityType.App ? _masterAppId : null, + Visibility = EntityVisibility.Active + }; + + _applicationContext.Groups.Add(entity); + + _logger.LogInformation("Added group: Type: {Type} Name: {Name} Path: {Path} Description: {Description}", entity.Type, entity.Name, entity.CategoryPath, entity.Description); + } + else + { + entity.Name = group.Name; + entity.CategoryPath = group.Path ?? "Other"; + entity.Description = group.Description; + entity.Type = group.Type; + entity.TenantId = _masterTenantId; + entity.AppId = group.Type == AuthorityType.App ? _masterAppId : null; + entity.Visibility = EntityVisibility.Active; + + _logger.LogInformation("Updated group: Id: {Id} TenantId: {TenantId} AppId: {AppId} Type: {Type} Name: {Name} Path: {Path} Description: {Description}", entity.Id, entity.TenantId, entity.AppId, entity.Type, entity.Name, + entity.CategoryPath, entity.Description); + } + + await _applicationContext.SaveChangesAsync(); + + _groupNameToIdMap.TryAdd(GetDictionaryKey(entity.Type, entity.Name, entity.Type == AuthorityType.Tenant ? entity.TenantId : entity.AppId), entity.Id!.Value); + } + + foreach (var group in groups) + { + var groupId = _groupNameToIdMap[GetDictionaryKey(group.Type, group.Name, group.Type == AuthorityType.Tenant ? _masterTenantId : _masterAppId)]; + + await _applicationContext.GroupRoleRelations + .Where(x => x.GroupId == groupId) + .ExecuteDeleteAsync(); + + var roleRelations = group.Roles + .Select(x => new GroupRoleRelationEntity + { + RoleId = _roleNameToIdMap[GetDictionaryKey(group.Type, x, group.Type == AuthorityType.Tenant ? _masterTenantId : _masterAppId)], + GroupId = groupId, + }) + .ToList(); + + _applicationContext.AddRange(roleRelations); + + await _applicationContext.SaveChangesAsync(); + } + + var deletedGroupsQuery = _applicationContext.Groups + .Where(x => !groups.Select(y => y.Name).Contains(x.Name)); + + var deletedRoles = await deletedGroupsQuery.ToListAsync(); + + foreach (var entity in deletedRoles) + { + _logger.LogInformation("Soft deleted group authority: Id: {Id} Type: {Type} Name: {Name} Path: {Path} Description: {Description}", entity.Id, entity.Type, entity.Name, entity.CategoryPath, entity.Description); + } + + await deletedGroupsQuery.ExecuteUpdateAsync(setter => setter.SetProperty(p => p.Visibility, EntityVisibility.Removed)); + } + + private async Task InitializeGroupRoles() + { + _invokerContext.Invoker = new Invoker + { + SubjectId = _masterSubjectId, + TenantAuthorityDictionary = new Dictionary>(), + AppAuthorityDictionary = new Dictionary>(), + IsAuthenticated = true + }; + + await InitializeAuthorities(); + await InitializeRoles(); + await InitializeGroups(); + + foreach (var entity in _deletedGlobalAuthorities) + { + _logger.LogInformation("Deleted global authority: Id: {Id} Type: {Type} Name: {Name} Path: {Path} Description: {Description}", entity.Id, entity.Type, entity.Name, entity.CategoryPath, entity.Description); + _applicationContext.GlobalAuthorities.Remove(entity); + } + + var appHouseMasterGroupRelation = await _applicationContext.GroupSubjectRelations + .Where(x => x.SubjectId == _masterSubjectId && x.Group.Name == Groups.AppHousemaster) + .SingleOrDefaultAsync(); + + if (appHouseMasterGroupRelation is null) + { + var relation = new GroupSubjectRelationEntity + { + SubjectId = _masterSubjectId, + GroupId = _groupNameToIdMap[GetDictionaryKey(AuthorityType.App, Groups.AppHousemaster, _masterAppId)] + }; + + _applicationContext.GroupSubjectRelations.Add(relation); + + await _applicationContext.SaveChangesAsync(); + } + + var tenantHouseMasterGroupRelation = await _applicationContext.GroupSubjectRelations + .Where(x => x.SubjectId == _masterSubjectId && x.Group.Name == Groups.TenantHousemaster) + .SingleOrDefaultAsync(); + + if (tenantHouseMasterGroupRelation is null) + { + var relation = new GroupSubjectRelationEntity + { + SubjectId = _masterSubjectId, + GroupId = _groupNameToIdMap[GetDictionaryKey(AuthorityType.Tenant, Groups.TenantHousemaster, _masterTenantId)] + }; + + _applicationContext.GroupSubjectRelations.Add(relation); + + await _applicationContext.SaveChangesAsync(); + } + } + + private string GetDictionaryKey(AuthorityType type, string name, long? id = null) + { + return id is null ? $"{type}:{name}" : $"{type}:{name}:{id}"; + } + public async Task InitializeAsync() { await InitializeDatabaseAsync(); await InitializeMaster(); - await InitializeMasterAuthorities(); + await InitializeGroupRoles(); } } \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Api/TestController.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Api/TestController.cs index f5deb4c..a5a2387 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Api/TestController.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Api/TestController.cs @@ -23,32 +23,32 @@ public class TestController(IHashids hashids, ApplicationContext context, Invoke return Ok((Invoker)User); } - [HttpPost("tenant")] - public async Task AddTenant([FromBody] CreateTenantCommand command) - { - var invoker = invokerContext.Invoker!; - - var authorities = await context.AuthorityEntities.Where(x => x.Type == AuthorityType.Tenant).ToListAsync(); - - var tenantSubjectRelationEntity = new TenantSubjectRelationEntity - { - Tenant = new TenantEntity - { - Visibility = EntityVisibility.Active, - OwnerId = invoker.SubjectId, - Name = command.Name, - IsMaster = false - }, - SubjectId = invoker.SubjectId, - InternalAuthorities = authorities.ToHashSet() - }; - - await context.AddAsync(tenantSubjectRelationEntity); - await context.SaveChangesAsync(); - - return Ok(tenantSubjectRelationEntity.Tenant); - } - + // [HttpPost("tenant")] + // public async Task AddTenant([FromBody] CreateTenantCommand command) + // { + // var invoker = invokerContext.Invoker!; + // + // var authorities = await context.AuthorityEntities.Where(x => x.Type == Type.Tenant).ToListAsync(); + // + // var tenantSubjectRelationEntity = new TenantSubjectRelationEntity + // { + // Tenant = new TenantEntity + // { + // Visibility = EntityVisibility.Active, + // OwnerId = invoker.SubjectId, + // Name = command.Name, + // IsMaster = false + // }, + // SubjectId = invoker.SubjectId, + // Authorities = authorities.ToHashSet() + // }; + // + // await context.AddAsync(tenantSubjectRelationEntity); + // await context.SaveChangesAsync(); + // + // return Ok(tenantSubjectRelationEntity.Tenant); + // } + // [HttpPut("tenant/{id:long}")] public async Task UpdateTenant(long id, [FromBody] UpdateTenantCommand command) { @@ -74,18 +74,18 @@ public class TestController(IHashids hashids, ApplicationContext context, Invoke return Ok(tenants); } - [GrAuthorize(Type = AuthorityType.Tenant, Authorities = [TenantAuthority.Read], ParameterName = "id")] - [HttpGet("tenant/{id}")] - public async Task GetTenant(string id) - { - if(!hashids.TryDecodeSingleLong(id, out var decodedId)) return BadRequest("One does not simply use a invalid id."); - - var tenant = await context.Tenants.Where(x => x.Id == decodedId).SingleOrDefaultAsync(); - - if(tenant is null) return BadRequest("One does not simply request unknown tenant."); - - return Ok(tenant); - } + // [GrAuthorize(Type = Type.Tenant, Authorities = [TenantAuthority.Read], ParameterName = "id")] + // [HttpGet("tenant/{id}")] + // public async Task GetTenant(string id) + // { + // if(!hashids.TryDecodeSingleLong(id, out var decodedId)) return BadRequest("One does not simply use a invalid id."); + // + // var tenant = await context.Tenants.Where(x => x.Id == decodedId).SingleOrDefaultAsync(); + // + // if(tenant is null) return BadRequest("One does not simply request unknown tenant."); + // + // return Ok(tenant); + // } [AllowAnonymous] [HttpGet("hashid/encode/{id:long}")] diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Database/ApplicationContext.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Database/ApplicationContext.cs index 37a666d..372deee 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Database/ApplicationContext.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Database/ApplicationContext.cs @@ -20,8 +20,8 @@ public sealed class ApplicationContext(DbContextOptions opti base.OnModelCreating(builder); ConfigureId(builder); - AddEnumToStringConversion(builder); AddVersionRelations(builder); + AddEnumToStringConversion(builder); SetTableNames(builder); } diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Database/CoreContext.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Database/CoreContext.cs index d93a2c1..7d2923d 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Database/CoreContext.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Database/CoreContext.cs @@ -1,10 +1,11 @@ using Microsoft.EntityFrameworkCore; using Suspectus.Gandalf.Palantir.Data.Entities.App; using Suspectus.Gandalf.Palantir.Data.Entities.Security; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; using Suspectus.Gandalf.Palantir.Data.Entities.Subject; using Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn; using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; -using Suspectus.Gandalf.Palantir.Data.Entities.Base; namespace Suspectus.Gandalf.Palantir.Data.Database; @@ -23,10 +24,26 @@ public abstract class CoreContext(DbContextOptions options) : DbContext(op public DbSet AppsVersions { get; set; } public DbSet TenantVersions { get; set; } public DbSet AppSubjectRelationVersions { get; set; } + public DbSet TenantSubjectRelationVersions { get; set; } - public DbSet AppSubjectRelationInternalAuthorityRelationVersions { get; set; } - public DbSet TenantSubjectRelationInternalAuthorityRelationVersions { get; set; } + // public DbSet AppSubjectRelationInternalAuthorityRelationVersions { get; set; } + // public DbSet TenantSubjectRelationInternalAuthorityRelationVersions { get; set; } + + + public DbSet GlobalAuthorities { get; set; } + public DbSet Authorities { get; set; } + public DbSet Roles { get; set; } + public DbSet Groups { get; set; } + + public DbSet GroupSubjectRelations { get; set; } + public DbSet RoleSubjectRelations { get; set; } + public DbSet RoleAuthorityRelations { get; set; } + public DbSet RoleGlobalAuthorityRelations { get; set; } + public DbSet GroupRoleRelations { get; set; } + + + protected override void OnModelCreating(ModelBuilder builder) { #region Tenant @@ -57,29 +74,6 @@ public abstract class CoreContext(DbContextOptions options) : DbContext(op #endregion - #region TenantSubjectRelation - - var tenantSubjectRelationBuilder = builder.Entity(); - - tenantSubjectRelationBuilder - .HasMany(x => x.InternalAuthorities) - .WithMany(x => x.TenantSubjectRelations) - .UsingEntity( - r => r - .HasOne(x => x.InternalAuthority) - .WithMany() - .HasForeignKey(x => x.InternalAuthorityId), - l => l - .HasOne(x => x.TenantSubjectRelation) - .WithMany() - .HasForeignKey(x => new { x.SubjectId, x.TenantId }), - j => j - .HasKey(x => new { x.SubjectId, x.TenantId, x.InternalAuthorityId }) - ) - .HasKey(x => new { x.SubjectId, x.TenantId }); - - #endregion - #region Subject var subjectBuilder = builder.Entity(); @@ -95,7 +89,7 @@ public abstract class CoreContext(DbContextOptions options) : DbContext(op .IsUnique(); #endregion - + #region SighnIns var signInBuilder = builder.Entity(); @@ -133,55 +127,155 @@ public abstract class CoreContext(DbContextOptions options) : DbContext(op #endregion - #region AppSubjectRelation + #region Group - var appSubjectRelationBuilder = builder.Entity(); + var groupBuilder = builder.Entity(); - appSubjectRelationBuilder - .HasMany(x => x.InternalAuthorities) - .WithMany(x => x.AppSubjectRelations) - .UsingEntity( + groupBuilder + .HasMany(x => x.Roles) + .WithMany(x => x.Groups) + .UsingEntity( r => r - .HasOne(x => x.InternalAuthority) + .HasOne(x => x.Role) .WithMany() - .HasForeignKey(x => x.InternalAuthorityId), + .HasForeignKey(x => x.RoleId), l => l - .HasOne(x => x.AppSubjectRelation) + .HasOne(x => x.Group) .WithMany() - .HasForeignKey(x => new { x.SubjectId, x.AppId }), + .HasForeignKey(x => x.GroupId), j => j - .HasKey(x => new { x.SubjectId, x.AppId, x.InternalAuthorityId }) - ) - .HasKey(x => new { x.SubjectId, x.AppId }); + .HasKey(x => new { x.GroupId, x.RoleId }) + ); + groupBuilder + .HasMany(x => x.Subjects) + .WithMany(x => x.Groups) + .UsingEntity( + r => r + .HasOne(x => x.Subject) + .WithMany() + .HasForeignKey(x => x.SubjectId), + l => l + .HasOne(x => x.Group) + .WithMany() + .HasForeignKey(x => x.GroupId), + j => j + .HasKey(x => new { x.GroupId, x.SubjectId })); + + groupBuilder.HasOne(x => x.Tenant) + .WithMany(x => x.Groups) + .HasForeignKey(x => x.TenantId); + + groupBuilder.HasOne(x => x.App) + .WithMany(x => x.Groups) + .HasForeignKey(x => x.AppId); + + groupBuilder.HasIndex(x => new { x.Name, x.AppId }) + .IsUnique() + .HasFilter($"\"{nameof(GroupEntity.AppId)}\" IS NOT NULL"); + + groupBuilder.HasIndex(x => new { x.Name, x.TenantId }) + .IsUnique() + .HasFilter($"\"{nameof(GroupEntity.AppId)}\" IS NULL"); + + #endregion + + #region Role + + var roleBuilder = builder.Entity(); + + roleBuilder + .HasMany(x => x.Authorities) + .WithMany(x => x.Roles) + .UsingEntity( + r => r + .HasOne(x => x.Authority) + .WithMany() + .HasForeignKey(x => x.AuthorityId), + l => l + .HasOne(x => x.Role) + .WithMany() + .HasForeignKey(x => x.RoleId), + j => j + .HasKey(x => new { x.RoleId, x.AuthorityId }) + ); + + roleBuilder + .HasMany(x => x.GlobalAuthorities) + .WithMany() + .UsingEntity( + r => r + .HasOne(x => x.GlobalAuthority) + .WithMany() + .HasForeignKey(x => x.GlobalAuthorityId), + l => l + .HasOne(x => x.Role) + .WithMany() + .HasForeignKey(x => x.RoleId), + j => j + .HasKey(x => new { x.RoleId, x.GlobalAuthorityId }) + ); + + roleBuilder.HasOne(x => x.Tenant) + .WithMany(x => x.Roles) + .HasForeignKey(x => x.TenantId); + + roleBuilder.HasOne(x => x.App) + .WithMany(x => x.Roles) + .HasForeignKey(x => x.AppId); + + roleBuilder + .HasMany(x => x.Subjects) + .WithMany(x => x.Roles) + .UsingEntity( + r => r + .HasOne(x => x.Subject) + .WithMany() + .HasForeignKey(x => x.SubjectId), + l => l + .HasOne(x => x.Role) + .WithMany() + .HasForeignKey(x => x.RoleId), + j => j + .HasKey(x => new { x.RoleId, x.SubjectId })); + + roleBuilder.HasIndex(x => new { x.Name, x.AppId }) + .IsUnique() + .HasFilter($"\"{nameof(GroupEntity.AppId)}\" IS NOT NULL"); + + roleBuilder.HasIndex(x => new { x.Name, x.TenantId }) + .IsUnique() + .HasFilter($"\"{nameof(GroupEntity.AppId)}\" IS NULL"); + #endregion #region Authority var authorityBuilder = builder.Entity(); - authorityBuilder - .HasData( - new AuthorityEntity - { - Id = 1, - Type = AuthorityType.Tenant, - Name = "Tenant_Read", - Description = "Allows users to read tenants" - }, new AuthorityEntity - { - Id = 2, - Type = AuthorityType.App, - Name = "App_Read", - Description = "Allows users to read apps" - } - ); + authorityBuilder.HasOne(x => x.Tenant) + .WithMany(x => x.Authorities) + .HasForeignKey(x => x.TenantId); - authorityBuilder - .HasKey(x => x.Id); + authorityBuilder.HasOne(x => x.App) + .WithMany(x => x.Authorities) + .HasForeignKey(x => x.AppId); - authorityBuilder - .HasIndex(x => x.Name) + authorityBuilder.HasIndex(x => new { x.Name, x.AppId }) + .IsUnique() + .HasFilter($"\"{nameof(GroupEntity.AppId)}\" IS NOT NULL"); + + authorityBuilder.HasIndex(x => new { x.Name, x.TenantId }) + .IsUnique() + .HasFilter($"\"{nameof(GroupEntity.AppId)}\" IS NULL"); + + #endregion + + #region GlobalAuthority + + var globalAuthorityBuilder = builder.Entity(); + + globalAuthorityBuilder.HasIndex(x => x.Name) .IsUnique(); #endregion @@ -191,7 +285,7 @@ public abstract class CoreContext(DbContextOptions options) : DbContext(op builder.Entity(); #endregion - + #region AuthCodes builder.Entity(); diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/App/AppEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/App/AppEntity.cs index 60b8ac7..bab075e 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/App/AppEntity.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/App/AppEntity.cs @@ -1,4 +1,5 @@ using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission; using Suspectus.Gandalf.Palantir.Data.Entities.Subject; using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; using Suspectus.Gandalf.Palantir.Data.Entities.Version; @@ -9,6 +10,9 @@ public class AppEntity : AppData, IVersionableEntity { public TenantEntity? Tenant { get; set; } public HashSet Subjects { get; set; } = []; + public HashSet Groups { get; set; } = []; + public HashSet Roles { get; set; } = []; + public HashSet Authorities { get; set; } = []; } public class AppVersionEntity : AppData, IVersionEntity @@ -24,4 +28,12 @@ public abstract class AppData : TenantRelationData { public required string Name { get; set; } public required string BaseAddress { get; set; } +} + +public abstract class AppRelationData : TenantRelationData { + public required long AppId { get; set; } +} + +public abstract class OptionalAppRelationData : TenantRelationData { + public long? AppId { get; set; } } \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/App/AppSubjectRelationEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/App/AppSubjectRelationEntity.cs index 62e4c48..37f541c 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/App/AppSubjectRelationEntity.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/App/AppSubjectRelationEntity.cs @@ -1,19 +1,19 @@ using Suspectus.Gandalf.Palantir.Data.Entities.Base; using Suspectus.Gandalf.Palantir.Data.Entities.Security; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission; using Suspectus.Gandalf.Palantir.Data.Entities.Subject; using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; using Suspectus.Gandalf.Palantir.Data.Entities.Version; namespace Suspectus.Gandalf.Palantir.Data.Entities.App; -public class AppSubjectRelationEntity : AppSubjectRelationData, IMappingEntity, IVersionableEntity +public class AppSubjectRelationEntity : AppSubjectRelationData, IMappingEntity, IVersionableEntity { - public HashSet InternalAuthorities { get; set; } = []; public AppEntity? App { get; set; } public SubjectEntity? Subject { get; set; } } -public class AppSubjectRelationVersionEntity : AppSubjectRelationData, IVersionEntity +public class AppSubjectRelationVersionEntity : AppSubjectRelationData, IVersionEntity { public SubjectEntity? Suspect { get; set; } public long SuspectId { get; set; } @@ -22,8 +22,8 @@ public class AppSubjectRelationVersionEntity : AppSubjectRelationData, IVe public AppSubjectRelationEntity? Reference { get; set; } } -public abstract class AppSubjectRelationData where T : IConvertible +public abstract class AppSubjectRelationData { - public required T AppId { get; set; } - public required T SubjectId { get; set; } + public required long AppId { get; set; } + public required long SubjectId { get; set; } } \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/AppUserRelationInternalAuthorityRelationEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/AppUserRelationInternalAuthorityRelationEntity.cs deleted file mode 100644 index e48357a..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/AppUserRelationInternalAuthorityRelationEntity.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Suspectus.Gandalf.Palantir.Data.Entities.App; -using Suspectus.Gandalf.Palantir.Data.Entities.Base; -using Suspectus.Gandalf.Palantir.Data.Entities.Subject; -using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; -using Suspectus.Gandalf.Palantir.Data.Entities.Version; - -namespace Suspectus.Gandalf.Palantir.Data.Entities.Security; - -public class AppSubjectRelationInternalAuthorityRelationEntity : AppSubjectRelationInternalAuthorityRelationData, IMappingEntity, IVersionableEntity -{ - public AppSubjectRelationEntity? AppSubjectRelation { get; set; } - public AuthorityEntity? InternalAuthority { get; set; } -} - -public class AppSubjectRelationInternalAuthorityRelationVersionEntity : AppSubjectRelationInternalAuthorityRelationData, IVersionEntity -{ - public SubjectEntity? Suspect { get; set; } - public long SuspectId { get; set; } - public VersionAction Action { get; set; } - public DateTimeOffset At { get; set; } - public AppSubjectRelationInternalAuthorityRelationEntity? Reference { get; set; } -} - -public class AppSubjectRelationInternalAuthorityRelationData where T : IConvertible -{ - public required T AppId { get; set; } - public required T SubjectId { get; set; } - public required T InternalAuthorityId { get; set; } -} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/AuthorityEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/AuthorityEntity.cs deleted file mode 100644 index 1a12be3..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/AuthorityEntity.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Suspectus.Gandalf.Palantir.Data.Entities.App; -using Suspectus.Gandalf.Palantir.Data.Entities.Base; -using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; - -namespace Suspectus.Gandalf.Palantir.Data.Entities.Security; - -public class AuthorityEntity : IdData -{ - public required string Name { get; set; } - - public required AuthorityType Type { get; set; } - - [ContentKey] public string? Description { get; set; } - - public HashSet? TenantSubjectRelations { get; set; } = []; - public HashSet? AppSubjectRelations { get; set; } = []; -} - -public static class TenantAuthority -{ - public const string Read = "Tenant_Read"; -} - -public static class AppAuthority -{ - public const string Read = "App_Read"; -} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/AuthorityType.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/AuthorityType.cs deleted file mode 100644 index 2885813..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/AuthorityType.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace Suspectus.Gandalf.Palantir.Data.Entities.Security; - -public enum AuthorityType -{ - Tenant, - App -} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/AppSubjectRelationInternalAuthorityRelationData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/AppSubjectRelationInternalAuthorityRelationData.cs new file mode 100644 index 0000000..2bf9c15 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/AppSubjectRelationInternalAuthorityRelationData.cs @@ -0,0 +1,8 @@ +// namespace Suspectus.Gandalf.Palantir.Data.Entities.Security; +// +// public class AppSubjectRelationInternalAuthorityRelationData where T : IConvertible +// { +// public required T AppId { get; set; } +// public required T SubjectId { get; set; } +// public required T AuthorityId { get; set; } +// } \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/AppSubjectRelationInternalAuthorityRelationEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/AppSubjectRelationInternalAuthorityRelationEntity.cs new file mode 100644 index 0000000..f55bd4b --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/AppSubjectRelationInternalAuthorityRelationEntity.cs @@ -0,0 +1,12 @@ +// using Suspectus.Gandalf.Palantir.Data.Entities.App; +// using Suspectus.Gandalf.Palantir.Data.Entities.Base; +// using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission; +// using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; +// +// namespace Suspectus.Gandalf.Palantir.Data.Entities.Security; +// +// public class AppSubjectRelationInternalAuthorityRelationEntity : AppSubjectRelationInternalAuthorityRelationData, IMappingEntity, IVersionableEntity +// { +// public AppSubjectRelationEntity? AppSubjectRelation { get; set; } +// public AuthorityEntity? Authority { get; set; } +// } \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/AppSubjectRelationInternalAuthorityRelationVersionEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/AppSubjectRelationInternalAuthorityRelationVersionEntity.cs new file mode 100644 index 0000000..ee28259 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/AppSubjectRelationInternalAuthorityRelationVersionEntity.cs @@ -0,0 +1,13 @@ +// using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +// using Suspectus.Gandalf.Palantir.Data.Entities.Version; +// +// namespace Suspectus.Gandalf.Palantir.Data.Entities.Security; +// +// public class AppSubjectRelationInternalAuthorityRelationVersionEntity : AppSubjectRelationInternalAuthorityRelationData, IVersionEntity +// { +// public SubjectEntity? Suspect { get; set; } +// public long SuspectId { get; set; } +// public VersionAction Action { get; set; } +// public DateTimeOffset At { get; set; } +// public AppSubjectRelationInternalAuthorityRelationEntity? Reference { get; set; } +// } \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/TenantSubjectRoleRelationData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/TenantSubjectRoleRelationData.cs new file mode 100644 index 0000000..13fcb2b --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/TenantSubjectRoleRelationData.cs @@ -0,0 +1,8 @@ +// namespace Suspectus.Gandalf.Palantir.Data.Entities.Security; +// +// public class TenantSubjectRoleRelationData where T : IConvertible +// { +// public required T TenantId { get; set; } +// public required T SubjectId { get; set; } +// public required T RoleId { get; set; } +// } \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/TenantSubjectRoleRelationEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/TenantSubjectRoleRelationEntity.cs new file mode 100644 index 0000000..b1c9a23 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/TenantSubjectRoleRelationEntity.cs @@ -0,0 +1,11 @@ +// using Suspectus.Gandalf.Palantir.Data.Entities.Base; +// using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission; +// using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; +// +// namespace Suspectus.Gandalf.Palantir.Data.Entities.Security; +// +// public class TenantSubjectRoleRelationEntity : TenantSubjectRoleRelationData, IMappingEntity, IVersionableEntity +// { +// public TenantSubjectRelationEntity? TenantSubjectRelation { get; set; } +// public AuthorityEntity? Role { get; set; } +// } \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/TenantSubjectRoleRelationVersionEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/TenantSubjectRoleRelationVersionEntity.cs new file mode 100644 index 0000000..ac1a7ee --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Obsolete/TenantSubjectRoleRelationVersionEntity.cs @@ -0,0 +1,13 @@ +// using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +// using Suspectus.Gandalf.Palantir.Data.Entities.Version; +// +// namespace Suspectus.Gandalf.Palantir.Data.Entities.Security; +// +// public class TenantSubjectRoleRelationVersionEntity : TenantSubjectRoleRelationData, IVersionEntity +// { +// public SubjectEntity? Suspect { get; set; } +// public long SuspectId { get; set; } +// public VersionAction Action { get; set; } +// public DateTimeOffset At { get; set; } +// public TenantSubjectRoleRelationEntity? Reference { get; set; } +// } \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/AuthorityEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/AuthorityEntity.cs new file mode 100644 index 0000000..d546b21 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/AuthorityEntity.cs @@ -0,0 +1,13 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.App; +using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; +using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission; + +public class AuthorityEntity : AuthorityData, IVersionableEntity +{ + public HashSet Roles { get; set; } = []; + public TenantEntity Tenant { get; set; } = null!; + public AppEntity? App { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/AuthorityData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/AuthorityData.cs new file mode 100644 index 0000000..11d8a4c --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/AuthorityData.cs @@ -0,0 +1,8 @@ +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; + +public abstract class AuthorityData : DescribedCategorizedNameWithVisibilityData +{ + public required long TenantId { get; set; } + public long? AppId { get; set; } + public required AuthorityType Type { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/AuthorityType.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/AuthorityType.cs new file mode 100644 index 0000000..8270e03 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/AuthorityType.cs @@ -0,0 +1,7 @@ +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; + +public enum AuthorityType +{ + Tenant, + App +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/CategorizedNameData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/CategorizedNameData.cs new file mode 100644 index 0000000..4adb502 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/CategorizedNameData.cs @@ -0,0 +1,9 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Base; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; + +public abstract class CategorizedNameData : IdData +{ + public required string Name { get; set; } + public required string CategoryPath { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/DescribedCategorizedNameData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/DescribedCategorizedNameData.cs new file mode 100644 index 0000000..bfe2ae5 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/DescribedCategorizedNameData.cs @@ -0,0 +1,6 @@ +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; + +public abstract class DescribedCategorizedNameData : CategorizedNameData +{ + public string? Description { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/DescribedCategorizedNameWithVisibilityData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/DescribedCategorizedNameWithVisibilityData.cs new file mode 100644 index 0000000..fd4a641 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/DescribedCategorizedNameWithVisibilityData.cs @@ -0,0 +1,8 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Base; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; + +public abstract class DescribedCategorizedNameWithVisibilityData : DescribedCategorizedNameData +{ + public EntityVisibility Visibility { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/GlobalAuthorityData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/GlobalAuthorityData.cs new file mode 100644 index 0000000..46587f2 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/GlobalAuthorityData.cs @@ -0,0 +1,6 @@ +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; + +public abstract class GlobalAuthorityData : DescribedCategorizedNameData +{ + public AuthorityType Type { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/GroupData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/GroupData.cs new file mode 100644 index 0000000..dd870ff --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/GroupData.cs @@ -0,0 +1,3 @@ +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; + +public abstract class GroupData : AuthorityData; \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/RoleData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/RoleData.cs new file mode 100644 index 0000000..ec23340 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Data/RoleData.cs @@ -0,0 +1,3 @@ +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; + +public abstract class RoleData : AuthorityData; \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/GlobalAuthorityEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/GlobalAuthorityEntity.cs new file mode 100644 index 0000000..c51eccb --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/GlobalAuthorityEntity.cs @@ -0,0 +1,5 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission; + +public class GlobalAuthorityEntity : GlobalAuthorityData; \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/GroupEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/GroupEntity.cs new file mode 100644 index 0000000..0b39781 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/GroupEntity.cs @@ -0,0 +1,15 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.App; +using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; +using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission; + +public class GroupEntity : GroupData, IVersionableEntity +{ + public HashSet Roles { get; set; } = []; + public TenantEntity Tenant { get; set; } = null!; + public AppEntity? App { get; set; } + public HashSet Subjects { get; set; } = []; +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupRoleRelationData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupRoleRelationData.cs new file mode 100644 index 0000000..96b3f89 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupRoleRelationData.cs @@ -0,0 +1,7 @@ +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; + +public class GroupRoleRelationData +{ + public required long GroupId { get; set; } + public required long RoleId { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupRoleRelationEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupRoleRelationEntity.cs new file mode 100644 index 0000000..825b955 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupRoleRelationEntity.cs @@ -0,0 +1,10 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; + +public class GroupRoleRelationEntity : GroupRoleRelationData, IMappingEntity, IVersionableEntity +{ + public GroupEntity Group { get; set; } = null!; + public RoleEntity Role { get; set; } = null!; +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupSubjectRelationData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupSubjectRelationData.cs new file mode 100644 index 0000000..e682ce4 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupSubjectRelationData.cs @@ -0,0 +1,7 @@ +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; + +public class GroupSubjectRelationData +{ + public required long GroupId { get; set; } + public required long SubjectId { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupSubjectRelationEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupSubjectRelationEntity.cs new file mode 100644 index 0000000..394fabe --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/GroupSubjectRelationEntity.cs @@ -0,0 +1,11 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; + +public class GroupSubjectRelationEntity : GroupSubjectRelationData, IMappingEntity, IVersionableEntity +{ + public GroupEntity Group { get; set; } = null!; + public SubjectEntity Subject { get; set; } = null!; +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleAuthorityRelationData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleAuthorityRelationData.cs new file mode 100644 index 0000000..50e0811 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleAuthorityRelationData.cs @@ -0,0 +1,7 @@ +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; + +public class RoleAuthorityRelationData +{ + public required long RoleId { get; set; } + public required long AuthorityId { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleAuthorityRelationEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleAuthorityRelationEntity.cs new file mode 100644 index 0000000..d8a5f26 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleAuthorityRelationEntity.cs @@ -0,0 +1,10 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; + +public class RoleAuthorityRelationEntity : RoleAuthorityRelationData, IMappingEntity, IVersionableEntity +{ + public RoleEntity Role { get; set; } = null!; + public AuthorityEntity Authority { get; set; } = null!; +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleGlobalAuthorityRelationData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleGlobalAuthorityRelationData.cs new file mode 100644 index 0000000..cf77c4c --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleGlobalAuthorityRelationData.cs @@ -0,0 +1,7 @@ +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; + +public class RoleGlobalAuthorityRelationData +{ + public required long RoleId { get; set; } + public required long GlobalAuthorityId { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleGlobalAuthorityRelationEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleGlobalAuthorityRelationEntity.cs new file mode 100644 index 0000000..b3bbfce --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleGlobalAuthorityRelationEntity.cs @@ -0,0 +1,10 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; + +public class RoleGlobalAuthorityRelationEntity : RoleGlobalAuthorityRelationData, IMappingEntity, IVersionableEntity +{ + public RoleEntity Role { get; set; } = null!; + public GlobalAuthorityEntity GlobalAuthority { get; set; } = null!; +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleSubjectRelationData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleSubjectRelationData.cs new file mode 100644 index 0000000..1e0918c --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleSubjectRelationData.cs @@ -0,0 +1,7 @@ +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; + +public class RoleSubjectRelationData +{ + public required long RoleId { get; set; } + public required long SubjectId { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleSubjectRelationEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleSubjectRelationEntity.cs new file mode 100644 index 0000000..62f0967 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Relation/RoleSubjectRelationEntity.cs @@ -0,0 +1,11 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; + +public class RoleSubjectRelationEntity : RoleSubjectRelationData, IMappingEntity, IVersionableEntity +{ + public RoleEntity Role { get; set; } = null!; + public SubjectEntity Subject { get; set; } = null!; +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/RoleEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/RoleEntity.cs new file mode 100644 index 0000000..4f9d4f2 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/RoleEntity.cs @@ -0,0 +1,16 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.App; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; +using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission; + +public class RoleEntity : RoleData, IVersionableEntity +{ + public HashSet Groups { get; set; } = []; + public HashSet Authorities { get; set; } = []; + public HashSet GlobalAuthorities { get; set; } = []; + public HashSet Subjects { get; set; } = []; + public TenantEntity Tenant { get; set; } = null!; + public AppEntity? App { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/AuthorityVersionEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/AuthorityVersionEntity.cs new file mode 100644 index 0000000..5efe5de --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/AuthorityVersionEntity.cs @@ -0,0 +1,14 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; +using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +using Suspectus.Gandalf.Palantir.Data.Entities.Version; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version; + +public class AuthorityVersionEntity : AuthorityData, IVersionEntity +{ + public SubjectEntity? Suspect { get; set; } + public long SuspectId { get; set; } + public VersionAction Action { get; set; } + public DateTimeOffset At { get; set; } + public AuthorityEntity? Reference { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/GroupRoleRelationVersionEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/GroupRoleRelationVersionEntity.cs new file mode 100644 index 0000000..4e4935a --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/GroupRoleRelationVersionEntity.cs @@ -0,0 +1,15 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; +using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +using Suspectus.Gandalf.Palantir.Data.Entities.Version; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version; + +public class GroupRoleRelationVersionEntity : GroupRoleRelationData, IMappingEntity, IVersionEntity +{ + public SubjectEntity? Suspect { get; set; } + public long SuspectId { get; set; } + public VersionAction Action { get; set; } + public DateTimeOffset At { get; set; } + public GroupRoleRelationEntity? Reference { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/GroupSubjectRelationVersionEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/GroupSubjectRelationVersionEntity.cs new file mode 100644 index 0000000..04cb492 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/GroupSubjectRelationVersionEntity.cs @@ -0,0 +1,15 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; +using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +using Suspectus.Gandalf.Palantir.Data.Entities.Version; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version; + +public class GroupSubjectRelationVersionEntity : GroupSubjectRelationData, IMappingEntity, IVersionEntity +{ + public SubjectEntity? Suspect { get; set; } + public long SuspectId { get; set; } + public VersionAction Action { get; set; } + public DateTimeOffset At { get; set; } + public GroupSubjectRelationEntity? Reference { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/GroupVersionEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/GroupVersionEntity.cs new file mode 100644 index 0000000..32ea954 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/GroupVersionEntity.cs @@ -0,0 +1,14 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; +using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +using Suspectus.Gandalf.Palantir.Data.Entities.Version; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version; + +public class GroupVersionEntity : GroupData, IVersionEntity +{ + public SubjectEntity? Suspect { get; set; } + public long SuspectId { get; set; } + public VersionAction Action { get; set; } + public DateTimeOffset At { get; set; } + public GroupEntity? Reference { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleAuthorityRelationVersionEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleAuthorityRelationVersionEntity.cs new file mode 100644 index 0000000..00829c7 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleAuthorityRelationVersionEntity.cs @@ -0,0 +1,15 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; +using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +using Suspectus.Gandalf.Palantir.Data.Entities.Version; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version; + +public class RoleAuthorityRelationVersionEntity : RoleAuthorityRelationData, IMappingEntity, IVersionEntity +{ + public SubjectEntity? Suspect { get; set; } + public long SuspectId { get; set; } + public VersionAction Action { get; set; } + public DateTimeOffset At { get; set; } + public RoleAuthorityRelationEntity? Reference { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleGlobalAuthorityRelationVersionEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleGlobalAuthorityRelationVersionEntity.cs new file mode 100644 index 0000000..1f7e510 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleGlobalAuthorityRelationVersionEntity.cs @@ -0,0 +1,15 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; +using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +using Suspectus.Gandalf.Palantir.Data.Entities.Version; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version; + +public class RoleGlobalAuthorityRelationVersionEntity : RoleGlobalAuthorityRelationData, IMappingEntity, IVersionEntity +{ + public SubjectEntity? Suspect { get; set; } + public long SuspectId { get; set; } + public VersionAction Action { get; set; } + public DateTimeOffset At { get; set; } + public RoleGlobalAuthorityRelationEntity? Reference { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleSubjectRelationVersionEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleSubjectRelationVersionEntity.cs new file mode 100644 index 0000000..fdd9753 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleSubjectRelationVersionEntity.cs @@ -0,0 +1,15 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation; +using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +using Suspectus.Gandalf.Palantir.Data.Entities.Version; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version; + +public class RoleSubjectRelationVersionEntity : RoleSubjectRelationData, IMappingEntity, IVersionEntity +{ + public SubjectEntity? Suspect { get; set; } + public long SuspectId { get; set; } + public VersionAction Action { get; set; } + public DateTimeOffset At { get; set; } + public RoleSubjectRelationEntity? Reference { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleVersionEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleVersionEntity.cs new file mode 100644 index 0000000..a416b18 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/Permission/Version/RoleVersionEntity.cs @@ -0,0 +1,14 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; +using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +using Suspectus.Gandalf.Palantir.Data.Entities.Version; + +namespace Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version; + +public class RoleVersionEntity : RoleData, IVersionEntity +{ + public SubjectEntity? Suspect { get; set; } + public long SuspectId { get; set; } + public VersionAction Action { get; set; } + public DateTimeOffset At { get; set; } + public RoleEntity? Reference { get; set; } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/TenantSubjectRelationInternalAuthorityRelationEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/TenantSubjectRelationInternalAuthorityRelationEntity.cs deleted file mode 100644 index 2da41af..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Security/TenantSubjectRelationInternalAuthorityRelationEntity.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Suspectus.Gandalf.Palantir.Data.Entities.Base; -using Suspectus.Gandalf.Palantir.Data.Entities.Subject; -using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; -using Suspectus.Gandalf.Palantir.Data.Entities.Version; - -namespace Suspectus.Gandalf.Palantir.Data.Entities.Security; - -public class TenantSubjectRelationInternalAuthorityRelationEntity : TenantSubjectRelationInternalAuthorityRelationData, IMappingEntity, IVersionableEntity -{ - public TenantSubjectRelationEntity? TenantSubjectRelation { get; set; } - public AuthorityEntity? InternalAuthority { get; set; } -} - -public class TenantSubjectRelationInternalAuthorityRelationVersionEntity : TenantSubjectRelationInternalAuthorityRelationData, IVersionEntity -{ - public SubjectEntity? Suspect { get; set; } - public long SuspectId { get; set; } - public VersionAction Action { get; set; } - public DateTimeOffset At { get; set; } - public TenantSubjectRelationInternalAuthorityRelationEntity? Reference { get; set; } -} - -public class TenantSubjectRelationInternalAuthorityRelationData where T : IConvertible -{ - public required T TenantId { get; set; } - public required T SubjectId { get; set; } - public required T InternalAuthorityId { get; set; } -} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Base/SubjectData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Subject/SubjectData.cs similarity index 100% rename from src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Base/SubjectData.cs rename to src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Subject/SubjectData.cs diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Subject/SubjectEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Subject/SubjectEntity.cs index e22056c..0101cf0 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Subject/SubjectEntity.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Subject/SubjectEntity.cs @@ -1,5 +1,6 @@ using Suspectus.Gandalf.Palantir.Data.Entities.App; using Suspectus.Gandalf.Palantir.Data.Entities.Base; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission; using Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn; using Suspectus.Gandalf.Palantir.Data.Entities.Tenant; @@ -11,4 +12,6 @@ public class SubjectEntity : VisibilityData public HashSet SignInMethods { get; set; } = []; public HashSet Tenants { get; set; } = []; public HashSet Apps { get; set; } = []; + public HashSet Roles { get; set; } = []; + public HashSet Groups { get; set; } = []; } \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Tenant/TenantEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Tenant/TenantEntity.cs index f8f8fa4..ceac0a0 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Tenant/TenantEntity.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Tenant/TenantEntity.cs @@ -1,4 +1,5 @@ using Suspectus.Gandalf.Palantir.Data.Entities.App; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission; using Suspectus.Gandalf.Palantir.Data.Entities.Subject; using Suspectus.Gandalf.Palantir.Data.Entities.Version; @@ -9,6 +10,9 @@ public class TenantEntity : TenantData, IVersionableEntity public SubjectEntity? Owner { get; set; } public HashSet Subjects { get; set; } = []; public HashSet Apps { get; set; } = []; + public HashSet Groups { get; set; } = []; + public HashSet Roles { get; set; } = []; + public HashSet Authorities { get; set; } = []; } public interface IVersionableEntity; diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Base/TenantRelationData.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Tenant/TenantRelationData.cs similarity index 100% rename from src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Base/TenantRelationData.cs rename to src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Tenant/TenantRelationData.cs diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Tenant/TenantSubjectRelationEntity.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Tenant/TenantSubjectRelationEntity.cs index 8bd4bff..f83ba70 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Tenant/TenantSubjectRelationEntity.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Entities/Tenant/TenantSubjectRelationEntity.cs @@ -1,18 +1,18 @@ using Suspectus.Gandalf.Palantir.Data.Entities.Base; using Suspectus.Gandalf.Palantir.Data.Entities.Security; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission; using Suspectus.Gandalf.Palantir.Data.Entities.Subject; using Suspectus.Gandalf.Palantir.Data.Entities.Version; namespace Suspectus.Gandalf.Palantir.Data.Entities.Tenant; -public class TenantSubjectRelationEntity : TenantSubjectRelationData, IMappingEntity, IVersionableEntity +public class TenantSubjectRelationEntity : TenantSubjectRelationData, IMappingEntity, IVersionableEntity { public TenantEntity? Tenant { get; set; } public SubjectEntity? Subject { get; set; } - public HashSet InternalAuthorities { get; set; } = []; } -public class TenantSubjectRelationVersionEntity : TenantSubjectRelationData, IVersionEntity +public class TenantSubjectRelationVersionEntity : TenantSubjectRelationData, IVersionEntity { public SubjectEntity? Suspect { get; set; } public long SuspectId { get; set; } @@ -21,8 +21,8 @@ public class TenantSubjectRelationVersionEntity : TenantSubjectRelationData where T : IConvertible +public abstract class TenantSubjectRelationData { - public T TenantId { get; set; } - public T SubjectId { get; set; } + public required long TenantId { get; set; } + public required long SubjectId { get; set; } } \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/AuthorityAttribute.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/AuthorityAttribute.cs new file mode 100644 index 0000000..6b1088e --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/AuthorityAttribute.cs @@ -0,0 +1,19 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; + +namespace Suspectus.Gandalf.Palantir.Data.MasterData.Attributes; + +[AttributeUsage(AttributeTargets.Field)] +public class AuthorityAttribute : Attribute +{ + public string? OldKey { get; init; } + public string? Path { get; init; } + public AuthorityType Type { get; init; } + + + public AuthorityAttribute(AuthorityType type, string? path = null, string? oldKey = null) + { + OldKey = oldKey; + Type = type; + Path = path; + } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/GlobalAuthorityAttribute.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/GlobalAuthorityAttribute.cs new file mode 100644 index 0000000..7ffb9c3 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/GlobalAuthorityAttribute.cs @@ -0,0 +1,19 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; + +namespace Suspectus.Gandalf.Palantir.Data.MasterData.Attributes; + +[AttributeUsage(AttributeTargets.Field)] +public class GlobalAuthorityAttribute : Attribute +{ + public string? OldKey { get; init; } + public string? Path { get; init; } + public AuthorityType Type { get; init; } + + + public GlobalAuthorityAttribute(AuthorityType type, string? path = null, string? oldKey = null) + { + OldKey = oldKey; + Type = type; + Path = path; + } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/GroupAttribute.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/GroupAttribute.cs new file mode 100644 index 0000000..688377d --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/GroupAttribute.cs @@ -0,0 +1,18 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; + +namespace Suspectus.Gandalf.Palantir.Data.MasterData.Attributes; + +[AttributeUsage(AttributeTargets.Field)] +public class GroupAttribute : Attribute +{ + public string? OldKey { get; init; } + public AuthorityType Type { get; init; } + public string? Path { get; init; } + + public GroupAttribute(AuthorityType type, string? path = null, string? oldKey = null) + { + OldKey = oldKey; + Type = type; + Path = path; + } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/HasAuthoritiesAttribute.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/HasAuthoritiesAttribute.cs new file mode 100644 index 0000000..fabe75a --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/HasAuthoritiesAttribute.cs @@ -0,0 +1,18 @@ +namespace Suspectus.Gandalf.Palantir.Data.MasterData.Attributes; + +[AttributeUsage(AttributeTargets.Field)] +public class HasAuthoritiesAttribute : Attribute +{ + public IReadOnlyList Authorities { get; init; } = []; + public bool AllAuthorities { get; init; } + + public HasAuthoritiesAttribute(params string[] authorities) + { + Authorities = authorities; + } + + public HasAuthoritiesAttribute(bool allAuthorities) + { + AllAuthorities = allAuthorities; + } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/HasMasterAuthoritiesAttribute.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/HasGlobalAuthoritiesAttribute.cs similarity index 52% rename from src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/HasMasterAuthoritiesAttribute.cs rename to src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/HasGlobalAuthoritiesAttribute.cs index 7203b0b..af9ebca 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/HasMasterAuthoritiesAttribute.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/HasGlobalAuthoritiesAttribute.cs @@ -1,17 +1,17 @@ -namespace Suspectus.Gandalf.Palantir.Data.MasterData.Atttibutes; +namespace Suspectus.Gandalf.Palantir.Data.MasterData.Attributes; [AttributeUsage(AttributeTargets.Field)] -public class HasMasterAuthoritiesAttribute : Attribute +public class HasGlobalAuthoritiesAttribute : Attribute { public IReadOnlyList Authorities { get; init; } = []; public bool AllAuthorities { get; init; } - public HasMasterAuthoritiesAttribute(params string[] authorities) + public HasGlobalAuthoritiesAttribute(params string[] authorities) { Authorities = authorities; } - public HasMasterAuthoritiesAttribute(bool allAuthorities) + public HasGlobalAuthoritiesAttribute(bool allAuthorities) { AllAuthorities = allAuthorities; } diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/HasMasterRolesAttribute.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/HasRolesAttribute.cs similarity index 51% rename from src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/HasMasterRolesAttribute.cs rename to src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/HasRolesAttribute.cs index 15013fa..aeb6791 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/HasMasterRolesAttribute.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/HasRolesAttribute.cs @@ -1,17 +1,17 @@ -namespace Suspectus.Gandalf.Palantir.Data.MasterData.Atttibutes; +namespace Suspectus.Gandalf.Palantir.Data.MasterData.Attributes; [AttributeUsage(AttributeTargets.Field)] -public class HasMasterRolesAttribute : Attribute +public class HasRolesAttribute : Attribute { public IReadOnlyList Roles { get; init; } = []; public bool AllRoles { get; init; } - public HasMasterRolesAttribute(params string[] roles) + public HasRolesAttribute(params string[] roles) { Roles = roles; } - public HasMasterRolesAttribute(bool allRoles) + public HasRolesAttribute(bool allRoles) { AllRoles = allRoles; } diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/RoleAttribute.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/RoleAttribute.cs new file mode 100644 index 0000000..4af7feb --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Attributes/RoleAttribute.cs @@ -0,0 +1,9 @@ +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; + +namespace Suspectus.Gandalf.Palantir.Data.MasterData.Attributes; + +[AttributeUsage(AttributeTargets.Field)] +public class RoleAttribute : AuthorityAttribute +{ + public RoleAttribute(AuthorityType type, string? path = null, string? oldKey = null) : base(type, path, oldKey) {} +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/MasterAuthorityAttribute.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/MasterAuthorityAttribute.cs deleted file mode 100644 index 007cea5..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/MasterAuthorityAttribute.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Suspectus.Gandalf.Palantir.Data.MasterData.Atttibutes; - -[AttributeUsage(AttributeTargets.Field)] -public class MasterAuthorityAttribute : Attribute -{ - public string? OldKey { get; init; } - - public MasterAuthorityAttribute() {} - - public MasterAuthorityAttribute(string? oldKey) - { - OldKey = oldKey; - } -} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/MasterGroupAttribute.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/MasterGroupAttribute.cs deleted file mode 100644 index 234d0a3..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/MasterGroupAttribute.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Suspectus.Gandalf.Palantir.Data.MasterData.Atttibutes; - -[AttributeUsage(AttributeTargets.Field)] -public class MasterGroupAttribute : Attribute -{ - public string? OldKey { get; init; } - - public MasterGroupAttribute() {} - - public MasterGroupAttribute(string? oldKey) - { - OldKey = oldKey; - } -} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/MasterRoleAttribute.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/MasterRoleAttribute.cs deleted file mode 100644 index 777286e..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Atttibutes/MasterRoleAttribute.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Suspectus.Gandalf.Palantir.Data.MasterData.Atttibutes; - -[AttributeUsage(AttributeTargets.Field)] -public class MasterRoleAttribute : Attribute -{ - public string? OldKey { get; init; } - - public MasterRoleAttribute() {} - - public MasterRoleAttribute(string? oldKey) - { - OldKey = oldKey; - } -} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Authorities.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Authorities.cs new file mode 100644 index 0000000..09e713b --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Authorities.cs @@ -0,0 +1,141 @@ +using System.ComponentModel; +using System.Reflection; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; +using Suspectus.Gandalf.Palantir.Data.MasterData.Attributes; + +namespace Suspectus.Gandalf.Palantir.Data.MasterData; + +public static class Authorities +{ + private const string RootPrefix = "g"; + + public static class Global + { + private const string GlobalPrefix = $"{RootPrefix}.global"; + + public static class TenantAuthorities + { + private const string TenantPrefix = $"{GlobalPrefix}.t"; + private const string TenantPath = "Tenant Authorities"; + + [GlobalAuthority(AuthorityType.Tenant, TenantPath)] [Description("Allows to see this tenant.")] + public const string View = $"{TenantPrefix}.view"; + + public static class App + { + private const string AppPrefix = $"{TenantPrefix}.a"; + private const string AppPath = $"{TenantPath}/App"; + + [GlobalAuthority(AuthorityType.Tenant, AppPath)] [Description("Allows to create a app for this tenant.")] + public const string Create = $"{AppPrefix}.add"; + } + } + + public static class AppAuthorities + { + private const string AppPrefix = $"{GlobalPrefix}.a"; + private const string AppPath = "App Authorities"; + + [GlobalAuthority(AuthorityType.App, AppPath)] [Description("Allows to see this app.")] + public const string View = $"{AppPrefix}.view"; + } + } + + public static class Profile + { + private const string ProfilePrefix = $"{RootPrefix}.p"; + private const string ProfilePath = $"{nameof(Profile)}"; + + [Authority(AuthorityType.App, ProfilePath)] [Description("Allows to view any profile.")] + public const string View = $"{ProfilePrefix}.view"; + + [Authority(AuthorityType.App, ProfilePath)] [Description("Allows to edit any profile.")] + public const string Edit = $"{ProfilePrefix}.edit"; + + public static class Self + { + private const string SelfProfilePrefix = $"{ProfilePrefix}.self"; + private const string SelfProfilePath = $"{ProfilePath}/{nameof(Self)}"; + + [Authority(AuthorityType.App, SelfProfilePath)] [Description("Allows to view your own profile.")] + public const string View = $"{SelfProfilePrefix}.view"; + + [Authority(AuthorityType.App, SelfProfilePath)] [Description("Allows to edit your own profile.")] + public const string Edit = $"{SelfProfilePrefix}.edit"; + } + } + + public static class Tenant + { + private const string TenantPrefix = $"{RootPrefix}.t"; + private const string TenantPath = $"{nameof(Tenant)}"; + + [Authority(AuthorityType.App, TenantPath)] [Description("Allows to create a tenant.")] + public const string Create = $"{TenantPrefix}.add"; + } + + public static List GetAllAuthorities() + { + var authorities = new List(); + CollectFields(typeof(Authorities)); + + return authorities + .Select(x => new MasterAuthorityData + { + Name = (string)x.GetValue(null)!, + Type = x.GetCustomAttribute()!.Type, + OldName = x.GetCustomAttribute()!.OldKey, + Description = x.GetCustomAttribute()?.Description ?? null, + Path = x.GetCustomAttribute()!.Path + }).ToList(); + + void CollectFields(Type type) + { + var fields = type + .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) + .Where(f => f.FieldType == typeof(string) && Attribute.IsDefined(f, typeof(AuthorityAttribute))); + + authorities.AddRange(fields); + + foreach (var nested in type.GetNestedTypes()) + CollectFields(nested); + } + } + + public static List GetAllGlobalAuthorities() + { + var authorities = new List(); + CollectFields(typeof(Authorities)); + + return authorities + .Select(x => new MasterAuthorityData + { + Name = (string)x.GetValue(null)!, + Type = x.GetCustomAttribute()!.Type, + OldName = x.GetCustomAttribute()!.OldKey, + Description = x.GetCustomAttribute()?.Description ?? null, + Path = x.GetCustomAttribute()!.Path + }).ToList(); + + void CollectFields(Type type) + { + var fields = type + .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) + .Where(f => f.FieldType == typeof(string) && Attribute.IsDefined(f, typeof(GlobalAuthorityAttribute))); + + authorities.AddRange(fields); + + foreach (var nested in type.GetNestedTypes()) + CollectFields(nested); + } + } + + public class MasterAuthorityData + { + public required string Name { get; set; } = null!; + public required AuthorityType Type { get; set; } + public string? OldName { get; set; } + public string? Description { get; set; } + public string? Path { get; set; } + } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/MasterGroups.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Groups.cs similarity index 55% rename from src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/MasterGroups.cs rename to src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Groups.cs index b3e4a41..2565f43 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/MasterGroups.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Groups.cs @@ -1,39 +1,47 @@ using System.ComponentModel; using System.Reflection; -using Suspectus.Gandalf.Palantir.Data.MasterData.Atttibutes; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; +using Suspectus.Gandalf.Palantir.Data.MasterData.Attributes; namespace Suspectus.Gandalf.Palantir.Data.MasterData; -public static class MasterGroups +public static class Groups { - [MasterGroup] - [Description("Contains the minimal set of Roles to use the application.")] - [HasMasterRoles(MasterRoles.SelfProfile)] - public const string BasicUser = "Basic User"; + [Group(AuthorityType.Tenant, "Housemaster", oldKey: "")] + [Description("Housemaster group, has full control over the tenant.")] + [HasRoles(Roles.TenantHousemaster)] + public const string TenantHousemaster = "Housemaster"; + + [Group(AuthorityType.App, "Housemaster")] + [Description("Housemaster group, has full control over the app.")] + [HasRoles(Roles.AppHousemaster)] + public const string AppHousemaster = "Housemaster"; public static List GetAllGroups() { var groups = new List(); - CollectFields(typeof(MasterGroups)); + CollectFields(typeof(Groups)); return groups .Select(x => new MasterGroupData { Name = (string)x.GetValue(null)!, - OldName = x.GetCustomAttribute()!.OldKey, + Type = x.GetCustomAttribute()!.Type, + OldName = x.GetCustomAttribute()!.OldKey, + Path = x.GetCustomAttribute()!.Path, Description = x.GetCustomAttribute()?.Description ?? null, Roles = GetRoles(x) }).ToList(); IReadOnlyList GetRoles(FieldInfo field) { - var hasMasterRolesAttribute = field.GetCustomAttribute(); + var hasMasterRolesAttribute = field.GetCustomAttribute(); if (hasMasterRolesAttribute is null) return []; if (hasMasterRolesAttribute.AllRoles) - return MasterRoles.GetAllRoles().Select(x => x.Name).ToList(); + return Roles.GetAllRoles().Select(x => x.Name).ToList(); return hasMasterRolesAttribute.Roles; } @@ -42,7 +50,7 @@ public static class MasterGroups { var fields = type .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) - .Where(f => f.FieldType == typeof(string) && Attribute.IsDefined(f, typeof(MasterGroupAttribute))); + .Where(f => f.FieldType == typeof(string) && Attribute.IsDefined(f, typeof(GroupAttribute))); groups.AddRange(fields); @@ -53,9 +61,11 @@ public static class MasterGroups public class MasterGroupData { - public required string Name { get; set; } + public required string Name { get; set; } = null!; + public required AuthorityType Type { get; set; } public string? OldName { get; set; } public string? Description { get; set; } + public string? Path { get; set; } public IReadOnlyList Roles { get; set; } = []; } } \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/MasterAuthorities.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/MasterAuthorities.cs deleted file mode 100644 index 7bad799..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/MasterAuthorities.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System.ComponentModel; -using System.Reflection; -using Suspectus.Gandalf.Palantir.Data.MasterData.Atttibutes; - -namespace Suspectus.Gandalf.Palantir.Data.MasterData; - -public static class MasterAuthorities -{ - public static class Profile - { - [MasterAuthority] [Description("Allows to view any profile.")] - public const string Read = "g.profile.read"; - - [MasterAuthority] [Description("Allows to edit any profile.")] - public const string Write = "g.profile.write"; - - public static class Self - { - [MasterAuthority] [Description("Allows to view your own profile.")] - public const string Read = "g.profile.self.read"; - - [MasterAuthority] [Description("Allows to edit your own profile.")] - public const string Write = "g.profile.self.write"; - } - } - - public static List GetAllAuthorities() - { - var authorities = new List(); - CollectFields(typeof(MasterAuthorities)); - - return authorities - .Select(x => new MasterAuthorityData - { - Name = (string)x.GetValue(null)!, - OldName = x.GetCustomAttribute()!.OldKey, - Description = x.GetCustomAttribute()?.Description ?? null - }).ToList(); - - void CollectFields(Type type) - { - var fields = type - .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) - .Where(f => f.FieldType == typeof(string) && Attribute.IsDefined(f, typeof(MasterAuthorityAttribute))); - - authorities.AddRange(fields); - - foreach (var nested in type.GetNestedTypes()) - CollectFields(nested); - } - } - - public class MasterAuthorityData - { - public string Name { get; set; } = null!; - public string? OldName { get; set; } - public string? Description { get; set; } - } -} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/MasterRoles.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/MasterRoles.cs deleted file mode 100644 index abc390e..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/MasterRoles.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System.ComponentModel; -using System.Reflection; -using Suspectus.Gandalf.Palantir.Data.MasterData.Atttibutes; - -namespace Suspectus.Gandalf.Palantir.Data.MasterData; - -public static class MasterRoles -{ - [MasterRole] - [Description("Allows everything.")] - [HasMasterAuthorities(true)] - public const string Housemaster = nameof(Housemaster); - - [MasterRole] - [Description("Allows to view your own profile.")] - [HasMasterAuthorities(MasterAuthorities.Profile.Self.Read, MasterAuthorities.Profile.Self.Write)] - public const string SelfProfile = "Self Profile"; - - public static List GetAllRoles() - { - var roles = new List(); - CollectFields(typeof(MasterRoles)); - - return roles - .Select(x => new MasterRoleData - { - Name = (string)x.GetValue(null)!, - OldName = x.GetCustomAttribute()!.OldKey, - Description = x.GetCustomAttribute()?.Description ?? null, - Authorities = GetAuthorities(x) - }).ToList(); - - IReadOnlyList GetAuthorities(FieldInfo field) - { - var hasMasterAuthoritiesAttribute = field.GetCustomAttribute(); - - if (hasMasterAuthoritiesAttribute is null) - return []; - - if (hasMasterAuthoritiesAttribute.AllAuthorities) - return MasterAuthorities.GetAllAuthorities().Select(x => x.Name).ToList(); - - return hasMasterAuthoritiesAttribute.Authorities; - } - - void CollectFields(Type type) - { - var fields = type - .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) - .Where(f => f.FieldType == typeof(string) && Attribute.IsDefined(f, typeof(MasterRoleAttribute))); - - roles.AddRange(fields); - - foreach (var nested in type.GetNestedTypes()) - CollectFields(nested); - } - } - - public class MasterRoleData - { - public required string Name { get; set; } - public string? OldName { get; set; } - public string? Description { get; set; } - public IReadOnlyList Authorities { get; set; } = []; - } -} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Roles.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Roles.cs new file mode 100644 index 0000000..8a7ccfd --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/MasterData/Roles.cs @@ -0,0 +1,100 @@ +using System.ComponentModel; +using System.Reflection; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; +using Suspectus.Gandalf.Palantir.Data.MasterData.Attributes; + +namespace Suspectus.Gandalf.Palantir.Data.MasterData; + +public static class Roles +{ + [Role(AuthorityType.App, "Housemaster")] + [Description("Allows everything.")] + [HasAuthorities(true)] + [HasGlobalAuthorities(true)] + public const string AppHousemaster = "Housemaster"; + + [Role(AuthorityType.Tenant, "Housemaster")] + [Description("Allows everything.")] + [HasAuthorities(true)] + [HasGlobalAuthorities(true)] + public const string TenantHousemaster = "Housemaster"; + + public static List GetAllRoles() + { + var roles = new List(); + CollectFields(typeof(Roles)); + + return roles + .Select(x => new MasterRoleData + { + Name = (string)x.GetValue(null)!, + Type = x.GetCustomAttribute()!.Type, + OldName = x.GetCustomAttribute()!.OldKey, + Path = x.GetCustomAttribute()!.Path, + Description = x.GetCustomAttribute()?.Description ?? null, + Authorities = GetAuthorities(x, x.GetCustomAttribute()!.Type), + GlobalAuthorities= GetGlobalAuthorities(x, x.GetCustomAttribute()!.Type) + }).ToList(); + + IReadOnlyList GetGlobalAuthorities(FieldInfo field, AuthorityType type) + { + var hasGlobalAuthoritiesAttribute = field.GetCustomAttribute(); + + if (hasGlobalAuthoritiesAttribute is null) + return []; + + if (hasGlobalAuthoritiesAttribute.AllAuthorities) + { + return Authorities + .GetAllGlobalAuthorities() + .Where(x => x.Type == type) + .Select(x => x.Name) + .ToList(); + } + + return hasGlobalAuthoritiesAttribute.Authorities; + } + + IReadOnlyList GetAuthorities(FieldInfo field, AuthorityType type) + { + var hasAuthoritiesAttribute = field.GetCustomAttribute(); + + if (hasAuthoritiesAttribute is null) + return []; + + if (hasAuthoritiesAttribute.AllAuthorities) + { + return Authorities + .GetAllAuthorities() + .Where(x => x.Type == type) + .Select(x => x.Name) + .ToList(); + } + + return hasAuthoritiesAttribute.Authorities; + } + + void CollectFields(Type type) + { + var fields = type + .GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy) + .Where(f => f.FieldType == typeof(string) && Attribute.IsDefined(f, typeof(RoleAttribute))); + + roles.AddRange(fields); + + foreach (var nested in type.GetNestedTypes()) + CollectFields(nested); + } + } + + public class MasterRoleData + { + public required string Name { get; set; } = null!; + public required AuthorityType Type { get; set; } + public string? OldName { get; set; } + public string? Description { get; set; } + public string? Path { get; init; } + public IReadOnlyList Authorities { get; set; } = []; + public IReadOnlyList GlobalAuthorities { get; set; } = []; + } +} \ No newline at end of file diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240903154112_sus.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240903154112_sus.Designer.cs deleted file mode 100644 index 3de120c..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240903154112_sus.Designer.cs +++ /dev/null @@ -1,663 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20240903154112_sus")] - partial class sus - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("AppRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - - b.HasData( - new - { - Id = 1L, - Name = "chris", - Visibility = "Active" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240903154112_sus.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240903154112_sus.cs deleted file mode 100644 index c2781fc..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240903154112_sus.cs +++ /dev/null @@ -1,592 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class sus : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.EnsureSchema( - name: "gr"); - - migrationBuilder.CreateTable( - name: "Authority", - schema: "gr", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "text", nullable: false), - Type = table.Column(type: "text", nullable: false), - Description = table.Column(type: "text", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Authority", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Subject", - schema: "gr", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Name = table.Column(type: "text", nullable: false), - Visibility = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Subject", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "SignIn", - schema: "gr", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Method = table.Column(type: "text", nullable: false), - IsLegacy = table.Column(type: "boolean", nullable: false), - Email = table.Column(type: "text", nullable: true), - PasswordHash = table.Column(type: "text", nullable: true), - Visibility = table.Column(type: "text", nullable: false), - SubjectId = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_SignIn", x => x.Id); - table.ForeignKey( - name: "FK_SignIn_Subject_SubjectId", - column: x => x.SubjectId, - principalSchema: "gr", - principalTable: "Subject", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Tenant", - schema: "gr", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Visibility = table.Column(type: "text", nullable: false), - OwnerId = table.Column(type: "bigint", nullable: false), - Name = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Tenant", x => x.Id); - table.ForeignKey( - name: "FK_Tenant_Subject_OwnerId", - column: x => x.OwnerId, - principalSchema: "gr", - principalTable: "Subject", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AppRelation", - schema: "gr", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Visibility = table.Column(type: "text", nullable: false), - TenantId = table.Column(type: "bigint", nullable: false), - Name = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AppRelation", x => x.Id); - table.ForeignKey( - name: "FK_AppRelation_Tenant_TenantId", - column: x => x.TenantId, - principalSchema: "gr", - principalTable: "Tenant", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "TenantSubjectRelation", - schema: "gr", - columns: table => new - { - TenantId = table.Column(type: "bigint", nullable: false), - SubjectId = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TenantSubjectRelation", x => new { x.SubjectId, x.TenantId }); - table.ForeignKey( - name: "FK_TenantSubjectRelation_Subject_SubjectId", - column: x => x.SubjectId, - principalSchema: "gr", - principalTable: "Subject", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_TenantSubjectRelation_Tenant_TenantId", - column: x => x.TenantId, - principalSchema: "gr", - principalTable: "Tenant", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "TenantVersion", - schema: "gr", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false), - At = table.Column(type: "timestamp with time zone", nullable: false), - SuspectId = table.Column(type: "bigint", nullable: false), - Action = table.Column(type: "text", nullable: false), - Visibility = table.Column(type: "text", nullable: false), - OwnerId = table.Column(type: "bigint", nullable: false), - Name = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TenantVersion", x => new { x.Id, x.At }); - table.ForeignKey( - name: "FK_TenantVersion_Subject_SuspectId", - column: x => x.SuspectId, - principalSchema: "gr", - principalTable: "Subject", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_TenantVersion_Tenant_Id", - column: x => x.Id, - principalSchema: "gr", - principalTable: "Tenant", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AppRelationVersion", - schema: "gr", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false), - At = table.Column(type: "timestamp with time zone", nullable: false), - SuspectId = table.Column(type: "bigint", nullable: false), - Action = table.Column(type: "text", nullable: false), - Visibility = table.Column(type: "text", nullable: false), - TenantId = table.Column(type: "bigint", nullable: false), - Name = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AppRelationVersion", x => new { x.Id, x.At }); - table.ForeignKey( - name: "FK_AppRelationVersion_AppRelation_Id", - column: x => x.Id, - principalSchema: "gr", - principalTable: "AppRelation", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AppRelationVersion_Subject_SuspectId", - column: x => x.SuspectId, - principalSchema: "gr", - principalTable: "Subject", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AppSubjectRelation", - schema: "gr", - columns: table => new - { - AppId = table.Column(type: "bigint", nullable: false), - SubjectId = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AppSubjectRelation", x => new { x.SubjectId, x.AppId }); - table.ForeignKey( - name: "FK_AppSubjectRelation_AppRelation_AppId", - column: x => x.AppId, - principalSchema: "gr", - principalTable: "AppRelation", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AppSubjectRelation_Subject_SubjectId", - column: x => x.SubjectId, - principalSchema: "gr", - principalTable: "Subject", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "TenantSubjectRelationInternalAuthorityRelation", - schema: "gr", - columns: table => new - { - TenantId = table.Column(type: "bigint", nullable: false), - SubjectId = table.Column(type: "bigint", nullable: false), - InternalAuthorityId = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TenantSubjectRelationInternalAuthorityRelation", x => new { x.SubjectId, x.TenantId, x.InternalAuthorityId }); - table.ForeignKey( - name: "FK_TenantSubjectRelationInternalAuthorityRelation_Authority_In~", - column: x => x.InternalAuthorityId, - principalSchema: "gr", - principalTable: "Authority", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_TenantSubjectRelationInternalAuthorityRelation_TenantSubjec~", - columns: x => new { x.SubjectId, x.TenantId }, - principalSchema: "gr", - principalTable: "TenantSubjectRelation", - principalColumns: new[] { "SubjectId", "TenantId" }, - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "TenantSubjectRelationVersion", - schema: "gr", - columns: table => new - { - TenantId = table.Column(type: "bigint", nullable: false), - SubjectId = table.Column(type: "bigint", nullable: false), - At = table.Column(type: "timestamp with time zone", nullable: false), - SuspectId = table.Column(type: "bigint", nullable: false), - Action = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TenantSubjectRelationVersion", x => new { x.SubjectId, x.TenantId, x.At }); - table.ForeignKey( - name: "FK_TenantSubjectRelationVersion_Subject_SuspectId", - column: x => x.SuspectId, - principalSchema: "gr", - principalTable: "Subject", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_TenantSubjectRelationVersion_TenantSubjectRelation_SubjectI~", - columns: x => new { x.SubjectId, x.TenantId }, - principalSchema: "gr", - principalTable: "TenantSubjectRelation", - principalColumns: new[] { "SubjectId", "TenantId" }, - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AppSubjectRelationInternalAuthorityRelation", - schema: "gr", - columns: table => new - { - AppId = table.Column(type: "bigint", nullable: false), - SubjectId = table.Column(type: "bigint", nullable: false), - InternalAuthorityId = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AppSubjectRelationInternalAuthorityRelation", x => new { x.SubjectId, x.AppId, x.InternalAuthorityId }); - table.ForeignKey( - name: "FK_AppSubjectRelationInternalAuthorityRelation_AppSubjectRelat~", - columns: x => new { x.SubjectId, x.AppId }, - principalSchema: "gr", - principalTable: "AppSubjectRelation", - principalColumns: new[] { "SubjectId", "AppId" }, - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AppSubjectRelationInternalAuthorityRelation_Authority_Inter~", - column: x => x.InternalAuthorityId, - principalSchema: "gr", - principalTable: "Authority", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AppSubjectRelationVersion", - schema: "gr", - columns: table => new - { - AppId = table.Column(type: "bigint", nullable: false), - SubjectId = table.Column(type: "bigint", nullable: false), - At = table.Column(type: "timestamp with time zone", nullable: false), - SuspectId = table.Column(type: "bigint", nullable: false), - Action = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AppSubjectRelationVersion", x => new { x.SubjectId, x.AppId, x.At }); - table.ForeignKey( - name: "FK_AppSubjectRelationVersion_AppSubjectRelation_SubjectId_AppId", - columns: x => new { x.SubjectId, x.AppId }, - principalSchema: "gr", - principalTable: "AppSubjectRelation", - principalColumns: new[] { "SubjectId", "AppId" }, - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AppSubjectRelationVersion_Subject_SuspectId", - column: x => x.SuspectId, - principalSchema: "gr", - principalTable: "Subject", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "TenantSubjectRelationInternalAuthorityRelationVersion", - schema: "gr", - columns: table => new - { - TenantId = table.Column(type: "bigint", nullable: false), - SubjectId = table.Column(type: "bigint", nullable: false), - InternalAuthorityId = table.Column(type: "bigint", nullable: false), - At = table.Column(type: "timestamp with time zone", nullable: false), - SuspectId = table.Column(type: "bigint", nullable: false), - Action = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TenantSubjectRelationInternalAuthorityRelationVersion", x => new { x.SubjectId, x.TenantId, x.InternalAuthorityId, x.At }); - table.ForeignKey( - name: "FK_TenantSubjectRelationInternalAuthorityRelationVersion_Subje~", - column: x => x.SuspectId, - principalSchema: "gr", - principalTable: "Subject", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_TenantSubjectRelationInternalAuthorityRelationVersion_Tenan~", - columns: x => new { x.SubjectId, x.TenantId, x.InternalAuthorityId }, - principalSchema: "gr", - principalTable: "TenantSubjectRelationInternalAuthorityRelation", - principalColumns: new[] { "SubjectId", "TenantId", "InternalAuthorityId" }, - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AppSubjectRelationInternalAuthorityRelationVersion", - schema: "gr", - columns: table => new - { - AppId = table.Column(type: "bigint", nullable: false), - SubjectId = table.Column(type: "bigint", nullable: false), - InternalAuthorityId = table.Column(type: "bigint", nullable: false), - At = table.Column(type: "timestamp with time zone", nullable: false), - SuspectId = table.Column(type: "bigint", nullable: false), - Action = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AppSubjectRelationInternalAuthorityRelationVersion", x => new { x.SubjectId, x.AppId, x.InternalAuthorityId, x.At }); - table.ForeignKey( - name: "FK_AppSubjectRelationInternalAuthorityRelationVersion_AppSubje~", - columns: x => new { x.SubjectId, x.AppId, x.InternalAuthorityId }, - principalSchema: "gr", - principalTable: "AppSubjectRelationInternalAuthorityRelation", - principalColumns: new[] { "SubjectId", "AppId", "InternalAuthorityId" }, - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AppSubjectRelationInternalAuthorityRelationVersion_Subject_~", - column: x => x.SuspectId, - principalSchema: "gr", - principalTable: "Subject", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.InsertData( - schema: "gr", - table: "Authority", - columns: new[] { "Id", "Description", "Name", "Type" }, - values: new object[,] - { - { 1L, "Allows users to read tenants", "Tenant_Read", "Tenant" }, - { 2L, "Allows users to read apps", "App_Read", "App" } - }); - - migrationBuilder.InsertData( - schema: "gr", - table: "Subject", - columns: new[] { "Id", "Name", "Visibility" }, - values: new object[] { 1L, "chris", "Active" }); - - migrationBuilder.CreateIndex( - name: "IX_AppRelation_TenantId", - schema: "gr", - table: "AppRelation", - column: "TenantId"); - - migrationBuilder.CreateIndex( - name: "IX_AppRelationVersion_SuspectId", - schema: "gr", - table: "AppRelationVersion", - column: "SuspectId"); - - migrationBuilder.CreateIndex( - name: "IX_AppSubjectRelation_AppId", - schema: "gr", - table: "AppSubjectRelation", - column: "AppId"); - - migrationBuilder.CreateIndex( - name: "IX_AppSubjectRelationInternalAuthorityRelation_InternalAuthori~", - schema: "gr", - table: "AppSubjectRelationInternalAuthorityRelation", - column: "InternalAuthorityId"); - - migrationBuilder.CreateIndex( - name: "IX_AppSubjectRelationInternalAuthorityRelationVersion_SuspectId", - schema: "gr", - table: "AppSubjectRelationInternalAuthorityRelationVersion", - column: "SuspectId"); - - migrationBuilder.CreateIndex( - name: "IX_AppSubjectRelationVersion_SuspectId", - schema: "gr", - table: "AppSubjectRelationVersion", - column: "SuspectId"); - - migrationBuilder.CreateIndex( - name: "IX_Authority_Name", - schema: "gr", - table: "Authority", - column: "Name", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_SignIn_SubjectId", - schema: "gr", - table: "SignIn", - column: "SubjectId"); - - migrationBuilder.CreateIndex( - name: "IX_Subject_Name", - schema: "gr", - table: "Subject", - column: "Name", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Tenant_OwnerId", - schema: "gr", - table: "Tenant", - column: "OwnerId"); - - migrationBuilder.CreateIndex( - name: "IX_TenantSubjectRelation_TenantId", - schema: "gr", - table: "TenantSubjectRelation", - column: "TenantId"); - - migrationBuilder.CreateIndex( - name: "IX_TenantSubjectRelationInternalAuthorityRelation_InternalAuth~", - schema: "gr", - table: "TenantSubjectRelationInternalAuthorityRelation", - column: "InternalAuthorityId"); - - migrationBuilder.CreateIndex( - name: "IX_TenantSubjectRelationInternalAuthorityRelationVersion_Suspe~", - schema: "gr", - table: "TenantSubjectRelationInternalAuthorityRelationVersion", - column: "SuspectId"); - - migrationBuilder.CreateIndex( - name: "IX_TenantSubjectRelationVersion_SuspectId", - schema: "gr", - table: "TenantSubjectRelationVersion", - column: "SuspectId"); - - migrationBuilder.CreateIndex( - name: "IX_TenantVersion_SuspectId", - schema: "gr", - table: "TenantVersion", - column: "SuspectId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AppRelationVersion", - schema: "gr"); - - migrationBuilder.DropTable( - name: "AppSubjectRelationInternalAuthorityRelationVersion", - schema: "gr"); - - migrationBuilder.DropTable( - name: "AppSubjectRelationVersion", - schema: "gr"); - - migrationBuilder.DropTable( - name: "SignIn", - schema: "gr"); - - migrationBuilder.DropTable( - name: "TenantSubjectRelationInternalAuthorityRelationVersion", - schema: "gr"); - - migrationBuilder.DropTable( - name: "TenantSubjectRelationVersion", - schema: "gr"); - - migrationBuilder.DropTable( - name: "TenantVersion", - schema: "gr"); - - migrationBuilder.DropTable( - name: "AppSubjectRelationInternalAuthorityRelation", - schema: "gr"); - - migrationBuilder.DropTable( - name: "TenantSubjectRelationInternalAuthorityRelation", - schema: "gr"); - - migrationBuilder.DropTable( - name: "AppSubjectRelation", - schema: "gr"); - - migrationBuilder.DropTable( - name: "Authority", - schema: "gr"); - - migrationBuilder.DropTable( - name: "TenantSubjectRelation", - schema: "gr"); - - migrationBuilder.DropTable( - name: "AppRelation", - schema: "gr"); - - migrationBuilder.DropTable( - name: "Tenant", - schema: "gr"); - - migrationBuilder.DropTable( - name: "Subject", - schema: "gr"); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914003536_addTokens.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914003536_addTokens.Designer.cs deleted file mode 100644 index 75c960c..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914003536_addTokens.Designer.cs +++ /dev/null @@ -1,716 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20240914003536_addTokens")] - partial class addTokens - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("AppRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - - b.HasData( - new - { - Id = 1L, - Name = "chris", - Visibility = "Active" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914003536_addTokens.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914003536_addTokens.cs deleted file mode 100644 index 62e8994..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914003536_addTokens.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class addTokens : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AuthCode", - schema: "gr", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Expiration = table.Column(type: "timestamp with time zone", nullable: false), - IsRevoked = table.Column(type: "boolean", nullable: false), - Code = table.Column(type: "text", nullable: false), - Challenge = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AuthCode", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "TokenMetadata", - schema: "gr", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Expiration = table.Column(type: "timestamp with time zone", nullable: false), - IsRevoked = table.Column(type: "boolean", nullable: false), - TokenType = table.Column(type: "text", nullable: false), - UsedBy = table.Column(type: "bigint", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TokenMetadata", x => x.Id); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AuthCode", - schema: "gr"); - - migrationBuilder.DropTable( - name: "TokenMetadata", - schema: "gr"); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914005530_affwaf.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914005530_affwaf.Designer.cs deleted file mode 100644 index 878ca16..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914005530_affwaf.Designer.cs +++ /dev/null @@ -1,716 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20240914005530_affwaf")] - partial class affwaf - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityAlwaysColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("AppRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityAlwaysColumn(b.Property("Id")); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityAlwaysColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityAlwaysColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityAlwaysColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityAlwaysColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - - b.HasData( - new - { - Id = 1L, - Name = "chris", - Visibility = "Active" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityAlwaysColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914005530_affwaf.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914005530_affwaf.cs deleted file mode 100644 index 7ef1222..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914005530_affwaf.cs +++ /dev/null @@ -1,173 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class affwaf : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "TokenMetadata", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "Tenant", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "Subject", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "SignIn", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "Authority", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "AuthCode", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "AppRelation", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "TokenMetadata", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "Tenant", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "Subject", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "SignIn", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "Authority", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "AuthCode", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "AppRelation", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914012943_fawfghh.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914012943_fawfghh.Designer.cs deleted file mode 100644 index 78d0160..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914012943_fawfghh.Designer.cs +++ /dev/null @@ -1,716 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20240914012943_fawfghh")] - partial class fawfghh - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("AppRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - - b.HasData( - new - { - Id = 1L, - Name = "chris", - Visibility = "Active" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914012943_fawfghh.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914012943_fawfghh.cs deleted file mode 100644 index 6c5a9bf..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914012943_fawfghh.cs +++ /dev/null @@ -1,173 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class fawfghh : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "TokenMetadata", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "Tenant", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "Subject", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "SignIn", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "Authority", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "AuthCode", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "AppRelation", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "TokenMetadata", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "Tenant", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "Subject", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "SignIn", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "Authority", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "AuthCode", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AlterColumn( - name: "Id", - schema: "gr", - table: "AppRelation", - type: "bigint", - nullable: false, - oldClrType: typeof(long), - oldType: "bigint") - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn) - .OldAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914014850_gjjjjjj.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914014850_gjjjjjj.Designer.cs deleted file mode 100644 index 4125b5a..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914014850_gjjjjjj.Designer.cs +++ /dev/null @@ -1,716 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20240914014850_gjjjjjj")] - partial class gjjjjjj - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("AppRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - - b.HasData( - new - { - Id = 1L, - Name = "chris", - Visibility = "Active" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914014850_gjjjjjj.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914014850_gjjjjjj.cs deleted file mode 100644 index e289962..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914014850_gjjjjjj.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class gjjjjjj : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914224344_jsoikgsoieg.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914224344_jsoikgsoieg.Designer.cs deleted file mode 100644 index fc2d00b..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914224344_jsoikgsoieg.Designer.cs +++ /dev/null @@ -1,719 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20240914224344_jsoikgsoieg")] - partial class jsoikgsoieg - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("AppRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - - b.HasData( - new - { - Id = 1L, - Name = "chris", - Visibility = "Active" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914224344_jsoikgsoieg.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914224344_jsoikgsoieg.cs deleted file mode 100644 index 05241a5..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240914224344_jsoikgsoieg.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class jsoikgsoieg : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateIndex( - name: "IX_SignIn_Email", - schema: "gr", - table: "SignIn", - column: "Email", - unique: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropIndex( - name: "IX_SignIn_Email", - schema: "gr", - table: "SignIn"); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919005908_afwawfawf.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919005908_afwawfawf.Designer.cs deleted file mode 100644 index f7e3011..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919005908_afwawfawf.Designer.cs +++ /dev/null @@ -1,730 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20240919005908_afwawfawf")] - partial class afwawfawf - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("AppRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - - b.HasData( - new - { - Id = 1L, - Name = "chris", - Visibility = "Active" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Temp.TempInvokerContextEntity", b => - { - b.Property("SubjectId") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.HasKey("SubjectId"); - - b.ToTable("TempInvokerContext", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919005908_afwawfawf.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919005908_afwawfawf.cs deleted file mode 100644 index 9f599e8..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919005908_afwawfawf.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class afwawfawf : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "TempInvokerContext", - schema: "gr", - columns: table => new - { - SubjectId = table.Column(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TempInvokerContext", x => x.SubjectId); - }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "TempInvokerContext", - schema: "gr"); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010339_ffffff.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010339_ffffff.Designer.cs deleted file mode 100644 index 09430ff..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010339_ffffff.Designer.cs +++ /dev/null @@ -1,729 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20240919010339_ffffff")] - partial class ffffff - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("AppRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - - b.HasData( - new - { - Id = 1L, - Name = "chris", - Visibility = "Active" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Temp.TempInvokerContextEntity", b => - { - b.Property("SubjectId") - .HasColumnType("uuid"); - - b.ToTable("TempInvokerContext", "gr"); - - b.ToView("#TempInvokerContext", (string)null); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010339_ffffff.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010339_ffffff.cs deleted file mode 100644 index 8652e18..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010339_ffffff.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class ffffff : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropPrimaryKey( - name: "PK_TempInvokerContext", - schema: "gr", - table: "TempInvokerContext"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddPrimaryKey( - name: "PK_TempInvokerContext", - schema: "gr", - table: "TempInvokerContext", - column: "SubjectId"); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010748_jm├ñpromh.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010748_jm├ñpromh.Designer.cs deleted file mode 100644 index 80319d4..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010748_jm├ñpromh.Designer.cs +++ /dev/null @@ -1,730 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20240919010748_jm├ñpromh")] - partial class jmñpromh - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("AppRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - - b.HasData( - new - { - Id = 1L, - Name = "chris", - Visibility = "Active" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Temp.TempInvokerContextEntity", b => - { - b.Property("SubjectId") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.HasKey("SubjectId"); - - b.ToTable("TempInvokerContext", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010748_jm├ñpromh.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010748_jm├ñpromh.cs deleted file mode 100644 index fe216d8..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919010748_jm├ñpromh.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class jmñpromh : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddPrimaryKey( - name: "PK_TempInvokerContext", - schema: "gr", - table: "TempInvokerContext", - column: "SubjectId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropPrimaryKey( - name: "PK_TempInvokerContext", - schema: "gr", - table: "TempInvokerContext"); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919012025_fghdhhzttr.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919012025_fghdhhzttr.Designer.cs deleted file mode 100644 index 8d9e1aa..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919012025_fghdhhzttr.Designer.cs +++ /dev/null @@ -1,719 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20240919012025_fghdhhzttr")] - partial class fghdhhzttr - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("AppRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - - b.HasData( - new - { - Id = 1L, - Name = "chris", - Visibility = "Active" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919012025_fghdhhzttr.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919012025_fghdhhzttr.cs deleted file mode 100644 index d01d1b3..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240919012025_fghdhhzttr.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class fghdhhzttr : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "TempInvokerContext", - schema: "gr"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "TempInvokerContext", - schema: "gr", - columns: table => new - { - SubjectId = table.Column(type: "uuid", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TempInvokerContext", x => x.SubjectId); - }); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240921214234_kl├╢hmpdmpmgr.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240921214234_kl├╢hmpdmpmgr.Designer.cs deleted file mode 100644 index 4d10b12..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240921214234_kl├╢hmpdmpmgr.Designer.cs +++ /dev/null @@ -1,726 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20240921214234_kl├╢hmpdmpmgr")] - partial class klhmpdmpmgr - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("AppRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Algorithm") - .IsRequired() - .HasColumnType("text"); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - - b.HasData( - new - { - Id = 1L, - Name = "chris", - Visibility = "Active" - }); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppRelationEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("W542.GandalfReborn.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240921214234_kl├╢hmpdmpmgr.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240921214234_kl├╢hmpdmpmgr.cs deleted file mode 100644 index d8a7900..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20240921214234_kl├╢hmpdmpmgr.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class klhmpdmpmgr : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Algorithm", - schema: "gr", - table: "AuthCode", - type: "text", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "SubjectId", - schema: "gr", - table: "AuthCode", - type: "bigint", - nullable: false, - defaultValue: 0L); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Algorithm", - schema: "gr", - table: "AuthCode"); - - migrationBuilder.DropColumn( - name: "SubjectId", - schema: "gr", - table: "AuthCode"); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525155339_cringe1.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525155339_cringe1.Designer.cs deleted file mode 100644 index a4150ea..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525155339_cringe1.Designer.cs +++ /dev/null @@ -1,718 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20250525155339_cringe1")] - partial class cringe1 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "9.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppRelationEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("AppRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppRelationVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Algorithm") - .IsRequired() - .HasColumnType("text"); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppRelationEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppRelationEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525155339_cringe1.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525155339_cringe1.cs deleted file mode 100644 index 85aa528..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525155339_cringe1.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class cringe1 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DeleteData( - schema: "gr", - table: "Subject", - keyColumn: "Id", - keyValue: 1L); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.InsertData( - schema: "gr", - table: "Subject", - columns: new[] { "Id", "Name", "Visibility" }, - values: new object[] { 1L, "chris", "Active" }); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525162427_cringe2.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525162427_cringe2.Designer.cs deleted file mode 100644 index d294744..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525162427_cringe2.Designer.cs +++ /dev/null @@ -1,718 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20250525162427_cringe2")] - partial class cringe2 - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "9.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("App", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Algorithm") - .IsRequired() - .HasColumnType("text"); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525162427_cringe2.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525162427_cringe2.cs deleted file mode 100644 index 0115b2a..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525162427_cringe2.cs +++ /dev/null @@ -1,230 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class cringe2 : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_AppRelation_Tenant_TenantId", - schema: "gr", - table: "AppRelation"); - - migrationBuilder.DropForeignKey( - name: "FK_AppRelationVersion_AppRelation_Id", - schema: "gr", - table: "AppRelationVersion"); - - migrationBuilder.DropForeignKey( - name: "FK_AppRelationVersion_Subject_SuspectId", - schema: "gr", - table: "AppRelationVersion"); - - migrationBuilder.DropForeignKey( - name: "FK_AppSubjectRelation_AppRelation_AppId", - schema: "gr", - table: "AppSubjectRelation"); - - migrationBuilder.DropPrimaryKey( - name: "PK_AppRelationVersion", - schema: "gr", - table: "AppRelationVersion"); - - migrationBuilder.DropPrimaryKey( - name: "PK_AppRelation", - schema: "gr", - table: "AppRelation"); - - migrationBuilder.RenameTable( - name: "AppRelationVersion", - schema: "gr", - newName: "AppVersion", - newSchema: "gr"); - - migrationBuilder.RenameTable( - name: "AppRelation", - schema: "gr", - newName: "App", - newSchema: "gr"); - - migrationBuilder.RenameIndex( - name: "IX_AppRelationVersion_SuspectId", - schema: "gr", - table: "AppVersion", - newName: "IX_AppVersion_SuspectId"); - - migrationBuilder.RenameIndex( - name: "IX_AppRelation_TenantId", - schema: "gr", - table: "App", - newName: "IX_App_TenantId"); - - migrationBuilder.AddPrimaryKey( - name: "PK_AppVersion", - schema: "gr", - table: "AppVersion", - columns: new[] { "Id", "At" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_App", - schema: "gr", - table: "App", - column: "Id"); - - migrationBuilder.AddForeignKey( - name: "FK_App_Tenant_TenantId", - schema: "gr", - table: "App", - column: "TenantId", - principalSchema: "gr", - principalTable: "Tenant", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_AppSubjectRelation_App_AppId", - schema: "gr", - table: "AppSubjectRelation", - column: "AppId", - principalSchema: "gr", - principalTable: "App", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_AppVersion_App_Id", - schema: "gr", - table: "AppVersion", - column: "Id", - principalSchema: "gr", - principalTable: "App", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_AppVersion_Subject_SuspectId", - schema: "gr", - table: "AppVersion", - column: "SuspectId", - principalSchema: "gr", - principalTable: "Subject", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_App_Tenant_TenantId", - schema: "gr", - table: "App"); - - migrationBuilder.DropForeignKey( - name: "FK_AppSubjectRelation_App_AppId", - schema: "gr", - table: "AppSubjectRelation"); - - migrationBuilder.DropForeignKey( - name: "FK_AppVersion_App_Id", - schema: "gr", - table: "AppVersion"); - - migrationBuilder.DropForeignKey( - name: "FK_AppVersion_Subject_SuspectId", - schema: "gr", - table: "AppVersion"); - - migrationBuilder.DropPrimaryKey( - name: "PK_AppVersion", - schema: "gr", - table: "AppVersion"); - - migrationBuilder.DropPrimaryKey( - name: "PK_App", - schema: "gr", - table: "App"); - - migrationBuilder.RenameTable( - name: "AppVersion", - schema: "gr", - newName: "AppRelationVersion", - newSchema: "gr"); - - migrationBuilder.RenameTable( - name: "App", - schema: "gr", - newName: "AppRelation", - newSchema: "gr"); - - migrationBuilder.RenameIndex( - name: "IX_AppVersion_SuspectId", - schema: "gr", - table: "AppRelationVersion", - newName: "IX_AppRelationVersion_SuspectId"); - - migrationBuilder.RenameIndex( - name: "IX_App_TenantId", - schema: "gr", - table: "AppRelation", - newName: "IX_AppRelation_TenantId"); - - migrationBuilder.AddPrimaryKey( - name: "PK_AppRelationVersion", - schema: "gr", - table: "AppRelationVersion", - columns: new[] { "Id", "At" }); - - migrationBuilder.AddPrimaryKey( - name: "PK_AppRelation", - schema: "gr", - table: "AppRelation", - column: "Id"); - - migrationBuilder.AddForeignKey( - name: "FK_AppRelation_Tenant_TenantId", - schema: "gr", - table: "AppRelation", - column: "TenantId", - principalSchema: "gr", - principalTable: "Tenant", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_AppRelationVersion_AppRelation_Id", - schema: "gr", - table: "AppRelationVersion", - column: "Id", - principalSchema: "gr", - principalTable: "AppRelation", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_AppRelationVersion_Subject_SuspectId", - schema: "gr", - table: "AppRelationVersion", - column: "SuspectId", - principalSchema: "gr", - principalTable: "Subject", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_AppSubjectRelation_AppRelation_AppId", - schema: "gr", - table: "AppSubjectRelation", - column: "AppId", - principalSchema: "gr", - principalTable: "AppRelation", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525174938_addIsMaster.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525174938_addIsMaster.Designer.cs deleted file mode 100644 index 7b0d345..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525174938_addIsMaster.Designer.cs +++ /dev/null @@ -1,724 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20250525174938_addIsMaster")] - partial class addIsMaster - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "9.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("App", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Algorithm") - .IsRequired() - .HasColumnType("text"); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("IsMaster") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsMaster") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525174938_addIsMaster.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525174938_addIsMaster.cs deleted file mode 100644 index ea8747d..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250525174938_addIsMaster.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class addIsMaster : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "IsMaster", - schema: "gr", - table: "TenantVersion", - type: "boolean", - nullable: false, - defaultValue: false); - - migrationBuilder.AddColumn( - name: "IsMaster", - schema: "gr", - table: "Tenant", - type: "boolean", - nullable: false, - defaultValue: false); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "IsMaster", - schema: "gr", - table: "TenantVersion"); - - migrationBuilder.DropColumn( - name: "IsMaster", - schema: "gr", - table: "Tenant"); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530220220_updateTokenMetadata.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530220220_updateTokenMetadata.Designer.cs deleted file mode 100644 index 4cb2d8d..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530220220_updateTokenMetadata.Designer.cs +++ /dev/null @@ -1,731 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20250530220220_updateTokenMetadata")] - partial class updateTokenMetadata - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "9.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("App", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Algorithm") - .IsRequired() - .HasColumnType("text"); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("Scope") - .IsRequired() - .HasColumnType("text"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.Property("UsedFor") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("IsMaster") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsMaster") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530220220_updateTokenMetadata.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530220220_updateTokenMetadata.cs deleted file mode 100644 index a86438b..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530220220_updateTokenMetadata.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class updateTokenMetadata : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Scope", - schema: "gr", - table: "TokenMetadata", - type: "text", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "UsedFor", - schema: "gr", - table: "TokenMetadata", - type: "bigint", - nullable: false, - defaultValue: 0L); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Scope", - schema: "gr", - table: "TokenMetadata"); - - migrationBuilder.DropColumn( - name: "UsedFor", - schema: "gr", - table: "TokenMetadata"); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530223053_addBaseAddress.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530223053_addBaseAddress.Designer.cs deleted file mode 100644 index b9bfe66..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530223053_addBaseAddress.Designer.cs +++ /dev/null @@ -1,739 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20250530223053_addBaseAddress")] - partial class addBaseAddress - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "9.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BaseAddress") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("App", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("BaseAddress") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Algorithm") - .IsRequired() - .HasColumnType("text"); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("Scope") - .IsRequired() - .HasColumnType("text"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.Property("UsedFor") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("IsMaster") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsMaster") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530223053_addBaseAddress.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530223053_addBaseAddress.cs deleted file mode 100644 index 0581e03..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530223053_addBaseAddress.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class addBaseAddress : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "BaseAddress", - schema: "gr", - table: "AppVersion", - type: "text", - nullable: false, - defaultValue: ""); - - migrationBuilder.AddColumn( - name: "BaseAddress", - schema: "gr", - table: "App", - type: "text", - nullable: false, - defaultValue: ""); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "BaseAddress", - schema: "gr", - table: "AppVersion"); - - migrationBuilder.DropColumn( - name: "BaseAddress", - schema: "gr", - table: "App"); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530235831_tokenType.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530235831_tokenType.Designer.cs deleted file mode 100644 index b2f7af1..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530235831_tokenType.Designer.cs +++ /dev/null @@ -1,739 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Suspectus.Gandalf.Palantir.Data.Database; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - [DbContext(typeof(ApplicationContext))] - [Migration("20250530235831_tokenType")] - partial class tokenType - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "9.0.2") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BaseAddress") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("TenantId"); - - b.ToTable("App", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId"); - - b.HasIndex("AppId"); - - b.ToTable("AppSubjectRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("BaseAddress") - .IsRequired() - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthCodeEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Algorithm") - .IsRequired() - .HasColumnType("text"); - - b.Property("Challenge") - .IsRequired() - .HasColumnType("text"); - - b.Property("Code") - .IsRequired() - .HasColumnType("text"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("AuthCode", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Description") - .HasColumnType("text"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Type") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TokenMetadataEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("IsRevoked") - .HasColumnType("boolean"); - - b.Property("Scope") - .IsRequired() - .HasColumnType("text"); - - b.Property("TokenType") - .IsRequired() - .HasColumnType("text"); - - b.Property("UsedBy") - .HasColumnType("bigint"); - - b.Property("UsedFor") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TokenMetadata", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Email") - .HasColumnType("text"); - - b.Property("IsLegacy") - .HasColumnType("boolean"); - - b.Property("Method") - .IsRequired() - .HasColumnType("text"); - - b.Property("PasswordHash") - .HasColumnType("text"); - - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Email") - .IsUnique(); - - b.HasIndex("SubjectId"); - - b.ToTable("SignIn", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("Name") - .IsUnique(); - - b.ToTable("Subject", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("IsMaster") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id"); - - b.HasIndex("OwnerId"); - - b.ToTable("Tenant", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantSubjectRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "TenantId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantSubjectRelationVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.Property("Id") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("IsMaster") - .HasColumnType("boolean"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text"); - - b.Property("OwnerId") - .HasColumnType("bigint"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.Property("Visibility") - .IsRequired() - .HasColumnType("text"); - - b.HasKey("Id", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("TenantVersion", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany("Apps") - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "App") - .WithMany() - .HasForeignKey("AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("App"); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn.SignInEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany("SignInMethods") - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Owner") - .WithMany() - .HasForeignKey("OwnerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") - .WithMany() - .HasForeignKey("SubjectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Subject"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantVersionEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Reference") - .WithMany() - .HasForeignKey("Id") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") - .WithMany() - .HasForeignKey("SuspectId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Reference"); - - b.Navigation("Suspect"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => - { - b.Navigation("SignInMethods"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => - { - b.Navigation("Apps"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530235831_tokenType.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530235831_tokenType.cs deleted file mode 100644 index ee94fe0..0000000 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250530235831_tokenType.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace W542.GandalfReborn.Data.Migrations -{ - /// - public partial class tokenType : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql( - """ - UPDATE gr."TokenMetadata" - SET "TokenType" = 'Access' - WHERE "TokenType" = 'User'; - - UPDATE gr."TokenMetadata" - SET "TokenType" = 'Refresh' - WHERE "TokenType" = 'Application'; - """ - ); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.Sql( - """ - UPDATE gr.TokenMetadata - SET TokenType = 'User' - WHERE TokenType = 'Access'; - - UPDATE gr.TokenMetadata - SET TokenType = 'Application' - WHERE TokenType = 'Refresh'; - """ - ); - } - } -} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250607014754_Init.Designer.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250607014754_Init.Designer.cs new file mode 100644 index 0000000..36c8fa2 --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250607014754_Init.Designer.cs @@ -0,0 +1,1363 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Suspectus.Gandalf.Palantir.Data.Database; + +#nullable disable + +namespace Suspectus.Gandalf.Palantir.Data.Migrations +{ + [DbContext(typeof(ApplicationContext))] + [Migration("20250607014754_Init")] + partial class Init + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BaseAddress") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("App", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", b => + { + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.Property("AppId") + .HasColumnType("bigint"); + + b.HasKey("SubjectId", "AppId"); + + b.HasIndex("AppId"); + + b.ToTable("AppSubjectRelation", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationVersionEntity", b => + { + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.Property("AppId") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.HasKey("SubjectId", "AppId", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("AppSubjectRelationVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppVersionEntity", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("BaseAddress") + .IsRequired() + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("AppVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthCodeEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Algorithm") + .IsRequired() + .HasColumnType("text"); + + b.Property("Challenge") + .IsRequired() + .HasColumnType("text"); + + b.Property("Code") + .IsRequired() + .HasColumnType("text"); + + b.Property("Expiration") + .HasColumnType("timestamp with time zone"); + + b.Property("IsRevoked") + .HasColumnType("boolean"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("AuthCode", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.AuthorityEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AppId") + .HasColumnType("bigint"); + + b.Property("CategoryPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AppId"); + + b.HasIndex("TenantId"); + + b.HasIndex("Name", "AppId") + .IsUnique() + .HasFilter("\"AppId\" IS NOT NULL"); + + b.HasIndex("Name", "TenantId") + .IsUnique() + .HasFilter("\"AppId\" IS NULL"); + + b.ToTable("Authority", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.GlobalAuthorityEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CategoryPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("GlobalAuthority", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.GroupEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AppId") + .HasColumnType("bigint"); + + b.Property("CategoryPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AppId"); + + b.HasIndex("TenantId"); + + b.HasIndex("Name", "AppId") + .IsUnique() + .HasFilter("\"AppId\" IS NOT NULL"); + + b.HasIndex("Name", "TenantId") + .IsUnique() + .HasFilter("\"AppId\" IS NULL"); + + b.ToTable("Group", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.GroupRoleRelationEntity", b => + { + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.HasKey("GroupId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("GroupRoleRelation", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.GroupSubjectRelationEntity", b => + { + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.HasKey("GroupId", "SubjectId"); + + b.HasIndex("SubjectId"); + + b.ToTable("GroupSubjectRelation", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleAuthorityRelationEntity", b => + { + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("AuthorityId") + .HasColumnType("bigint"); + + b.HasKey("RoleId", "AuthorityId"); + + b.HasIndex("AuthorityId"); + + b.ToTable("RoleAuthorityRelation", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleGlobalAuthorityRelationEntity", b => + { + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("GlobalAuthorityId") + .HasColumnType("bigint"); + + b.HasKey("RoleId", "GlobalAuthorityId"); + + b.HasIndex("GlobalAuthorityId"); + + b.ToTable("RoleGlobalAuthorityRelation", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleSubjectRelationEntity", b => + { + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.HasKey("RoleId", "SubjectId"); + + b.HasIndex("SubjectId"); + + b.ToTable("RoleSubjectRelation", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.RoleEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AppId") + .HasColumnType("bigint"); + + b.Property("CategoryPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AppId"); + + b.HasIndex("TenantId"); + + b.HasIndex("Name", "AppId") + .IsUnique() + .HasFilter("\"AppId\" IS NOT NULL"); + + b.HasIndex("Name", "TenantId") + .IsUnique() + .HasFilter("\"AppId\" IS NULL"); + + b.ToTable("Role", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.AuthorityVersionEntity", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("AppId") + .HasColumnType("bigint"); + + b.Property("CategoryPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("AuthorityVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.GroupRoleRelationVersionEntity", b => + { + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.HasKey("GroupId", "RoleId", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("GroupRoleRelationVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.GroupSubjectRelationVersionEntity", b => + { + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.HasKey("GroupId", "SubjectId", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("GroupSubjectRelationVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.GroupVersionEntity", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("AppId") + .HasColumnType("bigint"); + + b.Property("CategoryPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("GroupVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleAuthorityRelationVersionEntity", b => + { + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("AuthorityId") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.HasKey("RoleId", "AuthorityId", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("RoleAuthorityRelationVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleGlobalAuthorityRelationVersionEntity", b => + { + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("GlobalAuthorityId") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.HasKey("RoleId", "GlobalAuthorityId", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("RoleGlobalAuthorityRelationVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleSubjectRelationVersionEntity", b => + { + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.HasKey("RoleId", "SubjectId", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("RoleSubjectRelationVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleVersionEntity", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("AppId") + .HasColumnType("bigint"); + + b.Property("CategoryPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("RoleVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TokenMetadataEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Expiration") + .HasColumnType("timestamp with time zone"); + + b.Property("IsRevoked") + .HasColumnType("boolean"); + + b.Property("Scope") + .IsRequired() + .HasColumnType("text"); + + b.Property("TokenType") + .IsRequired() + .HasColumnType("text"); + + b.Property("UsedBy") + .HasColumnType("bigint"); + + b.Property("UsedFor") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("TokenMetadata", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn.SignInEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Email") + .HasColumnType("text"); + + b.Property("IsLegacy") + .HasColumnType("boolean"); + + b.Property("Method") + .IsRequired() + .HasColumnType("text"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("Email") + .IsUnique(); + + b.HasIndex("SubjectId"); + + b.ToTable("SignIn", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Subject", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("IsMaster") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("OwnerId") + .HasColumnType("bigint"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("OwnerId"); + + b.ToTable("Tenant", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", b => + { + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.HasKey("SubjectId", "TenantId"); + + b.HasIndex("TenantId"); + + b.ToTable("TenantSubjectRelation", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => + { + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.HasKey("SubjectId", "TenantId", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("TenantSubjectRelationVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantVersionEntity", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("IsMaster") + .HasColumnType("boolean"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("OwnerId") + .HasColumnType("bigint"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("TenantVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") + .WithMany("Apps") + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "App") + .WithMany() + .HasForeignKey("AppId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") + .WithMany() + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("App"); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", "Reference") + .WithMany() + .HasForeignKey("SubjectId", "AppId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "Reference") + .WithMany() + .HasForeignKey("Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.AuthorityEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "App") + .WithMany("Authorities") + .HasForeignKey("AppId"); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") + .WithMany("Authorities") + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("App"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.GroupEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "App") + .WithMany("Groups") + .HasForeignKey("AppId"); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") + .WithMany("Groups") + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("App"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.GroupRoleRelationEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.GroupEntity", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.RoleEntity", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.GroupSubjectRelationEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.GroupEntity", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") + .WithMany() + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleAuthorityRelationEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.AuthorityEntity", "Authority") + .WithMany() + .HasForeignKey("AuthorityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.RoleEntity", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Authority"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleGlobalAuthorityRelationEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.GlobalAuthorityEntity", "GlobalAuthority") + .WithMany() + .HasForeignKey("GlobalAuthorityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.RoleEntity", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("GlobalAuthority"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleSubjectRelationEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.RoleEntity", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") + .WithMany() + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.RoleEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "App") + .WithMany("Roles") + .HasForeignKey("AppId"); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") + .WithMany("Roles") + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("App"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.AuthorityVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.AuthorityEntity", "Reference") + .WithMany() + .HasForeignKey("Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.GroupRoleRelationVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.GroupRoleRelationEntity", "Reference") + .WithMany() + .HasForeignKey("GroupId", "RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.GroupSubjectRelationVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.GroupSubjectRelationEntity", "Reference") + .WithMany() + .HasForeignKey("GroupId", "SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.GroupVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.GroupEntity", "Reference") + .WithMany() + .HasForeignKey("Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleAuthorityRelationVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleAuthorityRelationEntity", "Reference") + .WithMany() + .HasForeignKey("RoleId", "AuthorityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleGlobalAuthorityRelationVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleGlobalAuthorityRelationEntity", "Reference") + .WithMany() + .HasForeignKey("RoleId", "GlobalAuthorityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleSubjectRelationVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleSubjectRelationEntity", "Reference") + .WithMany() + .HasForeignKey("RoleId", "SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.RoleEntity", "Reference") + .WithMany() + .HasForeignKey("Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SignIn.SignInEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") + .WithMany("SignInMethods") + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") + .WithMany() + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Subject"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", "Reference") + .WithMany() + .HasForeignKey("SubjectId", "TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Reference") + .WithMany() + .HasForeignKey("Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", b => + { + b.Navigation("Authorities"); + + b.Navigation("Groups"); + + b.Navigation("Roles"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => + { + b.Navigation("SignInMethods"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => + { + b.Navigation("Apps"); + + b.Navigation("Authorities"); + + b.Navigation("Groups"); + + b.Navigation("Roles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250607014754_Init.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250607014754_Init.cs new file mode 100644 index 0000000..0373d6a --- /dev/null +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/20250607014754_Init.cs @@ -0,0 +1,1192 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Suspectus.Gandalf.Palantir.Data.Migrations +{ + /// + public partial class Init : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.EnsureSchema( + name: "gr"); + + migrationBuilder.CreateTable( + name: "AuthCode", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + SubjectId = table.Column(type: "bigint", nullable: false), + Expiration = table.Column(type: "timestamp with time zone", nullable: false), + IsRevoked = table.Column(type: "boolean", nullable: false), + Code = table.Column(type: "text", nullable: false), + Challenge = table.Column(type: "text", nullable: false), + Algorithm = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AuthCode", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "GlobalAuthority", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + CategoryPath = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: true), + Type = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GlobalAuthority", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Subject", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + Visibility = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Subject", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "TokenMetadata", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Expiration = table.Column(type: "timestamp with time zone", nullable: false), + IsRevoked = table.Column(type: "boolean", nullable: false), + TokenType = table.Column(type: "text", nullable: false), + UsedBy = table.Column(type: "bigint", nullable: false), + UsedFor = table.Column(type: "bigint", nullable: false), + Scope = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TokenMetadata", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "SignIn", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Method = table.Column(type: "text", nullable: false), + IsLegacy = table.Column(type: "boolean", nullable: false), + Email = table.Column(type: "text", nullable: true), + PasswordHash = table.Column(type: "text", nullable: true), + Visibility = table.Column(type: "text", nullable: false), + SubjectId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_SignIn", x => x.Id); + table.ForeignKey( + name: "FK_SignIn_Subject_SubjectId", + column: x => x.SubjectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Tenant", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Visibility = table.Column(type: "text", nullable: false), + OwnerId = table.Column(type: "bigint", nullable: false), + Name = table.Column(type: "text", nullable: false), + IsMaster = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Tenant", x => x.Id); + table.ForeignKey( + name: "FK_Tenant_Subject_OwnerId", + column: x => x.OwnerId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "App", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Visibility = table.Column(type: "text", nullable: false), + TenantId = table.Column(type: "bigint", nullable: false), + Name = table.Column(type: "text", nullable: false), + BaseAddress = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_App", x => x.Id); + table.ForeignKey( + name: "FK_App_Tenant_TenantId", + column: x => x.TenantId, + principalSchema: "gr", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "TenantSubjectRelation", + schema: "gr", + columns: table => new + { + TenantId = table.Column(type: "bigint", nullable: false), + SubjectId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TenantSubjectRelation", x => new { x.SubjectId, x.TenantId }); + table.ForeignKey( + name: "FK_TenantSubjectRelation_Subject_SubjectId", + column: x => x.SubjectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_TenantSubjectRelation_Tenant_TenantId", + column: x => x.TenantId, + principalSchema: "gr", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "TenantVersion", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false), + At = table.Column(type: "timestamp with time zone", nullable: false), + SuspectId = table.Column(type: "bigint", nullable: false), + Action = table.Column(type: "text", nullable: false), + Visibility = table.Column(type: "text", nullable: false), + OwnerId = table.Column(type: "bigint", nullable: false), + Name = table.Column(type: "text", nullable: false), + IsMaster = table.Column(type: "boolean", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TenantVersion", x => new { x.Id, x.At }); + table.ForeignKey( + name: "FK_TenantVersion_Subject_SuspectId", + column: x => x.SuspectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_TenantVersion_Tenant_Id", + column: x => x.Id, + principalSchema: "gr", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AppSubjectRelation", + schema: "gr", + columns: table => new + { + AppId = table.Column(type: "bigint", nullable: false), + SubjectId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AppSubjectRelation", x => new { x.SubjectId, x.AppId }); + table.ForeignKey( + name: "FK_AppSubjectRelation_App_AppId", + column: x => x.AppId, + principalSchema: "gr", + principalTable: "App", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AppSubjectRelation_Subject_SubjectId", + column: x => x.SubjectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AppVersion", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false), + At = table.Column(type: "timestamp with time zone", nullable: false), + SuspectId = table.Column(type: "bigint", nullable: false), + Action = table.Column(type: "text", nullable: false), + Visibility = table.Column(type: "text", nullable: false), + TenantId = table.Column(type: "bigint", nullable: false), + Name = table.Column(type: "text", nullable: false), + BaseAddress = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AppVersion", x => new { x.Id, x.At }); + table.ForeignKey( + name: "FK_AppVersion_App_Id", + column: x => x.Id, + principalSchema: "gr", + principalTable: "App", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AppVersion_Subject_SuspectId", + column: x => x.SuspectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Authority", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + CategoryPath = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: true), + Visibility = table.Column(type: "text", nullable: false), + TenantId = table.Column(type: "bigint", nullable: false), + AppId = table.Column(type: "bigint", nullable: true), + Type = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Authority", x => x.Id); + table.ForeignKey( + name: "FK_Authority_App_AppId", + column: x => x.AppId, + principalSchema: "gr", + principalTable: "App", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Authority_Tenant_TenantId", + column: x => x.TenantId, + principalSchema: "gr", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Group", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + CategoryPath = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: true), + Visibility = table.Column(type: "text", nullable: false), + TenantId = table.Column(type: "bigint", nullable: false), + AppId = table.Column(type: "bigint", nullable: true), + Type = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Group", x => x.Id); + table.ForeignKey( + name: "FK_Group_App_AppId", + column: x => x.AppId, + principalSchema: "gr", + principalTable: "App", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Group_Tenant_TenantId", + column: x => x.TenantId, + principalSchema: "gr", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Role", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "text", nullable: false), + CategoryPath = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: true), + Visibility = table.Column(type: "text", nullable: false), + TenantId = table.Column(type: "bigint", nullable: false), + AppId = table.Column(type: "bigint", nullable: true), + Type = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Role", x => x.Id); + table.ForeignKey( + name: "FK_Role_App_AppId", + column: x => x.AppId, + principalSchema: "gr", + principalTable: "App", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Role_Tenant_TenantId", + column: x => x.TenantId, + principalSchema: "gr", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "TenantSubjectRelationVersion", + schema: "gr", + columns: table => new + { + TenantId = table.Column(type: "bigint", nullable: false), + SubjectId = table.Column(type: "bigint", nullable: false), + At = table.Column(type: "timestamp with time zone", nullable: false), + SuspectId = table.Column(type: "bigint", nullable: false), + Action = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TenantSubjectRelationVersion", x => new { x.SubjectId, x.TenantId, x.At }); + table.ForeignKey( + name: "FK_TenantSubjectRelationVersion_Subject_SuspectId", + column: x => x.SuspectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_TenantSubjectRelationVersion_TenantSubjectRelation_SubjectI~", + columns: x => new { x.SubjectId, x.TenantId }, + principalSchema: "gr", + principalTable: "TenantSubjectRelation", + principalColumns: new[] { "SubjectId", "TenantId" }, + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AppSubjectRelationVersion", + schema: "gr", + columns: table => new + { + AppId = table.Column(type: "bigint", nullable: false), + SubjectId = table.Column(type: "bigint", nullable: false), + At = table.Column(type: "timestamp with time zone", nullable: false), + SuspectId = table.Column(type: "bigint", nullable: false), + Action = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AppSubjectRelationVersion", x => new { x.SubjectId, x.AppId, x.At }); + table.ForeignKey( + name: "FK_AppSubjectRelationVersion_AppSubjectRelation_SubjectId_AppId", + columns: x => new { x.SubjectId, x.AppId }, + principalSchema: "gr", + principalTable: "AppSubjectRelation", + principalColumns: new[] { "SubjectId", "AppId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AppSubjectRelationVersion_Subject_SuspectId", + column: x => x.SuspectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AuthorityVersion", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false), + At = table.Column(type: "timestamp with time zone", nullable: false), + SuspectId = table.Column(type: "bigint", nullable: false), + Action = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + CategoryPath = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: true), + Visibility = table.Column(type: "text", nullable: false), + TenantId = table.Column(type: "bigint", nullable: false), + AppId = table.Column(type: "bigint", nullable: true), + Type = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AuthorityVersion", x => new { x.Id, x.At }); + table.ForeignKey( + name: "FK_AuthorityVersion_Authority_Id", + column: x => x.Id, + principalSchema: "gr", + principalTable: "Authority", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AuthorityVersion_Subject_SuspectId", + column: x => x.SuspectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "GroupSubjectRelation", + schema: "gr", + columns: table => new + { + GroupId = table.Column(type: "bigint", nullable: false), + SubjectId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GroupSubjectRelation", x => new { x.GroupId, x.SubjectId }); + table.ForeignKey( + name: "FK_GroupSubjectRelation_Group_GroupId", + column: x => x.GroupId, + principalSchema: "gr", + principalTable: "Group", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_GroupSubjectRelation_Subject_SubjectId", + column: x => x.SubjectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "GroupVersion", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false), + At = table.Column(type: "timestamp with time zone", nullable: false), + SuspectId = table.Column(type: "bigint", nullable: false), + Action = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + CategoryPath = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: true), + Visibility = table.Column(type: "text", nullable: false), + TenantId = table.Column(type: "bigint", nullable: false), + AppId = table.Column(type: "bigint", nullable: true), + Type = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GroupVersion", x => new { x.Id, x.At }); + table.ForeignKey( + name: "FK_GroupVersion_Group_Id", + column: x => x.Id, + principalSchema: "gr", + principalTable: "Group", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_GroupVersion_Subject_SuspectId", + column: x => x.SuspectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "GroupRoleRelation", + schema: "gr", + columns: table => new + { + GroupId = table.Column(type: "bigint", nullable: false), + RoleId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GroupRoleRelation", x => new { x.GroupId, x.RoleId }); + table.ForeignKey( + name: "FK_GroupRoleRelation_Group_GroupId", + column: x => x.GroupId, + principalSchema: "gr", + principalTable: "Group", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_GroupRoleRelation_Role_RoleId", + column: x => x.RoleId, + principalSchema: "gr", + principalTable: "Role", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RoleAuthorityRelation", + schema: "gr", + columns: table => new + { + RoleId = table.Column(type: "bigint", nullable: false), + AuthorityId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RoleAuthorityRelation", x => new { x.RoleId, x.AuthorityId }); + table.ForeignKey( + name: "FK_RoleAuthorityRelation_Authority_AuthorityId", + column: x => x.AuthorityId, + principalSchema: "gr", + principalTable: "Authority", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RoleAuthorityRelation_Role_RoleId", + column: x => x.RoleId, + principalSchema: "gr", + principalTable: "Role", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RoleGlobalAuthorityRelation", + schema: "gr", + columns: table => new + { + RoleId = table.Column(type: "bigint", nullable: false), + GlobalAuthorityId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RoleGlobalAuthorityRelation", x => new { x.RoleId, x.GlobalAuthorityId }); + table.ForeignKey( + name: "FK_RoleGlobalAuthorityRelation_GlobalAuthority_GlobalAuthority~", + column: x => x.GlobalAuthorityId, + principalSchema: "gr", + principalTable: "GlobalAuthority", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RoleGlobalAuthorityRelation_Role_RoleId", + column: x => x.RoleId, + principalSchema: "gr", + principalTable: "Role", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RoleSubjectRelation", + schema: "gr", + columns: table => new + { + RoleId = table.Column(type: "bigint", nullable: false), + SubjectId = table.Column(type: "bigint", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RoleSubjectRelation", x => new { x.RoleId, x.SubjectId }); + table.ForeignKey( + name: "FK_RoleSubjectRelation_Role_RoleId", + column: x => x.RoleId, + principalSchema: "gr", + principalTable: "Role", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RoleSubjectRelation_Subject_SubjectId", + column: x => x.SubjectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RoleVersion", + schema: "gr", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false), + At = table.Column(type: "timestamp with time zone", nullable: false), + SuspectId = table.Column(type: "bigint", nullable: false), + Action = table.Column(type: "text", nullable: false), + Name = table.Column(type: "text", nullable: false), + CategoryPath = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: true), + Visibility = table.Column(type: "text", nullable: false), + TenantId = table.Column(type: "bigint", nullable: false), + AppId = table.Column(type: "bigint", nullable: true), + Type = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RoleVersion", x => new { x.Id, x.At }); + table.ForeignKey( + name: "FK_RoleVersion_Role_Id", + column: x => x.Id, + principalSchema: "gr", + principalTable: "Role", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RoleVersion_Subject_SuspectId", + column: x => x.SuspectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "GroupSubjectRelationVersion", + schema: "gr", + columns: table => new + { + GroupId = table.Column(type: "bigint", nullable: false), + SubjectId = table.Column(type: "bigint", nullable: false), + At = table.Column(type: "timestamp with time zone", nullable: false), + SuspectId = table.Column(type: "bigint", nullable: false), + Action = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GroupSubjectRelationVersion", x => new { x.GroupId, x.SubjectId, x.At }); + table.ForeignKey( + name: "FK_GroupSubjectRelationVersion_GroupSubjectRelation_GroupId_Su~", + columns: x => new { x.GroupId, x.SubjectId }, + principalSchema: "gr", + principalTable: "GroupSubjectRelation", + principalColumns: new[] { "GroupId", "SubjectId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_GroupSubjectRelationVersion_Subject_SuspectId", + column: x => x.SuspectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "GroupRoleRelationVersion", + schema: "gr", + columns: table => new + { + GroupId = table.Column(type: "bigint", nullable: false), + RoleId = table.Column(type: "bigint", nullable: false), + At = table.Column(type: "timestamp with time zone", nullable: false), + SuspectId = table.Column(type: "bigint", nullable: false), + Action = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GroupRoleRelationVersion", x => new { x.GroupId, x.RoleId, x.At }); + table.ForeignKey( + name: "FK_GroupRoleRelationVersion_GroupRoleRelation_GroupId_RoleId", + columns: x => new { x.GroupId, x.RoleId }, + principalSchema: "gr", + principalTable: "GroupRoleRelation", + principalColumns: new[] { "GroupId", "RoleId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_GroupRoleRelationVersion_Subject_SuspectId", + column: x => x.SuspectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RoleAuthorityRelationVersion", + schema: "gr", + columns: table => new + { + RoleId = table.Column(type: "bigint", nullable: false), + AuthorityId = table.Column(type: "bigint", nullable: false), + At = table.Column(type: "timestamp with time zone", nullable: false), + SuspectId = table.Column(type: "bigint", nullable: false), + Action = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RoleAuthorityRelationVersion", x => new { x.RoleId, x.AuthorityId, x.At }); + table.ForeignKey( + name: "FK_RoleAuthorityRelationVersion_RoleAuthorityRelation_RoleId_A~", + columns: x => new { x.RoleId, x.AuthorityId }, + principalSchema: "gr", + principalTable: "RoleAuthorityRelation", + principalColumns: new[] { "RoleId", "AuthorityId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RoleAuthorityRelationVersion_Subject_SuspectId", + column: x => x.SuspectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RoleGlobalAuthorityRelationVersion", + schema: "gr", + columns: table => new + { + RoleId = table.Column(type: "bigint", nullable: false), + GlobalAuthorityId = table.Column(type: "bigint", nullable: false), + At = table.Column(type: "timestamp with time zone", nullable: false), + SuspectId = table.Column(type: "bigint", nullable: false), + Action = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RoleGlobalAuthorityRelationVersion", x => new { x.RoleId, x.GlobalAuthorityId, x.At }); + table.ForeignKey( + name: "FK_RoleGlobalAuthorityRelationVersion_RoleGlobalAuthorityRelat~", + columns: x => new { x.RoleId, x.GlobalAuthorityId }, + principalSchema: "gr", + principalTable: "RoleGlobalAuthorityRelation", + principalColumns: new[] { "RoleId", "GlobalAuthorityId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RoleGlobalAuthorityRelationVersion_Subject_SuspectId", + column: x => x.SuspectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RoleSubjectRelationVersion", + schema: "gr", + columns: table => new + { + RoleId = table.Column(type: "bigint", nullable: false), + SubjectId = table.Column(type: "bigint", nullable: false), + At = table.Column(type: "timestamp with time zone", nullable: false), + SuspectId = table.Column(type: "bigint", nullable: false), + Action = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RoleSubjectRelationVersion", x => new { x.RoleId, x.SubjectId, x.At }); + table.ForeignKey( + name: "FK_RoleSubjectRelationVersion_RoleSubjectRelation_RoleId_Subje~", + columns: x => new { x.RoleId, x.SubjectId }, + principalSchema: "gr", + principalTable: "RoleSubjectRelation", + principalColumns: new[] { "RoleId", "SubjectId" }, + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RoleSubjectRelationVersion_Subject_SuspectId", + column: x => x.SuspectId, + principalSchema: "gr", + principalTable: "Subject", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_App_TenantId", + schema: "gr", + table: "App", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_AppSubjectRelation_AppId", + schema: "gr", + table: "AppSubjectRelation", + column: "AppId"); + + migrationBuilder.CreateIndex( + name: "IX_AppSubjectRelationVersion_SuspectId", + schema: "gr", + table: "AppSubjectRelationVersion", + column: "SuspectId"); + + migrationBuilder.CreateIndex( + name: "IX_AppVersion_SuspectId", + schema: "gr", + table: "AppVersion", + column: "SuspectId"); + + migrationBuilder.CreateIndex( + name: "IX_Authority_AppId", + schema: "gr", + table: "Authority", + column: "AppId"); + + migrationBuilder.CreateIndex( + name: "IX_Authority_Name_AppId", + schema: "gr", + table: "Authority", + columns: new[] { "Name", "AppId" }, + unique: true, + filter: "\"AppId\" IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_Authority_Name_TenantId", + schema: "gr", + table: "Authority", + columns: new[] { "Name", "TenantId" }, + unique: true, + filter: "\"AppId\" IS NULL"); + + migrationBuilder.CreateIndex( + name: "IX_Authority_TenantId", + schema: "gr", + table: "Authority", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_AuthorityVersion_SuspectId", + schema: "gr", + table: "AuthorityVersion", + column: "SuspectId"); + + migrationBuilder.CreateIndex( + name: "IX_GlobalAuthority_Name", + schema: "gr", + table: "GlobalAuthority", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Group_AppId", + schema: "gr", + table: "Group", + column: "AppId"); + + migrationBuilder.CreateIndex( + name: "IX_Group_Name_AppId", + schema: "gr", + table: "Group", + columns: new[] { "Name", "AppId" }, + unique: true, + filter: "\"AppId\" IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_Group_Name_TenantId", + schema: "gr", + table: "Group", + columns: new[] { "Name", "TenantId" }, + unique: true, + filter: "\"AppId\" IS NULL"); + + migrationBuilder.CreateIndex( + name: "IX_Group_TenantId", + schema: "gr", + table: "Group", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_GroupRoleRelation_RoleId", + schema: "gr", + table: "GroupRoleRelation", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_GroupRoleRelationVersion_SuspectId", + schema: "gr", + table: "GroupRoleRelationVersion", + column: "SuspectId"); + + migrationBuilder.CreateIndex( + name: "IX_GroupSubjectRelation_SubjectId", + schema: "gr", + table: "GroupSubjectRelation", + column: "SubjectId"); + + migrationBuilder.CreateIndex( + name: "IX_GroupSubjectRelationVersion_SuspectId", + schema: "gr", + table: "GroupSubjectRelationVersion", + column: "SuspectId"); + + migrationBuilder.CreateIndex( + name: "IX_GroupVersion_SuspectId", + schema: "gr", + table: "GroupVersion", + column: "SuspectId"); + + migrationBuilder.CreateIndex( + name: "IX_Role_AppId", + schema: "gr", + table: "Role", + column: "AppId"); + + migrationBuilder.CreateIndex( + name: "IX_Role_Name_AppId", + schema: "gr", + table: "Role", + columns: new[] { "Name", "AppId" }, + unique: true, + filter: "\"AppId\" IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_Role_Name_TenantId", + schema: "gr", + table: "Role", + columns: new[] { "Name", "TenantId" }, + unique: true, + filter: "\"AppId\" IS NULL"); + + migrationBuilder.CreateIndex( + name: "IX_Role_TenantId", + schema: "gr", + table: "Role", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_RoleAuthorityRelation_AuthorityId", + schema: "gr", + table: "RoleAuthorityRelation", + column: "AuthorityId"); + + migrationBuilder.CreateIndex( + name: "IX_RoleAuthorityRelationVersion_SuspectId", + schema: "gr", + table: "RoleAuthorityRelationVersion", + column: "SuspectId"); + + migrationBuilder.CreateIndex( + name: "IX_RoleGlobalAuthorityRelation_GlobalAuthorityId", + schema: "gr", + table: "RoleGlobalAuthorityRelation", + column: "GlobalAuthorityId"); + + migrationBuilder.CreateIndex( + name: "IX_RoleGlobalAuthorityRelationVersion_SuspectId", + schema: "gr", + table: "RoleGlobalAuthorityRelationVersion", + column: "SuspectId"); + + migrationBuilder.CreateIndex( + name: "IX_RoleSubjectRelation_SubjectId", + schema: "gr", + table: "RoleSubjectRelation", + column: "SubjectId"); + + migrationBuilder.CreateIndex( + name: "IX_RoleSubjectRelationVersion_SuspectId", + schema: "gr", + table: "RoleSubjectRelationVersion", + column: "SuspectId"); + + migrationBuilder.CreateIndex( + name: "IX_RoleVersion_SuspectId", + schema: "gr", + table: "RoleVersion", + column: "SuspectId"); + + migrationBuilder.CreateIndex( + name: "IX_SignIn_Email", + schema: "gr", + table: "SignIn", + column: "Email", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_SignIn_SubjectId", + schema: "gr", + table: "SignIn", + column: "SubjectId"); + + migrationBuilder.CreateIndex( + name: "IX_Subject_Name", + schema: "gr", + table: "Subject", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Tenant_OwnerId", + schema: "gr", + table: "Tenant", + column: "OwnerId"); + + migrationBuilder.CreateIndex( + name: "IX_TenantSubjectRelation_TenantId", + schema: "gr", + table: "TenantSubjectRelation", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_TenantSubjectRelationVersion_SuspectId", + schema: "gr", + table: "TenantSubjectRelationVersion", + column: "SuspectId"); + + migrationBuilder.CreateIndex( + name: "IX_TenantVersion_SuspectId", + schema: "gr", + table: "TenantVersion", + column: "SuspectId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AppSubjectRelationVersion", + schema: "gr"); + + migrationBuilder.DropTable( + name: "AppVersion", + schema: "gr"); + + migrationBuilder.DropTable( + name: "AuthCode", + schema: "gr"); + + migrationBuilder.DropTable( + name: "AuthorityVersion", + schema: "gr"); + + migrationBuilder.DropTable( + name: "GroupRoleRelationVersion", + schema: "gr"); + + migrationBuilder.DropTable( + name: "GroupSubjectRelationVersion", + schema: "gr"); + + migrationBuilder.DropTable( + name: "GroupVersion", + schema: "gr"); + + migrationBuilder.DropTable( + name: "RoleAuthorityRelationVersion", + schema: "gr"); + + migrationBuilder.DropTable( + name: "RoleGlobalAuthorityRelationVersion", + schema: "gr"); + + migrationBuilder.DropTable( + name: "RoleSubjectRelationVersion", + schema: "gr"); + + migrationBuilder.DropTable( + name: "RoleVersion", + schema: "gr"); + + migrationBuilder.DropTable( + name: "SignIn", + schema: "gr"); + + migrationBuilder.DropTable( + name: "TenantSubjectRelationVersion", + schema: "gr"); + + migrationBuilder.DropTable( + name: "TenantVersion", + schema: "gr"); + + migrationBuilder.DropTable( + name: "TokenMetadata", + schema: "gr"); + + migrationBuilder.DropTable( + name: "AppSubjectRelation", + schema: "gr"); + + migrationBuilder.DropTable( + name: "GroupRoleRelation", + schema: "gr"); + + migrationBuilder.DropTable( + name: "GroupSubjectRelation", + schema: "gr"); + + migrationBuilder.DropTable( + name: "RoleAuthorityRelation", + schema: "gr"); + + migrationBuilder.DropTable( + name: "RoleGlobalAuthorityRelation", + schema: "gr"); + + migrationBuilder.DropTable( + name: "RoleSubjectRelation", + schema: "gr"); + + migrationBuilder.DropTable( + name: "TenantSubjectRelation", + schema: "gr"); + + migrationBuilder.DropTable( + name: "Group", + schema: "gr"); + + migrationBuilder.DropTable( + name: "Authority", + schema: "gr"); + + migrationBuilder.DropTable( + name: "GlobalAuthority", + schema: "gr"); + + migrationBuilder.DropTable( + name: "Role", + schema: "gr"); + + migrationBuilder.DropTable( + name: "App", + schema: "gr"); + + migrationBuilder.DropTable( + name: "Tenant", + schema: "gr"); + + migrationBuilder.DropTable( + name: "Subject", + schema: "gr"); + } + } +} diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/ApplicationContextModelSnapshot.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/ApplicationContextModelSnapshot.cs index f9d7bd1..17dfc04 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/ApplicationContextModelSnapshot.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Migrations/ApplicationContextModelSnapshot.cs @@ -8,7 +8,7 @@ using Suspectus.Gandalf.Palantir.Data.Database; #nullable disable -namespace W542.GandalfReborn.Data.Migrations +namespace Suspectus.Gandalf.Palantir.Data.Migrations { [DbContext(typeof(ApplicationContext))] partial class ApplicationContextModelSnapshot : ModelSnapshot @@ -129,52 +129,6 @@ namespace W542.GandalfReborn.Data.Migrations b.ToTable("AppVersion", "gr"); }); - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId"); - - b.HasIndex("InternalAuthorityId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelation", "gr"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => - { - b.Property("SubjectId") - .HasColumnType("bigint"); - - b.Property("AppId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); - - b.Property("At") - .HasColumnType("timestamp with time zone"); - - b.Property("Action") - .IsRequired() - .HasColumnType("text"); - - b.Property("SuspectId") - .HasColumnType("bigint"); - - b.HasKey("SubjectId", "AppId", "InternalAuthorityId", "At"); - - b.HasIndex("SuspectId"); - - b.ToTable("AppSubjectRelationInternalAuthorityRelationVersion", "gr"); - }); - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthCodeEntity", b => { b.Property("Id") @@ -209,7 +163,7 @@ namespace W542.GandalfReborn.Data.Migrations b.ToTable("AuthCode", "gr"); }); - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", b => + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.AuthorityEntity", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -217,6 +171,60 @@ namespace W542.GandalfReborn.Data.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("AppId") + .HasColumnType("bigint"); + + b.Property("CategoryPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AppId"); + + b.HasIndex("TenantId"); + + b.HasIndex("Name", "AppId") + .IsUnique() + .HasFilter("\"AppId\" IS NOT NULL"); + + b.HasIndex("Name", "TenantId") + .IsUnique() + .HasFilter("\"AppId\" IS NULL"); + + b.ToTable("Authority", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.GlobalAuthorityEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CategoryPath") + .IsRequired() + .HasColumnType("text"); + b.Property("Description") .HasColumnType("text"); @@ -233,52 +241,237 @@ namespace W542.GandalfReborn.Data.Migrations b.HasIndex("Name") .IsUnique(); - b.ToTable("Authority", "gr"); - - b.HasData( - new - { - Id = 1L, - Description = "Allows users to read tenants", - Name = "Tenant_Read", - Type = "Tenant" - }, - new - { - Id = 2L, - Description = "Allows users to read apps", - Name = "App_Read", - Type = "App" - }); + b.ToTable("GlobalAuthority", "gr"); }); - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.GroupEntity", b => { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AppId") + .HasColumnType("bigint"); + + b.Property("CategoryPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AppId"); + + b.HasIndex("TenantId"); + + b.HasIndex("Name", "AppId") + .IsUnique() + .HasFilter("\"AppId\" IS NOT NULL"); + + b.HasIndex("Name", "TenantId") + .IsUnique() + .HasFilter("\"AppId\" IS NULL"); + + b.ToTable("Group", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.GroupRoleRelationEntity", b => + { + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("RoleId") + .HasColumnType("bigint"); + + b.HasKey("GroupId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("GroupRoleRelation", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.GroupSubjectRelationEntity", b => + { + b.Property("GroupId") + .HasColumnType("bigint"); + b.Property("SubjectId") .HasColumnType("bigint"); + b.HasKey("GroupId", "SubjectId"); + + b.HasIndex("SubjectId"); + + b.ToTable("GroupSubjectRelation", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleAuthorityRelationEntity", b => + { + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("AuthorityId") + .HasColumnType("bigint"); + + b.HasKey("RoleId", "AuthorityId"); + + b.HasIndex("AuthorityId"); + + b.ToTable("RoleAuthorityRelation", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleGlobalAuthorityRelationEntity", b => + { + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("GlobalAuthorityId") + .HasColumnType("bigint"); + + b.HasKey("RoleId", "GlobalAuthorityId"); + + b.HasIndex("GlobalAuthorityId"); + + b.ToTable("RoleGlobalAuthorityRelation", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleSubjectRelationEntity", b => + { + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.HasKey("RoleId", "SubjectId"); + + b.HasIndex("SubjectId"); + + b.ToTable("RoleSubjectRelation", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.RoleEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AppId") + .HasColumnType("bigint"); + + b.Property("CategoryPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("AppId"); + + b.HasIndex("TenantId"); + + b.HasIndex("Name", "AppId") + .IsUnique() + .HasFilter("\"AppId\" IS NOT NULL"); + + b.HasIndex("Name", "TenantId") + .IsUnique() + .HasFilter("\"AppId\" IS NULL"); + + b.ToTable("Role", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.AuthorityVersionEntity", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("AppId") + .HasColumnType("bigint"); + + b.Property("CategoryPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + b.Property("TenantId") .HasColumnType("bigint"); - b.Property("InternalAuthorityId") - .HasColumnType("bigint"); + b.Property("Type") + .IsRequired() + .HasColumnType("text"); - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId"); + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); - b.HasIndex("InternalAuthorityId"); + b.HasKey("Id", "At"); - b.ToTable("TenantSubjectRelationInternalAuthorityRelation", "gr"); + b.HasIndex("SuspectId"); + + b.ToTable("AuthorityVersion", "gr"); }); - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.GroupRoleRelationVersionEntity", b => { - b.Property("SubjectId") + b.Property("GroupId") .HasColumnType("bigint"); - b.Property("TenantId") - .HasColumnType("bigint"); - - b.Property("InternalAuthorityId") + b.Property("RoleId") .HasColumnType("bigint"); b.Property("At") @@ -291,11 +484,205 @@ namespace W542.GandalfReborn.Data.Migrations b.Property("SuspectId") .HasColumnType("bigint"); - b.HasKey("SubjectId", "TenantId", "InternalAuthorityId", "At"); + b.HasKey("GroupId", "RoleId", "At"); b.HasIndex("SuspectId"); - b.ToTable("TenantSubjectRelationInternalAuthorityRelationVersion", "gr"); + b.ToTable("GroupRoleRelationVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.GroupSubjectRelationVersionEntity", b => + { + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.HasKey("GroupId", "SubjectId", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("GroupSubjectRelationVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.GroupVersionEntity", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("AppId") + .HasColumnType("bigint"); + + b.Property("CategoryPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("GroupVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleAuthorityRelationVersionEntity", b => + { + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("AuthorityId") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.HasKey("RoleId", "AuthorityId", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("RoleAuthorityRelationVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleGlobalAuthorityRelationVersionEntity", b => + { + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("GlobalAuthorityId") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.HasKey("RoleId", "GlobalAuthorityId", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("RoleGlobalAuthorityRelationVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleSubjectRelationVersionEntity", b => + { + b.Property("RoleId") + .HasColumnType("bigint"); + + b.Property("SubjectId") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.HasKey("RoleId", "SubjectId", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("RoleSubjectRelationVersion", "gr"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleVersionEntity", b => + { + b.Property("Id") + .HasColumnType("bigint"); + + b.Property("At") + .HasColumnType("timestamp with time zone"); + + b.Property("Action") + .IsRequired() + .HasColumnType("text"); + + b.Property("AppId") + .HasColumnType("bigint"); + + b.Property("CategoryPath") + .IsRequired() + .HasColumnType("text"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SuspectId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("bigint"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Visibility") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id", "At"); + + b.HasIndex("SuspectId"); + + b.ToTable("RoleVersion", "gr"); }); modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TokenMetadataEntity", b => @@ -566,64 +953,172 @@ namespace W542.GandalfReborn.Data.Migrations b.Navigation("Suspect"); }); - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", b => + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.AuthorityEntity", b => { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "App") + .WithMany("Authorities") + .HasForeignKey("AppId"); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") + .WithMany("Authorities") + .HasForeignKey("TenantId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppSubjectRelationEntity", "AppSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "AppId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + b.Navigation("App"); - b.Navigation("AppSubjectRelation"); - - b.Navigation("InternalAuthority"); + b.Navigation("Tenant"); }); - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationVersionEntity", b => + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.GroupEntity", b => { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "App") + .WithMany("Groups") + .HasForeignKey("AppId"); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") + .WithMany("Groups") + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("App"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.GroupRoleRelationEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.GroupEntity", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.RoleEntity", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.GroupSubjectRelationEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.GroupEntity", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") + .WithMany() + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleAuthorityRelationEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.AuthorityEntity", "Authority") + .WithMany() + .HasForeignKey("AuthorityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.RoleEntity", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Authority"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleGlobalAuthorityRelationEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.GlobalAuthorityEntity", "GlobalAuthority") + .WithMany() + .HasForeignKey("GlobalAuthorityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.RoleEntity", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("GlobalAuthority"); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleSubjectRelationEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.RoleEntity", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Subject") + .WithMany() + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.RoleEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", "App") + .WithMany("Roles") + .HasForeignKey("AppId"); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", "Tenant") + .WithMany("Roles") + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("App"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.AuthorityVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.AuthorityEntity", "Reference") + .WithMany() + .HasForeignKey("Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") .WithMany() .HasForeignKey("SuspectId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AppSubjectRelationInternalAuthorityRelationEntity", "Reference") - .WithMany() - .HasForeignKey("SubjectId", "AppId", "InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - b.Navigation("Reference"); b.Navigation("Suspect"); }); - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", b => - { - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.AuthorityEntity", "InternalAuthority") - .WithMany() - .HasForeignKey("InternalAuthorityId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantSubjectRelationEntity", "TenantSubjectRelation") - .WithMany() - .HasForeignKey("SubjectId", "TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("InternalAuthority"); - - b.Navigation("TenantSubjectRelation"); - }); - - modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationVersionEntity", b => + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.GroupRoleRelationVersionEntity", b => { b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") .WithMany() @@ -631,9 +1126,123 @@ namespace W542.GandalfReborn.Data.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.TenantSubjectRelationInternalAuthorityRelationEntity", "Reference") + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.GroupRoleRelationEntity", "Reference") .WithMany() - .HasForeignKey("SubjectId", "TenantId", "InternalAuthorityId") + .HasForeignKey("GroupId", "RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.GroupSubjectRelationVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.GroupSubjectRelationEntity", "Reference") + .WithMany() + .HasForeignKey("GroupId", "SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.GroupVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.GroupEntity", "Reference") + .WithMany() + .HasForeignKey("Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleAuthorityRelationVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleAuthorityRelationEntity", "Reference") + .WithMany() + .HasForeignKey("RoleId", "AuthorityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleGlobalAuthorityRelationVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleGlobalAuthorityRelationEntity", "Reference") + .WithMany() + .HasForeignKey("RoleId", "GlobalAuthorityId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleSubjectRelationVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Relation.RoleSubjectRelationEntity", "Reference") + .WithMany() + .HasForeignKey("RoleId", "SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Reference"); + + b.Navigation("Suspect"); + }); + + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Version.RoleVersionEntity", b => + { + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.RoleEntity", "Reference") + .WithMany() + .HasForeignKey("Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", "Suspect") + .WithMany() + .HasForeignKey("SuspectId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -721,6 +1330,15 @@ namespace W542.GandalfReborn.Data.Migrations b.Navigation("Suspect"); }); + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.App.AppEntity", b => + { + b.Navigation("Authorities"); + + b.Navigation("Groups"); + + b.Navigation("Roles"); + }); + modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Subject.SubjectEntity", b => { b.Navigation("SignInMethods"); @@ -729,6 +1347,12 @@ namespace W542.GandalfReborn.Data.Migrations modelBuilder.Entity("Suspectus.Gandalf.Palantir.Data.Entities.Tenant.TenantEntity", b => { b.Navigation("Apps"); + + b.Navigation("Authorities"); + + b.Navigation("Groups"); + + b.Navigation("Roles"); }); #pragma warning restore 612, 618 } diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Suspectus.Gandalf.Palantir.Data.csproj b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Suspectus.Gandalf.Palantir.Data.csproj index f5f4a69..7b51e05 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Data/Suspectus.Gandalf.Palantir.Data.csproj +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Data/Suspectus.Gandalf.Palantir.Data.csproj @@ -24,4 +24,8 @@ + + + + diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Security/GrAuthorizeAttribute.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Security/GrAuthorizeAttribute.cs index a4ab783..e897d28 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Security/GrAuthorizeAttribute.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Security/GrAuthorizeAttribute.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Suspectus.Gandalf.Palantir.Abstractions; using Suspectus.Gandalf.Palantir.Data.Entities.Security; +using Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data; namespace Suspectus.Gandalf.Palantir.Security; diff --git a/src/dotnet/Suspectus.Gandalf.Palantir.Security/Scheme/GandalfRebornJwtTokenAuthSchemeHandler.cs b/src/dotnet/Suspectus.Gandalf.Palantir.Security/Scheme/GandalfRebornJwtTokenAuthSchemeHandler.cs index 2471281..ea7015f 100644 --- a/src/dotnet/Suspectus.Gandalf.Palantir.Security/Scheme/GandalfRebornJwtTokenAuthSchemeHandler.cs +++ b/src/dotnet/Suspectus.Gandalf.Palantir.Security/Scheme/GandalfRebornJwtTokenAuthSchemeHandler.cs @@ -17,7 +17,10 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Suspectus.Gandalf.Palantir.Abstractions; using Suspectus.Gandalf.Palantir.Data.Database; +using Suspectus.Gandalf.Palantir.Data.Entities.Base; using Suspectus.Gandalf.Palantir.Data.Entities.Security; +using Suspectus.Gandalf.Palantir.Data.Entities.Subject; +using AuthorityType = Suspectus.Gandalf.Palantir.Data.Entities.Security.Permission.Data.AuthorityType; namespace Suspectus.Gandalf.Palantir.Security.Scheme; @@ -47,6 +50,14 @@ public partial class GandalfRebornJwtTokenAuthSchemeHandler( private string FailReason { get; set; } = ""; + private class AuthorityResult + { + public long Id { get; init; } + public string Name { get; init; } = null!; + public long TenantId { get; init; } + public long? AppId { get; init; } + }; + protected override async Task HandleAuthenticateAsync() { try @@ -64,37 +75,42 @@ public partial class GandalfRebornJwtTokenAuthSchemeHandler( { throw new UnauthorizedAccessException("One does not simply authenticate with a not existing subject."); } - + var claims = new List { new(Invoker.SubType, subjectId.ToString()) }; - var tenantAuthorities = await context.TenantSubjectRelations + var subjectQuery = context.Subjects .AsNoTracking() - .Where(x => x.SubjectId == subjectId) - .Include(x => x.InternalAuthorities) - .ToDictionaryAsync(x => x.TenantId, x => x.InternalAuthorities.Select(authority => authority.Name)); - - var appAuthorities = await context.AppSubjectRelations - .AsNoTracking() - .Where(x => x.SubjectId == subjectId) - .Include(x => x.InternalAuthorities) - .ToDictionaryAsync(x => x.AppId, x => x.InternalAuthorities.Select(authority => authority.Name)); + .Where(x => x.Id == subjectId); - var tenantClaims = tenantAuthorities - .SelectMany(x => x.Value.Select(authority => new Claim($"{Invoker.TenantAuthorityPrefix}{Invoker.AuthoritySeparator}{hashIds.EncodeLong(x.Key)}", authority))); + var tenantAuthorities = await GetAuthoritiesAsync(subjectQuery, AuthorityType.Tenant); + var appAuthorities = await GetAuthoritiesAsync(subjectQuery, AuthorityType.App); + + var tenantIds = tenantAuthorities + .Select(x => x.TenantId) + .Distinct() + .ToDictionary(x => x, hashIds.EncodeLong); + var appIds = appAuthorities + .Select(x => x.AppId!.Value) + .Distinct() + .ToDictionary(x => x, hashIds.EncodeLong); + + var tenantClaims = tenantAuthorities + .Select(x => new Claim($"{Invoker.TenantAuthorityPrefix}{Invoker.AuthoritySeparator}{tenantIds[x.TenantId]}", x.Name)); + var appClaims = appAuthorities - .SelectMany(x => x.Value.Select(authority => new Claim($"{Invoker.AppAuthorityPrefix}{Invoker.AuthoritySeparator}{hashIds.EncodeLong(x.Key)}", authority))); + .Select(x => new Claim($"{Invoker.AppAuthorityPrefix}{Invoker.AuthoritySeparator}{appIds[x.AppId!.Value]}", x.Name)); claims.AddRange(tenantClaims); claims.AddRange(appClaims); var principal = new ClaimsPrincipal(new ClaimsIdentity(claims, "Tokens")); - + invokerContext.Invoker = principal; - + var ticket = new AuthenticationTicket(principal, Scheme.Name); return AuthenticateResult.Success(ticket); } @@ -104,7 +120,7 @@ public partial class GandalfRebornJwtTokenAuthSchemeHandler( return AuthenticateResult.Fail(ex); } } - + protected override async Task HandleChallengeAsync(AuthenticationProperties properties) { await base.HandleChallengeAsync(properties); @@ -135,7 +151,7 @@ public partial class GandalfRebornJwtTokenAuthSchemeHandler( throw new UnauthorizedAccessException("One does not simply provide an invalid authorization header."); var token = tokenRegexMatch.Groups["token"].Value; - + var decodedToken = JwtBuilder.Create() .WithAlgorithm(new HMACSHA512Algorithm()) .WithSecret(Options.JwtSecret) @@ -147,18 +163,66 @@ public partial class GandalfRebornJwtTokenAuthSchemeHandler( if (tokenType != TokenType.Access) throw new UnauthorizedAccessException("One does not simply provide a refresh token as access token."); - + var audience = await context.Apps.Where(x => x.Tenant!.IsMaster && x.Name == "Master").Select(x => $"{x.Name.ToLower()}-api").SingleAsync(); - + if (decodedToken.Aud is null || decodedToken.Aud != audience) throw new UnauthorizedAccessException("One does not simply provide a token for a different audience."); - + if (decodedToken.Iss is null || !decodedToken.Iss.StartsWith(Options.BaseUrl)) throw new UnauthorizedAccessException("One does not simply provide a token from a unknown issuer."); - + if (decodedToken.Exp is null || decodedToken.Exp?.ToUniversalTime() <= timeProvider.GetUtcNow()) throw new UnauthorizedAccessException("One does not simply provide an expired token."); - + return decodedToken; } + + private async Task> GetAuthoritiesAsync(IQueryable subjectQuery, AuthorityType authorityType) + { + var rolesQuery = subjectQuery + .SelectMany(x => x.Roles) + .Where(x => x.Type == authorityType && x.Visibility == EntityVisibility.Active); + + var groupRolesQuery = subjectQuery + .SelectMany(x => x.Groups) + .Where(x => x.Type == authorityType && x.Visibility == EntityVisibility.Active) + .SelectMany(x => x.Roles) + .Where(x => x.Type == authorityType && x.Visibility == EntityVisibility.Active); + + var roleIds = await rolesQuery.Select(x => x.Id!.Value).ToListAsync(); + var groupRoleIds = await groupRolesQuery.Select(x => x.Id!.Value).ToListAsync(); + var allRoleIds = roleIds.Concat(groupRoleIds).Distinct().ToList(); + + var authorities = await context.Roles + .AsNoTracking() + .Where(x => allRoleIds.Contains(x.Id!.Value)) + .Select(x => new + { + Authorities = x.Authorities + .Where(y => y.Type == authorityType && y.Visibility == EntityVisibility.Active) + .Select(y => new AuthorityResult + { + Id = y.Id!.Value, + Name = y.Name, + TenantId = y.TenantId, + AppId = y.AppId + }), + GlobalAuthorities = x.GlobalAuthorities + .Where(y => y.Type == authorityType) + .Select(y => new AuthorityResult + { + Id = y.Id!.Value, + Name = y.Name, + TenantId = x.TenantId, + AppId = x.AppId + }) + }) + .SelectMany(x => x.Authorities.Concat(x.GlobalAuthorities)) + .ToListAsync(); + + var distinctAuthorities = authorities.DistinctBy(x => x.Id).ToList(); + + return distinctAuthorities; + } } \ No newline at end of file