1

I have a scenario to implement when there are two authentication options one is Oauth2 and another one is custom header "x-api-key". I want to pass the request to the backend without authorization if only the x-api-key is present. Can this be achieved using a custom filter?

snfrox
  • 124
  • 7

1 Answers1

0

Currently, we don't have any option for this. But you can give a try to write a custom filter including the below code and place it before the Auth filter.

  string X_API_HEADER_NAME = "x-api-key";
  string SKIP_ALL_FILTERS = "skip_filters";

  if (request.hasHeader(X_API_HEADER_NAME)) {
        context.attributes[SKIP_ALL_FILTERS] = true;
    } 
chashikajw
  • 592
  • 5
  • 18
  • tried adding the filter to position 2 and 3 getting Authentication Failure error. in the logs I can see skipping preAuth & analytics filters. any idea? – snfrox Apr 23 '21 at 04:24