diff --git a/AspNetCore.Authorization.Permissions.sln b/AspNetCore.Authorization.Permissions.sln
index 60fb98b..8678a2b 100644
--- a/AspNetCore.Authorization.Permissions.sln
+++ b/AspNetCore.Authorization.Permissions.sln
@@ -44,6 +44,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoSamplePermissions", "s
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MongoSampleTenant", "samples\MongoSampleTenant\MongoSampleTenant.csproj", "{B7172410-2A68-4DB9-9538-036C8FFC7DE4}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCore.Identity.Permissions.MongoDB.IntegrationTests", "tests\AspNetCore.Identity.Permissions.MongoDB.IntegrationTests\AspNetCore.Identity.Permissions.MongoDB.IntegrationTests.csproj", "{61ADF77F-B1DB-4489-AD46-DD6956605D41}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCore.Identity.Permissions.EntityFrameworkCore.IntegrationTests", "tests\AspNetCore.Identity.Permissions.EntityFrameworkCore.IntegrationTests\AspNetCore.Identity.Permissions.EntityFrameworkCore.IntegrationTests.csproj", "{637FE076-7CDE-49B1-BB14-1A6CE85382A8}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -98,6 +102,14 @@ Global
{B7172410-2A68-4DB9-9538-036C8FFC7DE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B7172410-2A68-4DB9-9538-036C8FFC7DE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B7172410-2A68-4DB9-9538-036C8FFC7DE4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {61ADF77F-B1DB-4489-AD46-DD6956605D41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {61ADF77F-B1DB-4489-AD46-DD6956605D41}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {61ADF77F-B1DB-4489-AD46-DD6956605D41}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {61ADF77F-B1DB-4489-AD46-DD6956605D41}.Release|Any CPU.Build.0 = Release|Any CPU
+ {637FE076-7CDE-49B1-BB14-1A6CE85382A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {637FE076-7CDE-49B1-BB14-1A6CE85382A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {637FE076-7CDE-49B1-BB14-1A6CE85382A8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {637FE076-7CDE-49B1-BB14-1A6CE85382A8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -117,6 +129,8 @@ Global
{074DB0DE-2F0B-4C8C-95B1-E8D1BE71077E} = {FA57E06B-CC0E-459C-A993-1D41ADF99ECF}
{3273907D-2D59-42AC-81C1-8B8F4617A7FA} = {24F9EFE8-010B-48D9-B5D2-EF194BDEAC31}
{B7172410-2A68-4DB9-9538-036C8FFC7DE4} = {24F9EFE8-010B-48D9-B5D2-EF194BDEAC31}
+ {61ADF77F-B1DB-4489-AD46-DD6956605D41} = {9BE8804F-BCC0-48CF-9AEC-ED97414B0C78}
+ {637FE076-7CDE-49B1-BB14-1A6CE85382A8} = {9BE8804F-BCC0-48CF-9AEC-ED97414B0C78}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A52A2019-EEE6-4DAB-B111-C10693C9E03B}
diff --git a/src/AspNetCore.Authorization.Permissions.Abstractions/AspNetCore.Authorization.Permissions.Abstractions.csproj b/src/AspNetCore.Authorization.Permissions.Abstractions/AspNetCore.Authorization.Permissions.Abstractions.csproj
index 6eceae7..6d68fdc 100644
--- a/src/AspNetCore.Authorization.Permissions.Abstractions/AspNetCore.Authorization.Permissions.Abstractions.csproj
+++ b/src/AspNetCore.Authorization.Permissions.Abstractions/AspNetCore.Authorization.Permissions.Abstractions.csproj
@@ -14,9 +14,9 @@
MadEyeMatt.$(MSBuildProjectName.Replace(" ", "_").Replace(".Abstractions", ""))
false
Copyright © 2022-2023 Matthias Gernand. All rights reserved.
- 8.2.0
- 8.2.0
- 8.2.0
+ 8.2.1
+ 8.2.1
+ 8.2.1
Matthias Gernand
A libary that adds permission-based authorization.
en
diff --git a/src/AspNetCore.Authorization.Permissions/AspNetCore.Authorization.Permissions.csproj b/src/AspNetCore.Authorization.Permissions/AspNetCore.Authorization.Permissions.csproj
index 5481206..b47d702 100644
--- a/src/AspNetCore.Authorization.Permissions/AspNetCore.Authorization.Permissions.csproj
+++ b/src/AspNetCore.Authorization.Permissions/AspNetCore.Authorization.Permissions.csproj
@@ -14,9 +14,9 @@
MadEyeMatt.$(MSBuildProjectName.Replace(" ", "_"))
false
Copyright © 2022-2023 Matthias Gernand. All rights reserved.
- 8.2.0
- 8.2.0
- 8.2.0
+ 8.2.1
+ 8.2.1
+ 8.2.1
Matthias Gernand
A libary that adds permission-based authorization.
en
diff --git a/src/AspNetCore.Identity.Permissions.EntityFrameworkCore/AspNetCore.Identity.Permissions.EntityFrameworkCore.csproj b/src/AspNetCore.Identity.Permissions.EntityFrameworkCore/AspNetCore.Identity.Permissions.EntityFrameworkCore.csproj
index 5ddab2c..e3cee69 100644
--- a/src/AspNetCore.Identity.Permissions.EntityFrameworkCore/AspNetCore.Identity.Permissions.EntityFrameworkCore.csproj
+++ b/src/AspNetCore.Identity.Permissions.EntityFrameworkCore/AspNetCore.Identity.Permissions.EntityFrameworkCore.csproj
@@ -14,9 +14,9 @@
MadEyeMatt.$(MSBuildProjectName.Replace(" ", "_"))
false
Copyright © 2022-2023 Matthias Gernand. All rights reserved.
- 8.2.0
- 8.2.0
- 8.2.0
+ 8.2.1
+ 8.2.1
+ 8.2.1
Matthias Gernand
A libary that adds permission-based authorization.
en
diff --git a/src/AspNetCore.Identity.Permissions.MongoDB/AspNetCore.Identity.Permissions.MongoDB.csproj b/src/AspNetCore.Identity.Permissions.MongoDB/AspNetCore.Identity.Permissions.MongoDB.csproj
index a08b17e..8cc6f12 100644
--- a/src/AspNetCore.Identity.Permissions.MongoDB/AspNetCore.Identity.Permissions.MongoDB.csproj
+++ b/src/AspNetCore.Identity.Permissions.MongoDB/AspNetCore.Identity.Permissions.MongoDB.csproj
@@ -14,9 +14,9 @@
MadEyeMatt.$(MSBuildProjectName.Replace(" ", "_"))
false
Copyright © 2022-2023 Matthias Gernand. All rights reserved.
- 8.2.0
- 8.2.0
- 8.2.0
+ 8.2.1
+ 8.2.1
+ 8.2.1
Matthias Gernand
A libary that adds permission-based authorization.
en
diff --git a/src/AspNetCore.Identity.Permissions/AspNetCore.Identity.Permissions.csproj b/src/AspNetCore.Identity.Permissions/AspNetCore.Identity.Permissions.csproj
index 7ef9270..41989c4 100644
--- a/src/AspNetCore.Identity.Permissions/AspNetCore.Identity.Permissions.csproj
+++ b/src/AspNetCore.Identity.Permissions/AspNetCore.Identity.Permissions.csproj
@@ -14,9 +14,9 @@
MadEyeMatt.AspNetCore.Identity.Permissions
false
Copyright © 2022-2023 Matthias Gernand. All rights reserved.
- 8.2.0
- 8.2.0
- 8.2.0
+ 8.2.1
+ 8.2.1
+ 8.2.1
Matthias Gernand
A libary that adds permission-based authorization.
en
diff --git a/src/Extensions.Identity.Permissions.Core/Extensions.Identity.Permissions.Core.csproj b/src/Extensions.Identity.Permissions.Core/Extensions.Identity.Permissions.Core.csproj
index d58819c..9ade11a 100644
--- a/src/Extensions.Identity.Permissions.Core/Extensions.Identity.Permissions.Core.csproj
+++ b/src/Extensions.Identity.Permissions.Core/Extensions.Identity.Permissions.Core.csproj
@@ -14,9 +14,9 @@
MadEyeMatt.AspNetCore.Identity.Permissions
false
Copyright © 2022-2023 Matthias Gernand. All rights reserved.
- 8.2.0
- 8.2.0
- 8.2.0
+ 8.2.1
+ 8.2.1
+ 8.2.1
Matthias Gernand
A libary that adds permission-based authorization.
en
diff --git a/src/Extensions.Identity.Permissions.Core/PermissionManager.cs b/src/Extensions.Identity.Permissions.Core/PermissionManager.cs
index 9c23c68..3db4f27 100644
--- a/src/Extensions.Identity.Permissions.Core/PermissionManager.cs
+++ b/src/Extensions.Identity.Permissions.Core/PermissionManager.cs
@@ -158,10 +158,7 @@ public void Dispose()
public virtual async Task CreateAsync(TPermission permission)
{
this.ThrowIfDisposed();
- if(permission == null)
- {
- throw new ArgumentNullException(nameof(permission));
- }
+ ArgumentNullException.ThrowIfNull(permission);
IdentityResult result = await this.ValidatePermissionAsync(permission);
if(!result.Succeeded)
@@ -185,12 +182,9 @@ public virtual async Task CreateAsync(TPermission permission)
public virtual Task UpdateAsync(TPermission permission)
{
this.ThrowIfDisposed();
- if(permission == null)
- {
- throw new ArgumentNullException(nameof(permission));
- }
+ ArgumentNullException.ThrowIfNull(permission);
- return this.UpdatePermissionAsync(permission);
+ return this.UpdatePermissionAsync(permission);
}
///
@@ -204,10 +198,7 @@ public virtual Task UpdateAsync(TPermission permission)
public virtual Task DeleteAsync(TPermission permission)
{
this.ThrowIfDisposed();
- if(permission == null)
- {
- throw new ArgumentNullException(nameof(permission));
- }
+ ArgumentNullException.ThrowIfNull(permission);
return this.Store.DeleteAsync(permission, this.CancellationToken);
}
@@ -223,12 +214,9 @@ public virtual Task DeleteAsync(TPermission permission)
public virtual async Task PermissionExistsAsync(string permissionName)
{
this.ThrowIfDisposed();
- if(permissionName == null)
- {
- throw new ArgumentNullException(nameof(permissionName));
- }
+ ArgumentNullException.ThrowIfNull(permissionName);
- return await this.FindByNameAsync(permissionName) != null;
+ return await this.FindByNameAsync(permissionName) != null;
}
///
@@ -290,23 +278,50 @@ public virtual Task GetPermissionIdAsync(TPermission permission)
return this.Store.GetPermissionIdAsync(permission, this.CancellationToken);
}
- ///
- /// Finds the role associated with the specified if any.
- ///
- /// The permission ID whose permission should be returned.
- ///
- /// The that represents the asynchronous operation, containing the permission
- /// associated with the specified
- ///
- public Task FindByNameAsync(string permissionName)
+ ///
+ /// Gets a list of role names the specified belongs to.
+ ///
+ /// The permission whose role names to retrieve.
+ /// The that represents the asynchronous operation, containing a list of role names.
+ public virtual async Task> GetRolesAsync(TPermission permission)
{
this.ThrowIfDisposed();
- if(permissionName == null)
- {
- throw new ArgumentNullException(nameof(permissionName));
- }
+ ArgumentNullException.ThrowIfNull(permission);
- return this.Store.FindByNameAsync(this.NormalizeName(permissionName), this.CancellationToken);
+ IRolePermissionStore store = this.GetRolePermissionStore();
+ return await store.GetRolesAsync(permission, this.CancellationToken);
+ }
+
+ ///
+ /// Finds the role associated with the specified if any.
+ ///
+ /// The permission ID whose permission should be returned.
+ ///
+ /// The that represents the asynchronous operation, containing the permission
+ /// associated with the specified
+ ///
+ public Task FindByIdAsync(string permissionId)
+ {
+ this.ThrowIfDisposed();
+ ArgumentNullException.ThrowIfNull(permissionId);
+
+ return this.Store.FindByIdAsync(permissionId, this.CancellationToken);
+ }
+
+ ///
+ /// Finds the role associated with the specified if any.
+ ///
+ /// The permission name whose permission should be returned.
+ ///
+ /// The that represents the asynchronous operation, containing the permission
+ /// associated with the specified
+ ///
+ public Task FindByNameAsync(string permissionName)
+ {
+ this.ThrowIfDisposed();
+ ArgumentNullException.ThrowIfNull(permissionName);
+
+ return this.Store.FindByNameAsync(this.NormalizeName(permissionName), this.CancellationToken);
}
///
@@ -323,12 +338,9 @@ public virtual Task> GetPermissionsInRoleAsync(string roleNam
{
this.ThrowIfDisposed();
IRolePermissionStore store = this.GetRolePermissionStore();
- if(roleName == null)
- {
- throw new ArgumentNullException(nameof(roleName));
- }
+ ArgumentNullException.ThrowIfNull(roleName);
- return store.GetPermissionsInRoleAsync(this.NormalizeName(roleName), this.CancellationToken);
+ return store.GetPermissionsInRoleAsync(this.NormalizeName(roleName), this.CancellationToken);
}
///
@@ -343,12 +355,9 @@ public virtual Task> GetPermissionsInRoleAsync(string roleNam
public IList GetPermissions(ClaimsPrincipal principal)
{
this.ThrowIfDisposed();
- if(principal == null)
- {
- throw new ArgumentNullException(nameof(principal));
- }
+ ArgumentNullException.ThrowIfNull(principal);
- return principal.GetPermissions().ToList();
+ return principal.GetPermissions().ToList();
}
///
diff --git a/src/Extensions.Identity.Permissions.Core/TenantManager.cs b/src/Extensions.Identity.Permissions.Core/TenantManager.cs
index a3fece9..e48f010 100644
--- a/src/Extensions.Identity.Permissions.Core/TenantManager.cs
+++ b/src/Extensions.Identity.Permissions.Core/TenantManager.cs
@@ -156,10 +156,7 @@ public void Dispose()
public virtual async Task CreateAsync(TTenant tenant)
{
this.ThrowIfDisposed();
- if(tenant == null)
- {
- throw new ArgumentNullException(nameof(tenant));
- }
+ ArgumentNullException.ThrowIfNull(tenant);
IdentityResult result = await this.ValidateTenantAsync(tenant);
if(!result.Succeeded)
@@ -183,12 +180,9 @@ public virtual async Task CreateAsync(TTenant tenant)
public virtual Task UpdateAsync(TTenant tenant)
{
this.ThrowIfDisposed();
- if(tenant == null)
- {
- throw new ArgumentNullException(nameof(tenant));
- }
+ ArgumentNullException.ThrowIfNull(tenant);
- return this.UpdateTenantAsync(tenant);
+ return this.UpdateTenantAsync(tenant);
}
///
@@ -202,12 +196,9 @@ public virtual Task UpdateAsync(TTenant tenant)
public virtual Task DeleteAsync(TTenant tenant)
{
this.ThrowIfDisposed();
- if(tenant == null)
- {
- throw new ArgumentNullException(nameof(tenant));
- }
+ ArgumentNullException.ThrowIfNull(tenant);
- return this.Store.DeleteAsync(tenant, this.CancellationToken);
+ return this.Store.DeleteAsync(tenant, this.CancellationToken);
}
///
@@ -221,12 +212,9 @@ public virtual Task DeleteAsync(TTenant tenant)
public virtual async Task TenantExistsAsync(string tenantName)
{
this.ThrowIfDisposed();
- if(tenantName == null)
- {
- throw new ArgumentNullException(nameof(tenantName));
- }
+ ArgumentNullException.ThrowIfNull(tenantName);
- return await this.FindByNameAsync(tenantName) != null;
+ return await this.FindByNameAsync(tenantName) != null;
}
///
@@ -240,10 +228,7 @@ public virtual async Task TenantExistsAsync(string tenantName)
public Task FindByIdAsync(string tenantId)
{
this.ThrowIfDisposed();
- if(tenantId == null)
- {
- throw new ArgumentNullException(nameof(tenantId));
- }
+ ArgumentNullException.ThrowIfNull(tenantId);
return this.Store.FindByIdAsync(tenantId, this.CancellationToken);
}
@@ -259,12 +244,9 @@ public Task FindByIdAsync(string tenantId)
public Task FindByNameAsync(string tenantName)
{
this.ThrowIfDisposed();
- if(tenantName == null)
- {
- throw new ArgumentNullException(nameof(tenantName));
- }
+ ArgumentNullException.ThrowIfNull(tenantName);
- return this.Store.FindByNameAsync(this.NormalizeName(tenantName), this.CancellationToken);
+ return this.Store.FindByNameAsync(this.NormalizeName(tenantName), this.CancellationToken);
}
///
@@ -348,13 +330,10 @@ public virtual async Task SetTenantNameAsync(TTenant tenant, str
public virtual async Task> GetRolesAsync(TTenant tenant)
{
this.ThrowIfDisposed();
- ITenantRoleStore store = this.GetTenantRoleStore();
- if(tenant == null)
- {
- throw new ArgumentNullException(nameof(tenant));
- }
+ ArgumentNullException.ThrowIfNull(tenant);
- return await store.GetRolesAsync(tenant, this.CancellationToken);
+ ITenantRoleStore store = this.GetTenantRoleStore();
+ return await store.GetRolesAsync(tenant, this.CancellationToken);
}
///
diff --git a/src/Extensions.Identity.Permissions.Core/TenantUserManager.cs b/src/Extensions.Identity.Permissions.Core/TenantUserManager.cs
index 0685205..0feb5ac 100644
--- a/src/Extensions.Identity.Permissions.Core/TenantUserManager.cs
+++ b/src/Extensions.Identity.Permissions.Core/TenantUserManager.cs
@@ -47,12 +47,9 @@ public TenantUserManager(
public virtual async Task GetTenantIdAsync(TUser user)
{
this.ThrowIfDisposed();
- if(user == null)
- {
- throw new ArgumentNullException(nameof(user));
- }
+ ArgumentNullException.ThrowIfNull(user);
- return await this.userStore.GetTenantIdAsync(user, this.CancellationToken);
+ return await this.userStore.GetTenantIdAsync(user, this.CancellationToken);
}
///
@@ -67,12 +64,9 @@ public virtual async Task GetTenantIdAsync(TUser user)
public string GetTenantId(ClaimsPrincipal principal)
{
this.ThrowIfDisposed();
- if(principal == null)
- {
- throw new ArgumentNullException(nameof(principal));
- }
+ ArgumentNullException.ThrowIfNull(principal);
- return principal.GetTenantId();
+ return principal.GetTenantId();
}
///
@@ -87,10 +81,7 @@ public string GetTenantId(ClaimsPrincipal principal)
public string GetTenantName(ClaimsPrincipal principal)
{
this.ThrowIfDisposed();
- if(principal == null)
- {
- throw new ArgumentNullException(nameof(principal));
- }
+ ArgumentNullException.ThrowIfNull(principal);
return principal.GetTenantName();
}
@@ -107,12 +98,9 @@ public string GetTenantName(ClaimsPrincipal principal)
public string GetTenantDisplayName(ClaimsPrincipal principal)
{
this.ThrowIfDisposed();
- if(principal == null)
- {
- throw new ArgumentNullException(nameof(principal));
- }
+ ArgumentNullException.ThrowIfNull(principal);
- return principal.GetTenantDisplayName();
+ return principal.GetTenantDisplayName();
}
}
}
diff --git a/src/Extensions.Identity.Permissions.Core/UserStoreExtensions.cs b/src/Extensions.Identity.Permissions.Core/UserStoreExtensions.cs
index fa82252..64cbc81 100644
--- a/src/Extensions.Identity.Permissions.Core/UserStoreExtensions.cs
+++ b/src/Extensions.Identity.Permissions.Core/UserStoreExtensions.cs
@@ -34,10 +34,7 @@ public static Task GetTenantIdAsync(this IUserStore userSt
MethodInfo methodInfo = userStore.GetType().GetMethod("ThrowIfDisposed", BindingFlags.NonPublic | BindingFlags.Instance);
methodInfo?.Invoke(userStore, Array.Empty