So I'm unfortunately still trying to get a good grasp of the flow my app has to go through to provide authentication. So I plan on making an Angular app with a PHP back-end. To get a JWT, a user will provide their email/password as the body of a HTTP post request that will be made to a PHP file.
Inside that file, the database will be hit to check their credentials, and if they are valid, they will need a JWT provided to them. My question is, how will I send that JWT token to the front-end?
Doing a simple
echo json_encode($jwt)
I imagine would be a bad idea.I could use PHP's setcookie() to send a cookie along with the rest of the HTTP headers. And I could set that cookie as httpOnly to make it even more secure, but I would need to add another cookie to prevent against XSRF attacks.
Once the client actually has the JWT token, I know I could use the Bearer authentication scheme and pass the token inside the Authorization HTTP header, and then the PHP file could grab the token by looking at the header. But could I also use the Bearer authentication scheme and use that Authorization HTTP header to pass the newly created JWT token from the PHP file to Angular?
Sorry if this is a bit confusing. If you have any questions, just post a comment.