What is the best way to protect an API? #655
Unanswered
sammyskills
asked this question in
Q&A
Replies: 1 comment 7 replies
-
Maybe I'm not understanding the question well, but if you want to protect your API, |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
From the docs, Shield🛡️ provides a way to generate an access token (or tokens) which will be checked on all incoming requests as set in the filter. This works well if you assume that "you know where the request is originating from". For example, from a mobile app or third-party app.
But what about cases where the API is created, but you want to limit access to the API routes to only specific or predetermined sources?
See this scenario:
Now, what if, before the authentication, I don't want everyone to have access to the endpoints? Like putting an extra security somewhere that checks if this request is coming from an approved source, something along the lines of
API_KEY
to be added to theBEARER
token that is checked in the header?If this is okay, what are the best ways to achieving something like this?
I understand that I'll have to create an store the
API_KEY
somewhere (database, as an environment variable, etc), but what is the best way to add the extra check:Thank you.
Beta Was this translation helpful? Give feedback.
All reactions