last ...
This commit is contained in:
@@ -159,7 +159,7 @@ namespace xIds.Controllers
|
||||
|
||||
[RequireXPowered]
|
||||
[HttpGet("Test/HiApiKeyAccess")]
|
||||
[Authorize(LocalApi.PolicyName)]
|
||||
// [Authorize(LocalApi.PolicyName)]
|
||||
[Authorize(Policy = XPolicies.ApiKeyAccess)]
|
||||
public ActionResult<string> HiApiKeyAccess()
|
||||
{
|
||||
|
||||
+40
-35
@@ -410,45 +410,50 @@ namespace xIds.DI
|
||||
|
||||
//
|
||||
// Create Authentication Builder ...
|
||||
// var authBuilder = services.AddAuthentication();
|
||||
var authBuilder = services.AddAuthentication();
|
||||
|
||||
//
|
||||
// Create Authentication Builder ...
|
||||
var authBuilder = services.AddAuthentication(options =>
|
||||
{
|
||||
//
|
||||
// Setting Default Authentication Schema ...
|
||||
// For Handling Smart Schema Forwarder ...
|
||||
options.DefaultScheme = XAuthentication.SMART_SCHEME;
|
||||
options.DefaultChallengeScheme = XAuthentication.SMART_SCHEME;
|
||||
options.DefaultAuthenticateScheme = XAuthentication.SMART_SCHEME;
|
||||
})
|
||||
.AddPolicyScheme(
|
||||
authenticationScheme: XAuthentication.SMART_SCHEME,
|
||||
displayName: XAuthentication.SMART_SCHEME,
|
||||
configureOptions: options =>
|
||||
{
|
||||
//
|
||||
// Configure Forward Default Selector ...
|
||||
options.ForwardDefaultSelector = context =>
|
||||
{
|
||||
//
|
||||
// Retrieve XApiKey Header Key ...
|
||||
var apiKeyHeader = XHeader.ApiKey.GetStringValue();
|
||||
// var authBuilder = services.AddAuthentication(options =>
|
||||
// {
|
||||
// //
|
||||
// // Setting Default Authentication Schema ...
|
||||
// // For Handling Smart Schema Forwarder ...
|
||||
// options.DefaultScheme = XAuthentication.SMART_SCHEME;
|
||||
// options.DefaultChallengeScheme = XAuthentication.SMART_SCHEME;
|
||||
// options.DefaultAuthenticateScheme = XAuthentication.SMART_SCHEME;
|
||||
// })
|
||||
// .AddPolicyScheme(
|
||||
// displayName: XAuthentication.SMART_SCHEME,
|
||||
// authenticationScheme: XAuthentication.SMART_SCHEME,
|
||||
// configureOptions: options =>
|
||||
// {
|
||||
// //
|
||||
// // Configure Forward Default Selector ...
|
||||
// options.ForwardDefaultSelector = context =>
|
||||
// {
|
||||
// //
|
||||
// // Retrieve XApiKey Header Key ...
|
||||
// var apiKeyHeader = XHeader.ApiKey.GetStringValue();
|
||||
|
||||
//
|
||||
// If Header Contains Key ...
|
||||
if (context.Request.Headers.ContainsKey(apiKeyHeader))
|
||||
{
|
||||
return XAuthenticationScheme.XApiKey.GetStringValue();
|
||||
}
|
||||
// //
|
||||
// // If Header Contains Key ...
|
||||
// if (context.Request.Headers.ContainsKey(apiKeyHeader))
|
||||
// {
|
||||
// return XAuthenticationScheme.XApiKey.GetStringValue();
|
||||
// }
|
||||
|
||||
//
|
||||
// If not ...
|
||||
return XAuthentication.IDENTITY_SERVER_LOCAL_API;
|
||||
};
|
||||
}
|
||||
);
|
||||
// //
|
||||
// // If not ...
|
||||
// return XAuthentication.IDENTITY_SERVER_LOCAL_API;
|
||||
// };
|
||||
// }
|
||||
// );
|
||||
|
||||
//
|
||||
// authBuilder.AddScheme<AuthenticationSchemeOptions, XApiKeyAuthenticationHandler>(
|
||||
// XAuthenticationScheme.XApiKey.GetStringValue(),
|
||||
// options => { });
|
||||
|
||||
//
|
||||
// Add JwtBearer by Smart Schema ForwardDefaultSelector ...
|
||||
@@ -513,7 +518,7 @@ namespace xIds.DI
|
||||
//
|
||||
policy.AddAuthenticationSchemes(
|
||||
[
|
||||
XAuthenticationScheme.XApiKey.GetStringValue(),
|
||||
// XAuthenticationScheme.XApiKey.GetStringValue(),
|
||||
IdentityServerConstants.LocalApi.AuthenticationScheme
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user