My question is specifically regarding my approach of JWT with REST implementation.
I am using AngularJS on the client side and PHP on server side.
As soon as page loads for the first time, I fire one GET request to server and get signature from web service (encoded signature).
When someone opens the web page, we present login form and when user fills it correctly, we send login information to server in JWT encrypted format:
Header(ALGORITHM & TOKEN TYPE).Payload(Login form data).Signature(Received from the first GET web service call)
Now, after login, we got the exp
i.e. token expire time out data from server. Now we show one more form to the logged in user. It is used to create employees. So, my implementation is:
- We present the form (using angularjs)
- User inputs the data
- System validates the form
- If the form entries are correct then system triggers
addEmployee
webservice. BUT the data we pass inheader authorization bearer
only. For example:
Host: mysite.com
POST: /services/addEmployee
Accept: application/json
Content-Type: application/json
Authorization: Bearer Header(ALGORITHM & TOKEN TYPE).PAYLOAD(Employee form data + EXP token expire time received in the response of login web service).Signature
So, here we don't pass anything on the request body. Even though this is being POST request. And on the server side, we just decode the Bearer and get the payload.
I really don't want to send any data in plain text format. For example, if we send POST data in body then anyone can see what's being passed. I want to encrypt my web services up to some level. Is this approach correct or harmful in anyway?