Backend Api Key Authorization
Hi,
I'm trying to figure out how api key authorization works. I'm trying to follow this doc
But looks like the the instructions are quite inadequate. The example in the doc doesn't even compile, there is no setController method in Ruoute and RouteCollection add api is not correctly used. Is there a fully functional example somewhere where the Glue backend api utilizes api keys to a custom api endpoint?
Answers
-
Hey!
Sorry for the broken documentation. We are currently fixing it.Indeed there is no
setController()
method and controller and action should be injected viasetDefault()
methodCurrently the only working example of API Key usage is Data Exchange API functionality. This is not the best example due to the fact that we prepare a route in a model and not in the plugin itself, but it should give a hint how it should work.
By integrating API code functionality and adding
->setDefault(static::STRATEGIES_AUTHORIZATION, [static::STRATEGY_AUTHORIZATION_API_KEY])
to your custom rout definition, it should allow you to useX-Api-Key
header orapi_key
URL parameter in order to get access for your resource.Also I want to add, that currently OOTB only custom routes support this and for regular resources it's not possible yet to use API Key.
Thank you for your post and sorry that documentation was not correct. We are fixing it right now.
5 -
I noticed a @deprecated flag while following the setup guide
In vendor/spryker/authorization/src/Spryker/Zed/Authorization/AuthorizationConfig.php
@deprecated Will be removed with next major. Multistrategy authorization is not supported anymore.
What do you have planned for protecting endpoints with an API key?
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 69 Spryker News
- 899 Developer Corner
- 760 Spryker Development
- 83 Spryker Dev Environment
- 361 Spryker Releases
- 3 Oryx frontend framework
- 34 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 24 Job Opportunities
- 3.2K 📜 Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 68 Spryker Safari Questions
- 50 Random