Although this may seem complicated, it will be very useful for you to take a look at the Stormpath . For this, we have a fairly simple solution. Please take a look at Using Stormpath for API Authentication .
As a result, your solution will look like this:
- You will use the Stormpath Java SDK to easily delegate all your user management needs.
When the user clicks the login button, your interface will safely send credentials to your backend-end through its REST API.
2.1. By the way, Stormpath significantly expands all the features here. Instead of your own login page, you can fully delegate the login / registration function to Stormpath via IDSite or you can also delegate it to our Servlet plugin . Stormpath also supports Google, Facebook, LinkedIn, and Github login.
Then your backend will try to authenticate the user using the Stormpath Backend and return an access token as a result:
public void postOAuthToken(HttpServletRequest request, HttpServletResponse response) { Application application = client.getResource(applicationRestUrl, Application.class);
Then for each authenticated request, your backend will do:
public void getEquipment(HttpServletRequest request, HttpServletResponse response) { Application application = client.getResource(applicationRestUrl, Application.class); OauthAuthenticationResult result = (OauthAuthenticationResult) application.authenticateOauthRequest(request).execute(); System.out.println(result.getApiKey()); System.out.println(result.getAccount());
Please see here for more information.
Hope this helps!
Disclaimer, I am an active member of the Stormpath.
mario source share