last ...
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
namespace xCommons.Constants {
|
namespace xCommons.Constants {
|
||||||
public partial struct XAuthorization {
|
public partial struct XAuthorization {
|
||||||
public const string TokenIdentifier = "Bearer ";
|
public const string XApiKey = "X-Api-Key";
|
||||||
public const string Header = "Authorization";
|
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 AccessToken = "access_token";
|
||||||
public const string RefreshToken = "refresh_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 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="xmlFilePath"></param>
|
||||||
/// <param name="addRequiredXPoweredFilter"></param>
|
/// <param name="addRequiredXPoweredFilter"></param>
|
||||||
/// <param name="addXTokenAuthorization"></param>
|
/// <param name="addXTokenAuthorization"></param>
|
||||||
|
/// <param name="addXApiKeyAuthorization"></param>
|
||||||
/// <param name="addDefaultValueFilter"></param>
|
/// <param name="addDefaultValueFilter"></param>
|
||||||
public static void AddXSwaggerGenOptions(
|
public static void AddXSwaggerGenOptions(
|
||||||
this SwaggerGenOptions source,
|
this SwaggerGenOptions source,
|
||||||
string xmlFilePath = null,
|
string xmlFilePath = null,
|
||||||
bool addRequiredXPoweredFilter = true,
|
bool addRequiredXPoweredFilter = true,
|
||||||
bool addXTokenAuthorization = true,
|
bool addXTokenAuthorization = true,
|
||||||
|
bool addXApiKeyAuthorization = true,
|
||||||
bool addDefaultValueFilter = true
|
bool addDefaultValueFilter = true
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -210,6 +212,32 @@ namespace xCommons.Extensions
|
|||||||
});
|
});
|
||||||
#endregion
|
#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>
|
/// <summary>
|
||||||
@@ -221,6 +249,7 @@ namespace xCommons.Extensions
|
|||||||
/// <param name="xmlFilePath"></param>
|
/// <param name="xmlFilePath"></param>
|
||||||
/// <param name="addRequiredXPoweredFilter"></param>
|
/// <param name="addRequiredXPoweredFilter"></param>
|
||||||
/// <param name="addXTokenAuthorization"></param>
|
/// <param name="addXTokenAuthorization"></param>
|
||||||
|
/// <param name="addXApiKeyAuthorization"></param>
|
||||||
/// <param name="addDefaultValueFilter"></param>
|
/// <param name="addDefaultValueFilter"></param>
|
||||||
public static void AddXSwagger(
|
public static void AddXSwagger(
|
||||||
this IServiceCollection source,
|
this IServiceCollection source,
|
||||||
@@ -229,6 +258,7 @@ namespace xCommons.Extensions
|
|||||||
string xmlFilePath = null,
|
string xmlFilePath = null,
|
||||||
bool addRequiredXPoweredFilter = true,
|
bool addRequiredXPoweredFilter = true,
|
||||||
bool addXTokenAuthorization = true,
|
bool addXTokenAuthorization = true,
|
||||||
|
bool addXApiKeyAuthorization = true,
|
||||||
bool addDefaultValueFilter = true
|
bool addDefaultValueFilter = true
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -252,6 +282,7 @@ namespace xCommons.Extensions
|
|||||||
xmlFilePath: xmlFilePath,
|
xmlFilePath: xmlFilePath,
|
||||||
addDefaultValueFilter: addDefaultValueFilter,
|
addDefaultValueFilter: addDefaultValueFilter,
|
||||||
addXTokenAuthorization: addXTokenAuthorization,
|
addXTokenAuthorization: addXTokenAuthorization,
|
||||||
|
addXApiKeyAuthorization: addXApiKeyAuthorization,
|
||||||
addRequiredXPoweredFilter: addRequiredXPoweredFilter
|
addRequiredXPoweredFilter: addRequiredXPoweredFilter
|
||||||
);
|
);
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user