last ...
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
namespace xCommons.Constants {
|
||||
public partial struct XAuthorization {
|
||||
public const string TokenIdentifier = "Bearer ";
|
||||
public const string XApiKey = "X-Api-Key";
|
||||
public const string Header = "Authorization";
|
||||
public const string ExpiresAt = "expires_at";
|
||||
public const string XPoweredBy = "X-PoweredBy";
|
||||
public const string TokenIdentifier = "Bearer ";
|
||||
public const string AccessToken = "access_token";
|
||||
public const string RefreshToken = "refresh_token";
|
||||
public const string ExpiresAt = "expires_at";
|
||||
public const string AccessTokenExpired = "AccessToken-Expired";
|
||||
public const string RevisionChecksum = "revision_checksum";
|
||||
public const string XPoweredBy = "X-PoweredBy";
|
||||
public const int ThresholdBeforeTokenExpiration = 600;
|
||||
public const string RevisionChecksum = "revision_checksum";
|
||||
public const string AccessTokenExpired = "AccessToken-Expired";
|
||||
}
|
||||
}
|
||||
@@ -94,12 +94,14 @@ namespace xCommons.Extensions
|
||||
/// <param name="xmlFilePath"></param>
|
||||
/// <param name="addRequiredXPoweredFilter"></param>
|
||||
/// <param name="addXTokenAuthorization"></param>
|
||||
/// <param name="addXApiKeyAuthorization"></param>
|
||||
/// <param name="addDefaultValueFilter"></param>
|
||||
public static void AddXSwaggerGenOptions(
|
||||
this SwaggerGenOptions source,
|
||||
string xmlFilePath = null,
|
||||
bool addRequiredXPoweredFilter = true,
|
||||
bool addXTokenAuthorization = true,
|
||||
bool addXApiKeyAuthorization = true,
|
||||
bool addDefaultValueFilter = true
|
||||
)
|
||||
{
|
||||
@@ -210,6 +212,32 @@ namespace xCommons.Extensions
|
||||
});
|
||||
#endregion
|
||||
}
|
||||
|
||||
//
|
||||
// Handle XApiKey Authorization ...
|
||||
if (addXApiKeyAuthorization)
|
||||
{
|
||||
//
|
||||
source.AddSecurityDefinition(nameof(XAuthorization.XApiKey), new OpenApiSecurityScheme
|
||||
{
|
||||
In = ParameterLocation.Header,
|
||||
Name = XAuthorization.XApiKey,
|
||||
Type = SecuritySchemeType.ApiKey,
|
||||
Description = "Api Key for Authentication ...",
|
||||
});
|
||||
|
||||
//
|
||||
source.AddSecurityRequirement(new OpenApiSecurityRequirement {
|
||||
{
|
||||
new OpenApiSecurityScheme {
|
||||
Reference = new OpenApiReference {
|
||||
Id = nameof (XAuthorization.XApiKey),
|
||||
Type = ReferenceType.SecurityScheme
|
||||
}
|
||||
}, Array.Empty<string> ()
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -221,6 +249,7 @@ namespace xCommons.Extensions
|
||||
/// <param name="xmlFilePath"></param>
|
||||
/// <param name="addRequiredXPoweredFilter"></param>
|
||||
/// <param name="addXTokenAuthorization"></param>
|
||||
/// <param name="addXApiKeyAuthorization"></param>
|
||||
/// <param name="addDefaultValueFilter"></param>
|
||||
public static void AddXSwagger(
|
||||
this IServiceCollection source,
|
||||
@@ -229,6 +258,7 @@ namespace xCommons.Extensions
|
||||
string xmlFilePath = null,
|
||||
bool addRequiredXPoweredFilter = true,
|
||||
bool addXTokenAuthorization = true,
|
||||
bool addXApiKeyAuthorization = true,
|
||||
bool addDefaultValueFilter = true
|
||||
)
|
||||
{
|
||||
@@ -252,6 +282,7 @@ namespace xCommons.Extensions
|
||||
xmlFilePath: xmlFilePath,
|
||||
addDefaultValueFilter: addDefaultValueFilter,
|
||||
addXTokenAuthorization: addXTokenAuthorization,
|
||||
addXApiKeyAuthorization: addXApiKeyAuthorization,
|
||||
addRequiredXPoweredFilter: addRequiredXPoweredFilter
|
||||
);
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user