(12) Integrate spring cloud architecture - OAuth2.0 login process for SSO single sign-on (2)

The last article is to stand on the shoulders of giants and study OAuth2.0. It is also to quickly help everyone understand OAuth2.0. Without further ado, I drew a simple flow chart based on the summary of the use of OAuth2.0 in the framework (according to the user Name + password to achieve OAuth2.0 login authentication):

 



 The above figure clearly describes the current login process. Now we make related microservices for login, and the analysis is as follows:

Request method: POST
Service URL:  http://localhost:8080/user/login
Parameter type: application/json
Headers: Content-Type: application/json

             Authorization: Basic QXkjkdkYkhfeyKOKKHUM67ejfjeSfnrRdk5nPT0=    
Body:{

       "userName":"admin", --- can also be a mobile phone number, etc.

      "password": "e10adc3949ba59abbe56e057f20f883e"  



Return value type: application/json

Returned result set: {

 "code": "200",

 "message": "Success",

 "version": "v1.0",

 "data": {

   "userInfo": {

     "userId": "00001",

     "pwd": "e10adc3949ba59abbe56e057f20f883e",

     "userName": "admin",

     "mobile": "15875500000",

     "telephone": "",

     "wechat": "",

     "email": "[email protected]",

     "status": "1",

     "createTime": "2017-06-26"

    },

   "roleIds": "100",

   "tokenInfo": {

     "accessToken":"4de55a69-e372-4766-acd3-1c419d6f2fda",

     "tokenType": "bearer",

     "webTokent":"uHSLjfJoQwU4t4PAqCzH1SN0fp7PUWKluPNS+x1dZ8R9Gx+NJkBI7w==",

     "refreshToken":"d3d71594-5c3f-4a68-a7e5-b8d21c4fa73b",

     "expiresIn": 34644,

     "scope": "read write"

    }

  }


Note: You can use the Postman tool for testing.
Framework design ideas: Provide independent commonservice-sso microservices, provide component-sso dependent components, and provide microservice client user-service microservice interfaces for user login.

The entire execution process is as follows: user-service ---> commonservice-sso ---> component-sso
The service gateway has not been explained here, and how to implement service authentication and authentication between the service gateway and sso single sign-on will be involved later. right.

 

From now on, I will record the construction process and essence of the recently developed spring cloud microservice cloud architecture to help more friends who are interested in developing the spring cloud framework. Let's discuss the construction process and how of the spring cloud architecture together. Used in enterprise projects.

Sources of information and source code

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324405225&siteId=291194637
Recommended