Hey there,
I have created a project and right now, I am a bit lost. Therefore, I am seeking for help here.
Currently, I have implemented a stateless API with Laravel Sanctum. Why is my API stateless? Because I want to make use of my API with an SPA as well as a native mobile App for iOS and Android. My project/API is capable of very standardized CRUD functionalities such as registering, login, submitting posts, commenting on posts, liking and disliking posts etc...
However, I am starting to ask myself if that was the right way. Because the reason for this is the CORS protection and the XSS Injection problem.
I do have a few questions which would help me to understand my problem:
- Do I need CSRF/CORS protection for my API?
- If CSRF/CORS protection is necessary, can I implement that into my stateless Laravel Sanctum API?
- Can I also make use of a stateful API when implementing an API for both, SPA and native mobile Apps, and which are the advantages of a stateful API?
- The token which is being issued by Laravel Sanctum does not expire by default. Are there any security concerns about an infinite valid token?
- Would it be a better idea to use Laravel Passport and implement an OAuth 2 authentication to be used by an SPA and native mobile apps?
Kind regards and thank you!