-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from netcorepal/dev
Dev
- Loading branch information
Showing
98 changed files
with
1,344 additions
and
764 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
NetCorePal.D3Shop.Admin.Shared/Authorization/PermissionAuthorizationHandler.cs
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
NetCorePal.D3Shop.Admin.Shared/NetCorePal.D3Shop.Admin.Shared.csproj
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
NetCorePal.D3Shop.Admin.Shared/Requests/AdminUserQueryRequest.cs
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
NetCorePal.D3Shop.Admin.Shared/Requests/AdminUserRefreshTokenRequest.cs
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
NetCorePal.D3Shop.Admin.Shared/Requests/CreateAdminUserRequest.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
NetCorePal.D3Shop.Admin.Shared/Requests/UpdateRoleInfoRequest.cs
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
NetCorePal.D3Shop.Admin.Shared/Responses/AdminUserResponse.cs
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
NetCorePal.D3Shop.Admin.Shared/Responses/AdminUserTokenResponse.cs
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
NetCorePal.D3Shop.Admin.Shared/Responses/RolePermissionResponse.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
35 changes: 35 additions & 0 deletions
35
src/NetCorePal.D3Shop.Admin.Shared/Authorization/PermissionAuthorizationHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Security.Claims; | ||
using Microsoft.AspNetCore.Authorization; | ||
using NetCorePal.D3Shop.Domain.AggregatesModel.Identity.AdminUserAggregate; | ||
|
||
namespace NetCorePal.D3Shop.Admin.Shared.Authorization; | ||
|
||
public class PermissionAuthorizationHandler(IPermissionChecker permissionChecker) | ||
: AuthorizationHandler<PermissionRequirement> | ||
{ | ||
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, | ||
PermissionRequirement requirement) | ||
{ | ||
if (context.User.Identity?.IsAuthenticated is null or false) | ||
{ | ||
context.Fail(); | ||
return; | ||
} | ||
|
||
// 系统默认用户不校验权限 | ||
var name = context.User.Claims.Single(c => c.Type == ClaimTypes.Name).Value; | ||
if (name == AppDefaultCredentials.Name) | ||
{ | ||
context.Succeed(requirement); | ||
return; | ||
} | ||
|
||
// 检查用户是否拥有指定权限 | ||
var hasPermission = | ||
await permissionChecker.HasPermissionAsync(context.User, requirement.PermissionCode); | ||
if (hasPermission) | ||
{ | ||
context.Succeed(requirement); | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions
19
src/NetCorePal.D3Shop.Admin.Shared/NetCorePal.D3Shop.Admin.Shared.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="8.0.10"/> | ||
<PackageReference Include="NetCorePal.Extensions.Dto" Version="$(NetCorePalVersion)"/> | ||
<PackageReference Include="NetCorePal.Extensions.NewtonsoftJson" Version="$(NetCorePalVersion)"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\NetCorePal.D3Shop.Domain\NetCorePal.D3Shop.Domain.csproj"/> | ||
</ItemGroup> | ||
|
||
</Project> |
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
src/NetCorePal.D3Shop.Admin.Shared/Requests/AdminUserQueryRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using NetCorePal.Extensions.Dto; | ||
|
||
namespace NetCorePal.D3Shop.Admin.Shared.Requests; | ||
|
||
public class AdminUserQueryRequest : PageRequest | ||
{ | ||
public string? Name { get; set; } | ||
public string? Phone { get; set; } | ||
} |
12 changes: 12 additions & 0 deletions
12
src/NetCorePal.D3Shop.Admin.Shared/Requests/CreateAdminUserRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using NetCorePal.D3Shop.Domain.AggregatesModel.Identity.RoleAggregate; | ||
|
||
namespace NetCorePal.D3Shop.Admin.Shared.Requests; | ||
|
||
public class CreateAdminUserRequest | ||
{ | ||
[Required] public string Name { get; set; } = string.Empty; | ||
[Required] public string Phone { get; set; } = string.Empty; | ||
[Required] public string PassWord { get; set; } = string.Empty; | ||
public IEnumerable<RoleId> RoleIds { get; set; } = []; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/NetCorePal.D3Shop.Admin.Shared/Requests/CreateRoleRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace NetCorePal.D3Shop.Admin.Shared.Requests; | ||
|
||
public class CreateRoleRequest | ||
{ | ||
[Required] public string Name { get; set; } = string.Empty; | ||
public string Description { get; set; } = string.Empty; | ||
public IEnumerable<string> PermissionCodes { get; set; } = []; | ||
} |
9 changes: 9 additions & 0 deletions
9
src/NetCorePal.D3Shop.Admin.Shared/Requests/RoleQueryRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using NetCorePal.Extensions.Dto; | ||
|
||
namespace NetCorePal.D3Shop.Admin.Shared.Requests; | ||
|
||
public class RoleQueryRequest : PageRequest | ||
{ | ||
public string? Name { get; set; } | ||
public string? Description { get; set; } | ||
} |
File renamed without changes.
9 changes: 9 additions & 0 deletions
9
src/NetCorePal.D3Shop.Admin.Shared/Requests/UpdateRoleInfoRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace NetCorePal.D3Shop.Admin.Shared.Requests; | ||
|
||
public class UpdateRoleInfoRequest | ||
{ | ||
[Required] public string Name { get; set; } = string.Empty; | ||
public string Description { get; set; } = string.Empty; | ||
} |
8 changes: 8 additions & 0 deletions
8
src/NetCorePal.D3Shop.Admin.Shared/Responses/AdminUserPermissionResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace NetCorePal.D3Shop.Admin.Shared.Responses; | ||
|
||
public record AdminUserPermissionResponse( | ||
string Code, | ||
string GroupName, | ||
string Remark, | ||
bool IsAssigned, | ||
bool IsFromRole); |
10 changes: 10 additions & 0 deletions
10
src/NetCorePal.D3Shop.Admin.Shared/Responses/AdminUserResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using NetCorePal.D3Shop.Domain.AggregatesModel.Identity.AdminUserAggregate; | ||
|
||
namespace NetCorePal.D3Shop.Admin.Shared.Responses; | ||
|
||
public class AdminUserResponse(AdminUserId id, string name, string phone) | ||
{ | ||
public AdminUserId Id { get; } = id; | ||
public string Name { get; set; } = name; | ||
public string Phone { get; set; } = phone; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/NetCorePal.D3Shop.Admin.Shared/Responses/AdminUserRoleResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using NetCorePal.D3Shop.Domain.AggregatesModel.Identity.RoleAggregate; | ||
|
||
namespace NetCorePal.D3Shop.Admin.Shared.Responses; | ||
|
||
public class AdminUserRoleResponse(RoleId roleId, string roleName, bool isAssigned) | ||
{ | ||
public RoleId RoleId { get; } = roleId; | ||
public string RoleName { get; } = roleName; | ||
public bool IsAssigned { get; set; } = isAssigned; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/NetCorePal.D3Shop.Admin.Shared/Responses/RolePermissionResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace NetCorePal.D3Shop.Admin.Shared.Responses; | ||
|
||
public record RolePermissionResponse( | ||
string Code, | ||
string GroupName, | ||
string Remark, | ||
bool IsAssigned); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.