I have created a custom graphql APIs , I want to restrict these APIS for unwanted use , How can I restrict access to API'S
Any help is appreciated
Thank you.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI have created a custom graphql APIs , I want to restrict these APIS for unwanted use , How can I restrict access to API'S
Any help is appreciated
Thank you.
I check resources like this in my resolver class. You can assign certain permissions/resources for api integrations that you create in the Magento admin. They'll get an auth code/codes which are sent in headers, and that auth code has permissions to certain acl resources.
use Magento\Framework\AuthorizationInterface;
//...create with di in construct...
//an example you could use in your methods
if (!$this->authorization->isAllowed('--RESOURCE HERE--')) {
throw new \Magento\Framework\Webapi\Exception(__('Forbidden'), 0, 403);
}