Is it possible to secure with JWT the endpoints generated with the Loopback v4 REST CRUD model endpoints generator #8905
Replies: 3 comments 1 reply
-
Hi, have a look at the following: https://loopback.io/doc/en/lb4/Authentication-overview.html https://github.com/loopbackio/loopback4-example-shopping#authentication |
Beta Was this translation helpful? Give feedback.
-
Hi @mrmodise and thank you for your answer. |
Beta Was this translation helpful? Give feedback.
-
I'm looking into this very thing as well and I would extend the discussion to authorization as well (since both authentication and authorization relies on annotations for the controller methods). The following is a working solution but I don't know if it's the favored solution. I'm not part of the loopback team and this has never seen poduction. From my understanding,
Reading about creating a custom CRUD controller in the README, I thought:
Creating a
Registering the controller manually: Under
Now, fetching all the whatevers will give me the following:
And, fetching one whatever by id:
This is mainly bypassing the auto-wiring as in, I don't have a file under |
Beta Was this translation helpful? Give feedback.
-
I have generated a Loopback 4 REST API application for CRUD operations against a relational DB, using the REST CRUD model endpoints generator available in Loopback 4: https://loopback.io/doc/en/lb4/Creating-crud-rest-apis.html
Now I trying to secure the endpoints, according to this: https://loopback.io/doc/en/lb4/Authentication-tutorial.html I should add an authenticate decoration to the class exports in the controller definitions. But in my case there is no such definition in my application, besides the one for the user endpoint.
How can I secure with JWT the endpoints generated with the Loopback v4 REST CRUD model endpoints generator?
Thanks for any suggestion.
Beta Was this translation helpful? Give feedback.
All reactions