Answer the question
In order to leave comments, you need to log in
What is the best way to implement REST API authentication?
Good afternoon,
the task is to write a rest api for an application whose front-end is on Vue, the back-end is on Symfony4
How best to implement API request authentication to prevent requests from being executed by unauthorized users or users who do not have rights to do so.
I mean not ready-made solutions, but some technologies or methods, maybe there are some vendors in Sf for this?
Answer the question
In order to leave comments, you need to log in
I am actively using OIDC + JWT. Auth0 suited me, but if you go beyond the limits, it turns out not very cheap
You can create a subscriber to kernel.request and expand on this idea:
public function onKernelRequest(GetResponseEvent $event)
{
if (false !== strpos($event->getRequest()->getRequestUri(), '/api/')) {
if (!$this->security->isGranted('ROLE_USER')) {
throw new NotFoundHttpException();
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question