// // 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(); // // // // If Header Contains Key ... // if (context.Request.Headers.ContainsKey(apiKeyHeader)) // { // return XAuthenticationScheme.XApiKey.GetStringValue(); // } // // // // If not ... // return XAuthentication.IDENTITY_SERVER_LOCAL_API; // }; // } // ); // // // // For Best Support we Have to Add ApiKey Authentication First ... // if (addApiKeyAuthentication) // { // // // authBuilder // .AddScheme( // XAuthenticationScheme.XApiKey.GetStringValue(), // options => { }); // }