title: Custom authentication asp.net core web api
body: <p>I want to use a secret key (api key) authorization asp.net core web api. The key will be passed in Authorization header like given below,</p>
  
  <pre><code>ex. Authorization keytype;h43484344343bbhfdjfdfhj34343
  </code></pre>
  
  <p>I want to write a middleware to read this key from request headers and call an internal api to validate the key.</p>
  
  <p>In web api we can write a message handler to do this, but I am new to asp.net core. I'm seeing a lot of samples but they are using inbuilt JWT token authentication. But I wanted to use my own key and I decrypt this key and validate against a database entry.</p>
  
  <p>Can anyone suggest some code samples on how to do this?</p>