修正了方法名称,修正了说明文档
This commit is contained in:
@@ -16,7 +16,7 @@ public class SimApiAuthCenterMiddleware(RequestDelegate next, ILogger<SimApiAuth
|
|||||||
httpContext.Request.Headers.TryGetValue("X-SimApi-Gate-Sign", out var sign))
|
httpContext.Request.Headers.TryGetValue("X-SimApi-Gate-Sign", out var sign))
|
||||||
{
|
{
|
||||||
var signStr =
|
var signStr =
|
||||||
$"appId={simApiOptions.SimApiAuthGateOptions.AppId}&auth={auth}&time={time}&appKey={simApiOptions.SimApiAuthGateOptions.AppKey}";
|
$"appId={simApiOptions.SimApiAuthCenterOptions.AppId}&auth={auth}&time={time}&appKey={simApiOptions.SimApiAuthCenterOptions.AppKey}";
|
||||||
logger.LogDebug($"签名字符串 => {signStr}");
|
logger.LogDebug($"签名字符串 => {signStr}");
|
||||||
if (SimApiUtil.Md5(signStr) == sign && !string.IsNullOrEmpty(auth))
|
if (SimApiUtil.Md5(signStr) == sign && !string.IsNullOrEmpty(auth))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace SimApi.AuthSDK;
|
|||||||
public class SimApiAuthClient(SimApiOptions apiOptions, ILogger<SimApiAuthClient> logger)
|
public class SimApiAuthClient(SimApiOptions apiOptions, ILogger<SimApiAuthClient> logger)
|
||||||
: SimApiHttpClient(apiOptions, logger)
|
: SimApiHttpClient(apiOptions, logger)
|
||||||
{
|
{
|
||||||
public override string Server { get; init; } = apiOptions.SimApiAuthGateOptions.Server ?? string.Empty;
|
public override string Server { get; init; } = apiOptions.SimApiAuthCenterOptions.Server ?? string.Empty;
|
||||||
public override string AppId { get; init; } = apiOptions.SimApiAuthGateOptions.AppId ?? string.Empty;
|
public override string AppId { get; init; } = apiOptions.SimApiAuthCenterOptions.AppId ?? string.Empty;
|
||||||
public override string AppKey { get; init; } = apiOptions.SimApiAuthGateOptions.AppKey ?? string.Empty;
|
public override string AppKey { get; init; } = apiOptions.SimApiAuthCenterOptions.AppKey ?? string.Empty;
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace SimApi.Configurations;
|
namespace SimApi.Configurations;
|
||||||
|
|
||||||
public class SimApiAuthGateOptions
|
public class SimApiAuthCenterOptions
|
||||||
{
|
{
|
||||||
public string? Server { get; set; }
|
public string? Server { get; set; }
|
||||||
public string? AppId { get; set; }
|
public string? AppId { get; set; }
|
||||||
@@ -96,7 +96,7 @@ public class SimApiOptions
|
|||||||
|
|
||||||
public SimApiSynapseOptions SimApiSynapseOptions { get; set; } = new();
|
public SimApiSynapseOptions SimApiSynapseOptions { get; set; } = new();
|
||||||
|
|
||||||
public SimApiAuthGateOptions SimApiAuthGateOptions { get; set; } = new();
|
public SimApiAuthCenterOptions SimApiAuthCenterOptions { get; set; } = new();
|
||||||
|
|
||||||
public SimApiHttpClientOptions SimApiHttpClientOptions { get; set; } = new();
|
public SimApiHttpClientOptions SimApiHttpClientOptions { get; set; } = new();
|
||||||
|
|
||||||
@@ -139,8 +139,8 @@ public class SimApiOptions
|
|||||||
options?.Invoke(SimApiJobOptions);
|
options?.Invoke(SimApiJobOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConfigureSimApiAuthGate(Action<SimApiAuthGateOptions>? options = null)
|
public void ConfigureSimApiAuthCenter(Action<SimApiAuthCenterOptions>? options = null)
|
||||||
{
|
{
|
||||||
options?.Invoke(SimApiAuthGateOptions);
|
options?.Invoke(SimApiAuthCenterOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-4
@@ -333,7 +333,7 @@ public static class SimApiExtensions
|
|||||||
{
|
{
|
||||||
builder.AddSingleton<SimApiAuthClient>();
|
builder.AddSingleton<SimApiAuthClient>();
|
||||||
builder.AddSingleton<SimApiAuthCenter>();
|
builder.AddSingleton<SimApiAuthCenter>();
|
||||||
if (simApiOptions.SimApiAuthGateOptions.UseIam)
|
if (simApiOptions.SimApiAuthCenterOptions.UseIam)
|
||||||
{
|
{
|
||||||
builder.AddSingleton<SimApiAuthIam>();
|
builder.AddSingleton<SimApiAuthIam>();
|
||||||
}
|
}
|
||||||
@@ -425,14 +425,14 @@ public static class SimApiExtensions
|
|||||||
if (options.EnableSimApiAuthGate)
|
if (options.EnableSimApiAuthGate)
|
||||||
{
|
{
|
||||||
logger.LogInformation("开始配置SimApiAuthGate...");
|
logger.LogInformation("开始配置SimApiAuthGate...");
|
||||||
if (string.IsNullOrEmpty(options.SimApiAuthGateOptions.AppId) ||
|
if (string.IsNullOrEmpty(options.SimApiAuthCenterOptions.AppId) ||
|
||||||
string.IsNullOrEmpty(options.SimApiAuthGateOptions.AppKey))
|
string.IsNullOrEmpty(options.SimApiAuthCenterOptions.AppKey))
|
||||||
{
|
{
|
||||||
logger.LogCritical("必须配置AuthGate的AppId和AppKey才能启用SimApiAuthGate");
|
logger.LogCritical("必须配置AuthGate的AppId和AppKey才能启用SimApiAuthGate");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (options.SimApiAuthGateOptions.UseMiddleware)
|
if (options.SimApiAuthCenterOptions.UseMiddleware)
|
||||||
{
|
{
|
||||||
builder.UseMiddleware<SimApiAuthCenterMiddleware>();
|
builder.UseMiddleware<SimApiAuthCenterMiddleware>();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user