网关和服务发现

This commit is contained in:
administrator committed 2024-04-20 14:33:06 +08:00
1 parent cea1278b71
commit 6f4a338bb4
14 files changed
+190 -52

No files matched your search

@@ -9,10 +9,8 @@ using System.Net.Http.Json;
namespace HelloShop.ServiceDefaults.Authorization;
public class RemotePermissionChecker(IHttpContextAccessor httpContextAccessor, IDistributedCache distributedCache, IHttpClientFactory httpClientFactory, IOptions<RemotePermissionCheckerOptions> options) : PermissionChecker(httpContextAccessor, distributedCache)
public class RemotePermissionChecker(IHttpContextAccessor httpContextAccessor, IDistributedCache distributedCache, IHttpClientFactory httpClientFactory) : PermissionChecker(httpContextAccessor, distributedCache)
{
private readonly RemotePermissionCheckerOptions _remotePermissionCheckerOptions = options.Value;
public override async Task<bool> IsGrantedAsync(int roleId, string permissionName, string? resourceType = null, string? resourceId = null)
{
string? accessToken = await HttpContext.GetTokenAsync("access_token");
@@ -21,7 +19,7 @@ public class RemotePermissionChecker(IHttpContextAccessor httpContextAccessor, I
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
httpClient.BaseAddress = new Uri(_remotePermissionCheckerOptions.ApiEndpoint);
httpClient.BaseAddress = new Uri("http://identityservice");
Dictionary<string, string?> parameters = new()
{