Hello,
So i am really confused about all the stuff regarding APIs, authentications etcs.
What i want to achieve:
- API in Laravel, consumed only by my apps
- Frontend made with ReactJS, served from the same Laravel app, in the same domain
- In the future there might be some mobile app
- Users of React/mobile app have access to some public available resources
- Users should be able to register/login in and for example post some articles
- Also they should be able to login with Facebook
So i don't really know what and how to use
I know i can use JWT (https://github.com/tymondesigns/jwt-auth) to authenticate users. Would it be suitable for both React app (served by the laravel itself) and future mobile app ? Can it be used to login with Facebook?
What about Laravel passport?
I don't want any third party apps to consume my API. Or at least i don't care about them. Should i then use passport for authentication? Is it good for authenticating users or clients?
If i want to protect my AP,I so only my apps could consume it, how do i authenticate them?
I can't store client credentials inside client apps...
In this tutorial: http://esbenp.github.io/2017/03/19/modern-rest-api-laravel-part-4/ author writes about authenticating users on different clients. He writes about distinguishing clients and not storing client's id/secret directly in the client app. He proposes to create a proxy in the api backend, so client would communicate to route like 'api/login' and from there it would be passed to passport with client id/secret, but as i understand this approach makes impossible to distinguish the clients and actually anybody can hit 'api/login' route and authenticate regardless of the client app xD
Should i really care about API protection (so that only my apps could consume it) or should i just focus on user authentication with JWT and that would be sufficient?
And what about CSRF? Should i use it with API or not? It is excluded from the api routes by default and then... https://laravel.com/docs/5.6/csrf here they tell to automatically attach CSRF token to every outgoing request in Javascript applications (in my case i believe it would be React served by the Laravel) :)
The more i read the more confused i become.
I really need some clarifications and help, cause i got stuck. Don't know what and how to use to achieve my goals.