External authentication service or function for some of Netlify hosted files

I am running a site on Netlify. On the site, I am hosting some machine-readable files that should be accessible only with an API key.

Is it possible to have a Netlify function, or similar, which intercepts the HTTP request and checks the key, as an HTTP query parameter, against an external authentication API before serving the URL (file download)?

What other options there is to make files authentication only, using an external authentication service?

I believe this is possible using Netlify Edge Handlers, however it’s still not open for public use.

Instead, you can use Netlify Identity and used Role Based Access Control: Role-based access control with JWT | Netlify Docs. This won’t allow you to check against at external API, but you can redirect users based on their role set in Identity.