Auth custom using IAuthenticationFilter and AuthorizeAttribute

public class AuthenticationServiceAttribute : IAuthenticationFilter { public AuthenticationServiceAttribute() { } public async Task AuthenticateAsync(HttpAuthenticationContext actionContext, CancellationToken cancellationToken) { if (actionContext.Request.Headers.Authorization != null) { var cacheResponse = _memoryProvider.Get<MYCLASS>(“key”); if (cacheResponse != null) { await Validate(cacheResponse.access_token, actionContext.Request.Headers.Authorization.Parameter.ToString(), actionContext); return; } else { AuthTokenEntity serviceToken = null; using (var client = new HttpClient()) { client.BaseAddress = new Uri(ConfigurationManager.AppSettings[“AuthBaseAddress”]);… Read More Auth custom using IAuthenticationFilter and AuthorizeAttribute

caching – memory

public interface ICache { /// <summary> /// Retrieve cached item /// </summary> /// <typeparam name=”T”>Type of cached item</typeparam> /// <param name=”key”>Name of cached item</param> /// <returns>Cached value. Default(T) if item doesn’t exist.</returns> T Get<T>(string key); /// <summary> /// Insert value into the cache using appropriate name/value pairs /// Use predefined cache duration with absolute expiration… Read More caching – memory

add custom swagger header

Yes you can do it via inheriting from IOperationFilter You can find the answer on github here: AddRequiredHeaderParameter public class AddRequiredHeaderParameter : IOperationFilter { public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription) { if (operation.parameters == null) operation.parameters = new List<Parameter>(); operation.parameters.Add(new Parameter { name = “X-User-Token”, @in = “header”, type = “string”, required = false });… Read More add custom swagger header