An open platform authentication and authorization method and device
Through the open platform authentication and authorization method, through the identity verification and token mechanism, the problem of three-party interactive trust and data security under the open interface is solved, multi-channel and full-process verification is realized, and data security is ensured.
Patent Information
- Application Number
- CN202011583242.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-28
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2040-12-28
AI Technical Summary
Under the conditions of open interfaces, how to ensure three-party mutual trust and secure data communication during the interaction between users, open platforms and third parties has become an important issue for Internet companies.
An open platform authentication and authorization method is proposed. It performs identity verification by obtaining the login authorization request of a third-party application, returns a temporary token, and generates an access token based on the temporary token to ensure the legitimacy of the third-party application when calling user information. Match with permissions to achieve multi-channel and full-process verification to ensure the security of interactive data.
It implements a trust mechanism for three-party interaction, ensures the security of interactive data, prevents unauthorized access to user information, and enhances the protection of user information.
Smart Images

Figure CN112613073B
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to an open platform authentication and authorization method and device. Background Art
[0002] With the development of the Internet, the opening of services has become an inevitable trend. Major Internet companies have launched their open platforms one after another, aiming to package their services and resources into data interfaces and open them to third-party companies, so that third-party companies can use various resources of the open platform through open interfaces.
[0003] Under the conditions of open interfaces, how to ensure mutual trust and secure data communication among users, open platforms and third parties during interaction has attracted the attention and importance of major Internet companies and is also the most pressing issue to be addressed. Summary of the invention
[0004] Based on the above requirements, this application proposes an open platform authentication and authorization method and device, which can realize a trust mechanism for three-party interaction and ensure the security of interactive data.
[0005] An open platform authentication and authorization method, applied to an open platform, comprising:
[0006] Obtaining a login authorization request sent by a third-party application, and verifying the identity of the third-party application;
[0007] When the third-party application passes the identity verification, returning a temporary token to the third-party application;
[0008] Receiving an access token acquisition request sent by the third-party application, and sending the access token to the third-party application; wherein the access token acquisition request is generated by the third-party application according to the temporary access token;
[0009] Based on the user information calling request sent by the third-party application, the requested user information is sent to the third-party application; wherein the user information calling request is generated by the third-party application based on the access token.
[0010] Optionally, obtaining a login authorization request sent by a third-party application and verifying the identity of the third-party application includes:
[0011] Obtaining a login authorization request sent by a third-party application, and performing identity verification on the third-party application using the identity information of the third-party application included in the login authorization request;
[0012] Determine whether the user corresponding to the user information requested by the third-party application is logging into the open platform for the first time;
[0013] If it is not the first time to log in to the open platform, when the third-party application identity is verified to be legitimate, confirming that the third-party application has passed the identity verification;
[0014] If it is the first time to log in to the open platform, a user information authorization request is sent to the user terminal so that the user authorizes the third-party application to obtain the user information;
[0015] If the identity of the third-party application is legitimate and the user authorizes the third-party application to obtain user information, it is confirmed that the third-party application has passed the identity verification.
[0016] Optionally, the login authorization request further includes authorization domain information, where the authorization domain information indicates the category of information for which the calling authority is requested;
[0017] The method of obtaining a login authorization request sent by a third-party application and verifying the identity of the third-party application further includes:
[0018] If the user corresponding to the user information requested by the third-party application is not logging into the open platform for the first time, determining whether the authorization domain information in the login authorization request matches the user information calling authority pre-acquired by the third-party application;
[0019] If the identity of the third-party application is legitimate, and the authorization domain information in the login authorization request matches the user information calling authority pre-acquired by the third-party application, confirming that the third-party application has passed the identity verification;
[0020] The sending of the user information authorization request to the user terminal includes:
[0021] Send a user information authorization request including the authorized domain information to the user terminal.
[0022] Optionally, the sending the requested user information to the third-party application based on the user information calling request sent by the third-party application includes:
[0023] Based on the user information calling request sent by the third-party application, determining whether the user information called by the third-party application matches the authorization domain information in the login authorization request;
[0024] If there is a match, the requested user information is sent to the third-party application.
[0025] Optionally, obtaining a login authorization request sent by a third-party application includes:
[0026] Get the login authorization request sent by the third-party application through any one or more channels including PC, mobile application, web H5 page, WeChat public account applet.
[0027] Optionally, the receiving the access token acquisition request sent by the third-party application, and sending the access token to the third-party application includes:
[0028] Receiving an access token acquisition request sent by the third-party application;
[0029] Determine whether a time interval between a time of receiving the access token acquisition request and a time of returning a temporary token to the third-party application is less than a validity period of the temporary token;
[0030] If the time is less than the validity period of the temporary token, the access token is sent to the third-party application.
[0031] An open platform authentication and authorization method, applied to a third-party application, comprising:
[0032] Send a login authorization request to the open platform;
[0033] When receiving the temporary token sent by the open platform, generating an access token acquisition request according to the temporary token;
[0034] Sending the access token acquisition request to the open platform;
[0035] When receiving the access token sent by the open platform, generating a user information call request based on the access token and sending the request to the open platform;
[0036] Receive user information sent by the open platform.
[0037] An open platform authentication and authorization device, applied to an open platform, comprising:
[0038] A request acquisition unit, used to acquire a login authorization request sent by a third-party application and verify the identity of the third-party application;
[0039] A first response unit, configured to return a temporary token to the third-party application when the identity of the third-party application passes the identity verification;
[0040] A second response unit, configured to receive an access token acquisition request sent by the third-party application, and send the access token to the third-party application; wherein the access token acquisition request is generated by the third-party application according to the temporary access token;
[0041] A third response unit is used to send the requested user information to the third-party application based on the user information calling request sent by the third-party application; wherein the user information calling request is generated by the third-party application based on the access token.
[0042] Optionally, the open platform includes: a server session layer, a server interface layer and a server business layer;
[0043] The server session layer is used to implement access control processing for third-party application requests, two-way identity authentication processing for signature verification, anti-replay processing for requests, and encryption and decryption processing for communication data;
[0044] The server interface layer is used to filter and verify request parameters to prevent cross-site request forgery attacks and cross-site scripting attacks;
[0045] The server-side business layer is used to strictly verify third-party application requests and perform real-time verification and blocking of user behaviors through at least input parameter verification, process bypass prevention, password control, token validity period, authorization domain verification, and callback address verification;
[0046] Each unit of the open platform authentication and authorization device realizes its own function by calling the server session layer, and / or the server interface layer, and / or the server business layer of the open platform.
[0047] An open platform authentication and authorization device, applied to third-party applications, comprising:
[0048] A first request sending unit, used to send a login authorization request to the open platform;
[0049] A first receiving unit, configured to generate an access token acquisition request according to the temporary token when receiving the temporary token sent by the open platform;
[0050] A second request sending unit, configured to send the access token acquisition request to the open platform;
[0051] A third request sending unit, configured to, when receiving an access token sent by the open platform, generate a user information calling request based on the access token and send the request to the open platform;
[0052] The second receiving unit is used to receive the user information sent by the open platform.
[0053] In the authentication and authorization process proposed in this application, the identity of the third-party application is verified, and it is set that the third-party application must use a temporary token and an access token to call user information, thereby achieving multi-channel and full-process verification of the third-party application, realizing a trust mechanism for three-party interaction, and ensuring the security of the interactive data. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0055] Figure 1 It is a flowchart of an open platform authentication and authorization method provided in an embodiment of the present application;
[0056] Figure 2 It is a flowchart of another open platform authentication and authorization method provided in an embodiment of the present application;
[0057] Figure 3 It is a processing timing diagram of the open platform authentication and authorization method provided in the embodiment of the present application;
[0058] Figure 4 It is a structural diagram of an open platform authentication and authorization device provided in an embodiment of the present application;
[0059] Figure 5 is a schematic diagram of the open platform structure provided in the embodiment of the present application;
[0060] Figure 6 It is a structural diagram of another open platform authentication and authorization device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0061] The technical solution of the embodiment of the present application is applicable to the three-party interactive application scenario of the user, the open platform and the third-party application based on the open platform. The technical solution of the embodiment of the present application can solve the mutual trust problem among the three parties in the three-party interaction and ensure the security of the interactive data.
[0062] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0063] Before introducing the technical solution of the embodiment of the present application in detail, the relevant terms involved in the text are explained first:
[0064] Open platform: A platform that integrates services and resources and outputs them through a unified interface.
[0065] Third-party applications: The party that accesses the open platform needs to access and call the open platform interface to obtain relevant resource information of users on the open platform.
[0066] OAuth2.0: User authentication and authorization mechanism, used to ensure mutual trust among three parties during the interaction process.
[0067] Authorization domain (Scope): Category subdivision of resource information of users at different dimensions.
[0068] Application ID (APPID): A unique application ID used by third-party applications to access the open platform interface.
[0069] Application secret key (SECRET): A unique application secret key used by third-party applications to access the open platform interface.
[0070] Temporary token (Code): The token returned when the first step of authentication and authorization is completed, valid for 3 minutes.
[0071] Access Token: The token returned when the second step of authentication and authorization is completed, and is valid for 120 minutes.
[0072] Callback address (Redirect_Uri): The callback address after successful authorization, used for parameter verification sent by third-party applications and receiving temporary tokens during redirection.
[0073] Status code (State): The status value defined by the third-party application. It is used by the third-party application to prevent CSRF attacks. It will be returned as is when the callback is called after successful authorization.
[0074] Grant type (Grant_Type): Authentication authorization mode type. This application considers the more mainstream authorization code mode.
[0075] The present application embodiment proposes an open platform authentication and authorization method, which can be applied to the open platform, see Figure 1 As shown, the method includes:
[0076] S101: Obtain a login authorization request sent by a third-party application, and verify the identity of the third-party application.
[0077] Specifically, when a third-party application needs to obtain user information through an open platform, it needs to first log in to the open platform and guide the user to log in to the open platform.
[0078] When a third-party application logs in to the open platform, the login authorization transaction of the open platform is called up, and parameter information such as application identifier, authorization domain, callback address, etc. is passed in according to the message specification to guide the user to log in to the open platform.
[0079] Correspondingly, the open platform obtains the login authorization request sent by the third-party application and verifies the identity of the third-party application.
[0080] When the third-party application passes the identity verification, step S102 is executed to return a temporary token to the third-party application.
[0081] If the third-party application fails the identity verification, step S103 is executed to reject the login authorization request of the third-party application.
[0082] Specifically, when the open platform performs identity verification on the third-party application and determines that the third-party application passes the identity verification, a temporary token code is returned to the third-party application. The validity period of the temporary token is 3 minutes.
[0083] The open platform appends the temporary token to the callback address of the third-party application and redirects it back to the third-party application.
[0084] S104: Receive an access token acquisition request sent by the third-party application, and send the access token to the third-party application.
[0085] The access token acquisition request is generated by the third-party application according to the temporary access token.
[0086] Specifically, when the third-party application receives the information returned by the open platform, the application receives the code parameter in the callback address and calls the open platform access token transaction through the background to exchange for the access token AccessToken. That is, the third-party application generates an access token acquisition request based on the obtained temporary token.
[0087] After receiving the access token acquisition request sent by the third-party application, the open platform sends the access token to the third-party application. The access token is valid for 120 minutes.
[0088] S105. Based on the user information calling request sent by the third-party application, send the requested user information to the third-party application; wherein the user information calling request is generated by the third-party application based on the access token.
[0089] After receiving the access token, the third-party application uses the access token to call the open platform resource service in the background to request user-related information.
[0090] Specifically, the third-party application generates a user information call request based on the received access token and sends it to the open platform. After receiving the user information call request sent by the third-party application, the open platform sends the requested user information to the third-party application.
[0091] The open platform authentication and authorization method described in the embodiment of the present application is an open platform authentication and authorization scheme based on the OAuth2.0 protocol. This protocol can ensure that before a third party obtains user resources, it must be authorized by the user on the open platform. During the interaction, sensitive information such as user account passwords will not be transmitted to the third party. Instead, a time-limited token will be granted to the third party to access data resources, ensuring that the entire interaction process is secure and user-friendly.
[0092] In the authentication and authorization process proposed in the embodiment of the present application, the identity of the third-party application is verified, and it is set that the third-party application must use a temporary token and an access token to call user information, thereby achieving multi-channel and full-process verification of the third-party application, realizing a trust mechanism for three-party interaction, and ensuring the security of the interactive data.
[0093] As an exemplary implementation, the open platform obtains a login authorization request sent by a third-party application and verifies the identity of the third-party application, specifically including:
[0094] Obtaining a login authorization request sent by a third-party application, and performing identity verification on the third-party application using the identity information of the third-party application included in the login authorization request;
[0095] At the same time, it is determined whether the user corresponding to the user information requested by the third-party application is logging into the open platform for the first time.
[0096] If it is not the first time to log in to the open platform, when the third-party application identity is verified to be legitimate, it is confirmed that the third-party application has passed the identity verification.
[0097] If it is the first time to log in to the open platform, a user information authorization request is sent to the user terminal so that the user authorizes the third-party application to obtain user information.
[0098] Specifically, the user information authorization request is pushed to the user end in the form of an authorization page. The authorization page pops up on the user end. The user clicks confirm to continue the authorization process. If the user refuses, the authorization process is interrupted.
[0099] If the open platform verifies that the identity of the third-party application is legitimate, and the user authorizes the third-party application to obtain its user information, the open platform confirms that the third-party application has passed the identity verification.
[0100] Furthermore, when constructing the authorization domain Scope, the embodiment of the present application fully considers the user's resources of different dimensions and performs resource segmentation. As shown in Table 1 below, the divided authorization domains mainly include eight categories of authorization domain information, including openid (user ID), low privacy, medium privacy, name, mobile phone number, ID, customer number, and card list. When a third party seeks access to the open platform, the authorization domain is allocated to the third party according to business scenario requirements.
[0101] Table 1
[0102] Scope Name describe Specific content cardlist Bank card list data Read the user's bank card list information OpenID User openid information Read the user's openid low Low privacy data Read the user's nickname and other information mid Privacy data Read the user's address, email address, etc. phone Mobile phone number data Read the user's mobile phone number name Name data Read the user's name certnum Document data Read the user's ID number custinfo Customer Number Read the user's client ID
[0103] Specifically, the login authorization request sent by the third-party application to the open platform includes the authorization domain information for which the third-party application hopes to obtain the calling authority.
[0104] When the open platform obtains the login authorization request sent by the third-party application and verifies the identity of the third-party application, it not only verifies the identity information of the third-party application, but also performs the following processing:
[0105] If the user whose user information is requested by the third-party application is not logging into the open platform for the first time, the open platform determines whether the authorization domain information in the received login authorization request matches the user information calling authority pre-obtained by the third-party application, that is, whether the third-party application has pre-obtained the calling authority of the authorization domain corresponding to the requested user information.
[0106] If the identity of the third-party application is legitimate, and the authorization domain information in the login authorization request matches the user information calling authority pre-acquired by the third-party application, it is confirmed that the third-party application has passed the identity verification.
[0107] If the user whose user information is requested by the third-party application is logging into the open platform for the first time, the open platform sends a user information authorization request to the user terminal, specifically, a user information authorization request containing the above-mentioned authorization domain information is sent to the user terminal, so as to request the user to agree that the third-party application obtains the user information within the authorization domain of the user.
[0108] At the same time, when the open platform sends the requested user information to the third-party application based on the user information call request sent by the third-party application, it is determined whether the user information requested to be called by the third-party application matches the authorization domain information in the login authorization request based on the user information call request sent by the third-party application;
[0109] If there is a match, the requested user information is sent to the third-party application.
[0110] Specifically, the open platform determines whether the user information requested by the third-party application is the user information within the authorized domain for which it is authorized, that is, whether it is the user information within the authorized domain in the login authorization request sent by it.
[0111] If the user information is within the scope of the authorization domain, that is, the user information requested by the third-party application, matches the authorization domain information in the login authorization request, the open platform sends the requested user information to the third-party application.
[0112] If the user information is not within the scope of the authorized domain, the open platform will reject the user information call request from the third-party application.
[0113] It can be seen that based on the above-mentioned authorization domain division in the embodiment of the present application, the open platform can perform permission verification on third-party applications in a more detailed manner to prevent third-party applications from arbitrarily calling user information, thereby ensuring the security of user information.
[0114] As an exemplary implementation method, the open platform authentication and authorization method proposed in the embodiment of the present application can be applied to a variety of authentication and authorization scenarios, such as PC application authorization, mobile APP authorization, QR code scanning authorization, mobile APP embedded H5 page authorization, WeChat public account authorization, etc.
[0115] Then, the open platform obtains the login authorization request sent by the third-party application, which can be obtained by obtaining the login authorization request sent by the third-party application through any one or more channels including PC, mobile application, web H5 page, WeChat public account applet.
[0116] As a preferred implementation, since the temporary token issued by the open platform to the third-party application is time-limited, when the open platform receives the access token acquisition request sent by the third-party application and sends the access token to the third-party application, it first receives the access token acquisition request sent by the third-party application, and then determines whether the time interval between the moment of receiving the access token acquisition request and the moment of returning the temporary token to the third-party application is less than the effective duration of the temporary token. In other words, it determines whether the temporary token is still within the validity period when the access token acquisition request is received.
[0117] If it is less than the valid time of the temporary token, that is, the temporary token is still within the validity period, the access token is sent to the third-party application.
[0118] If it is not less than the validity period of the temporary token, that is, when the access token acquisition request is received, the temporary token has expired, the open platform refuses to send the access token to the third-party application.
[0119] Correspondingly, since the access token issued by the open platform to the third-party application is also time-limited, when the open platform sends the requested user information to the third-party application based on the user information call request sent by the third-party application, it can also further verify whether the access token of the third-party application is within the validity period when receiving the user information call request sent by the third-party application. If it is within the validity period, the requested user information is sent to the third-party application; if it has expired, the user information call request of the third-party application is rejected.
[0120] The present application embodiment also proposes another open platform authentication and authorization method, which can be applied to third-party applications. Figure 2 As shown, the method includes:
[0121] S201. Send a login authorization request to the open platform.
[0122] Specifically, when a third-party application needs to obtain user information through an open platform, it needs to first log in to the open platform and guide the user to log in to the open platform.
[0123] When a third-party application logs in to the open platform, it calls the login authorization transaction of the open platform, sends a login authorization request to the development platform, and passes in parameter information such as application identifier, authorization domain, callback address, etc. according to the message specification.
[0124] When the temporary token sent by the open platform is received, step S202 is executed to generate an access token acquisition request according to the temporary token.
[0125] If the temporary token sent by the open platform is not received, the process may return to step S201 and resend a login authorization request to the open platform, or wait.
[0126] S203: Send the access token acquisition request to the open platform.
[0127] Specifically, since the temporary token has a validity period limit, the third-party application should generate an access token acquisition request within the validity period of the temporary token and send the access token acquisition request to the open platform.
[0128] If the open platform does not return a temporary token after the third-party application sends a login authorization request, it may be that the open platform did not receive the request or the request was not allowed. At this time, the third-party application can send the login authorization request again, or resend a new login authorization request, or continue to wait.
[0129] When the access token sent by the open platform is received, step S204 is executed to generate a user information calling request based on the access token and send the request to the open platform.
[0130] If the access token sent by the open platform is not received, the process returns to step S201 and resends the access token acquisition request to the open platform, or waits.
[0131] After receiving the access token, the third-party application uses the access token to call the open platform resource service in the background to request user-related information. Specifically, the third-party application generates a user information call request based on the received access token and sends it to the open platform.
[0132] If the open platform does not return an access token after the third-party application sends a request to obtain an access token, it may be that the open platform did not receive the request or the request was not allowed. At this time, the third-party application can send the access token request again or continue to wait.
[0133] S205: Receive user information sent by the open platform.
[0134] Specifically, after receiving the user information call request sent by the third-party application, the open platform sends the requested user information to the third-party application. The third-party application receives the user information sent by the open platform, thus completing the three-party interaction process of the user information call.
[0135] The open platform authentication and authorization method described in the embodiment of the present application is an open platform authentication and authorization scheme based on the OAuth2.0 protocol. This protocol can ensure that before a third party obtains user resources, it must be authorized by the user on the open platform. During the interaction, sensitive information such as user account passwords will not be transmitted to the third party. Instead, a time-limited token will be granted to the third party to access data resources, ensuring that the entire interaction process is secure and user-friendly.
[0136] In the authentication and authorization process proposed in the embodiment of the present application, the identity of the third-party application is verified, and it is set that the third-party application must use a temporary token and an access token to call user information, thereby achieving multi-channel and full-process verification of the third-party application, realizing a trust mechanism for three-party interaction, and ensuring the security of the interactive data.
[0137] It should be noted that the above-mentioned open platform authentication and authorization method applied to the open platform and the open platform authentication and authorization method applied to third-party applications have corresponding processing flows. Therefore, the specific processing contents of the above-mentioned two open platform authentication and authorization methods can refer to each other, and the embodiments of this application will no longer be separately introduced one by one.
[0138] In addition, it can be seen from the above introduction that the open platform authentication and authorization method proposed in the embodiment of the present application actually requires the open platform to interact with the third-party application to realize mutual trust information interaction. The following briefly introduces the specific processing flow of the open platform authentication and authorization method proposed in the embodiment of the present application in the form of interaction between the open platform and the third-party application.
[0139] See also Figure 3 As shown, the processing flow of the open platform authentication and authorization method proposed in the embodiment of the present application is as follows:
[0140] ① The third-party page initiates the open platform login authorization transaction, and passes in parameter information such as appid, scope, callback address, etc. according to the message specification to guide the user to log in;
[0141] ② The open platform performs third-party identity verification. If the user logs in for the first time, an authorization page will pop up to prompt the user to authorize the application. If the user clicks confirm, the authorization process will continue. If the user refuses, the authorization process will be interrupted.
[0142] ③After the open platform verifies the third-party information, it will return a temporary token code, which is valid for 3 minutes;
[0143] ④ The open platform appends the temporary token to the third-party callback address and redirects back to the third-party application page;
[0144] ⑤ The third-party application receives the code parameter in the callback address and calls the open platform access token transaction through the background to exchange for the access token AccessToken. The access token is valid for 120 minutes;
[0145] ⑥ After the third party receives the access token, the backend calls the open platform resource service through the access token to obtain user-related information.
[0146] The present application also provides an open platform authentication and authorization device, which can be applied to the open platform, see Figure 4 As shown, the device comprises:
[0147] The request acquisition unit 100 is used to acquire a login authorization request sent by a third-party application and verify the identity of the third-party application;
[0148] The first response unit 110 is configured to return a temporary token to the third-party application when the identity of the third-party application passes the identity verification;
[0149] The second response unit 120 is used to receive the access token acquisition request sent by the third-party application, and send the access token to the third-party application; wherein the access token acquisition request is generated by the third-party application according to the temporary access token;
[0150] The third response unit 130 is used to send the requested user information to the third-party application based on the user information calling request sent by the third-party application; wherein the user information calling request is generated by the third-party application based on the access token.
[0151] Optionally, obtaining a login authorization request sent by a third-party application and verifying the identity of the third-party application includes:
[0152] Obtaining a login authorization request sent by a third-party application, and performing identity verification on the third-party application using the identity information of the third-party application included in the login authorization request;
[0153] Determine whether the user corresponding to the user information requested by the third-party application is logging into the open platform for the first time;
[0154] If it is not the first time to log in to the open platform, when the third-party application identity is verified to be legitimate, confirming that the third-party application has passed the identity verification;
[0155] If it is the first time to log in to the open platform, a user information authorization request is sent to the user terminal so that the user authorizes the third-party application to obtain the user information;
[0156] If the identity of the third-party application is legitimate and the user authorizes the third-party application to obtain user information, it is confirmed that the third-party application has passed the identity verification.
[0157] Optionally, the login authorization request further includes authorization domain information, where the authorization domain information indicates the category of information for which the calling authority is requested;
[0158] The method of obtaining a login authorization request sent by a third-party application and verifying the identity of the third-party application further includes:
[0159] If the user corresponding to the user information requested by the third-party application is not logging into the open platform for the first time, determining whether the authorization domain information in the login authorization request matches the user information calling authority pre-acquired by the third-party application;
[0160] If the identity of the third-party application is legitimate, and the authorization domain information in the login authorization request matches the user information calling authority pre-acquired by the third-party application, confirming that the third-party application has passed the identity verification;
[0161] The sending of the user information authorization request to the user terminal includes:
[0162] Send a user information authorization request including the authorized domain information to the user terminal.
[0163] Optionally, the sending the requested user information to the third-party application based on the user information calling request sent by the third-party application includes:
[0164] Based on the user information calling request sent by the third-party application, determining whether the user information called by the third-party application matches the authorization domain information in the login authorization request;
[0165] If there is a match, the requested user information is sent to the third-party application.
[0166] Optionally, obtaining a login authorization request sent by a third-party application includes:
[0167] Get the login authorization request sent by the third-party application through any one or more channels including PC, mobile application, web H5 page, WeChat public account applet.
[0168] Optionally, the receiving the access token acquisition request sent by the third-party application, and sending the access token to the third-party application includes:
[0169] Receiving an access token acquisition request sent by the third-party application;
[0170] Determine whether a time interval between a time of receiving the access token acquisition request and a time of returning a temporary token to the third-party application is less than a validity period of the temporary token;
[0171] If the time is less than the validity period of the temporary token, the access token is sent to the third-party application.
[0172] The above-mentioned open platform bears important security responsibilities, which are mainly reflected in two aspects: first, to ensure that legitimate third parties can safely obtain user information through the authentication and authorization process; second, to prevent third parties or other attackers from bypassing the authentication and authorization process to obtain resource information by illegal means. Therefore, this application uses the above-mentioned open platform to protect the security of user authorization data from three dimensions, namely, server session layer security, server interface layer security, and server business layer security.
[0173] See also Figure 5 As shown, the open platform includes: a server session layer, a server interface layer and a server business layer;
[0174] The server session layer is used to implement access control processing for third-party application requests, two-way identity authentication processing for signature verification, anti-replay processing for requests, and encryption and decryption processing for communication data;
[0175] The server interface layer is used to perform xss, csrf and other filtering checks on request parameters to prevent cross-site request forgery attacks and cross-site scripting attacks;
[0176] The service-side business layer is used to strictly verify third-party application requests through at least input parameter verification, process bypass prevention, password control, token validity period, authorization domain verification, and callback address verification, and to verify and block user behavior in real time through anti-fraud and other verification methods;
[0177] Each unit of the open platform authentication and authorization device realizes its own function by calling the server session layer, and / or the server interface layer, and / or the server business layer of the open platform.
[0178] Specifically, for the specific working contents of each unit of the above-mentioned open platform authentication and authorization device, please refer to the embodiment of the above-mentioned open platform authentication and authorization method, which will not be repeated here.
[0179] Another embodiment of the present application also provides another open platform authentication and authorization device, which is applied to third-party applications, see Figure 6 As shown, the device comprises:
[0180] The first request sending unit 200 is used to send a login authorization request to the open platform;
[0181] The first receiving unit 210 is configured to generate an access token acquisition request according to the temporary token when receiving the temporary token sent by the open platform;
[0182] A second request sending unit 220, configured to send the access token acquisition request to the open platform;
[0183] A third request sending unit 230 is used to generate a user information calling request based on the access token when receiving the access token sent by the open platform, and send the request to the open platform;
[0184] The second receiving unit 240 is configured to receive user information sent by the open platform.
[0185] Specifically, the specific working contents of each unit of the open platform authentication and authorization device can be found in the above-mentioned embodiment of the open platform authentication and authorization method, which will not be described in detail here.
[0186] For the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0187] It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0188] The steps in the methods of each embodiment of the present application can be adjusted in order, combined and deleted according to actual needs, and the technical features recorded in each embodiment can be replaced or combined.
[0189] The modules and sub-modules in the devices and terminals of the various embodiments of the present application can be combined, divided and deleted according to actual needs.
[0190] In the several embodiments provided in the present application, it should be understood that the disclosed terminals, devices and methods can be implemented in other ways. For example, the terminal embodiments described above are only schematic, for example, the division of modules or submodules is only a logical function division, and there may be other division methods in actual implementation, for example, multiple submodules or modules can be combined or integrated into another module, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0191] The modules or submodules described as separate components may or may not be physically separated, and the components of the modules or submodules may or may not be physical modules or submodules, that is, they may be located in one place, or they may be distributed on multiple network modules or submodules. Some or all of the modules or submodules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0192] In addition, each functional module or submodule in each embodiment of the present application may be integrated into one processing module, or each module or submodule may exist physically separately, or two or more modules or submodules may be integrated into one module. The above-mentioned integrated modules or submodules may be implemented in the form of hardware or in the form of software functional modules or submodules.
[0193] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0194] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly by hardware, software units executed by a processor, or a combination of the two. The software units may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0195] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0196] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An open platform authentication and authorization method, characterized in that: Applied to an open platform, the method comprises: Obtaining a login authorization request sent by a third-party application, and verifying the identity of the third-party application; When the third-party application passes the identity verification, returning a temporary token to the third-party application; Receiving an access token acquisition request sent by the third-party application, and sending the access token to the third-party application; wherein the access token acquisition request is generated by the third-party application according to the temporary token; Based on the user information call request sent by the third-party application, sending the requested user information to the third-party application; wherein the user information call request is generated by the third-party application based on the access token; The obtaining of the login authorization request sent by the third-party application and verifying the identity of the third-party application includes: Obtaining a login authorization request sent by a third-party application, and performing identity verification on the third-party application using the identity information of the third-party application included in the login authorization request; Determine whether the user corresponding to the user information requested by the third-party application is logging into the open platform for the first time; If it is not the first time to log in to the open platform, when the third-party application identity is verified to be legitimate, confirming that the third-party application has passed the identity verification; If it is the first time to log in to the open platform, a user information authorization request is sent to the user terminal so that the user authorizes the third-party application to obtain the user information; If the identity of the third-party application is legitimate and the user authorizes the third-party application to obtain user information, confirming that the third-party application has passed the identity verification; The login authorization request also includes authorization domain information, and the authorization domain information indicates the category of information for which the calling authority is requested; The obtaining of the login authorization request sent by the third-party application and verifying the identity of the third-party application further includes: If the user corresponding to the user information requested by the third-party application is not logging into the open platform for the first time, determining whether the authorization domain information in the login authorization request matches the user information calling authority pre-acquired by the third-party application; If the identity of the third-party application is legitimate, and the authorization domain information in the login authorization request matches the user information calling authority pre-acquired by the third-party application, confirming that the third-party application has passed the identity verification; The sending of the user information authorization request to the user terminal includes: Send a user information authorization request including the authorized domain information to the user terminal.
2. The method according to claim 1, characterized in that The sending the requested user information to the third-party application based on the user information calling request sent by the third-party application includes: Based on the user information calling request sent by the third-party application, determining whether the user information called by the third-party application matches the authorization domain information in the login authorization request; If there is a match, the requested user information is sent to the third-party application.
3. The method according to claim 1, characterized in that The obtaining of the login authorization request sent by the third-party application includes: Get the login authorization request sent by the third-party application through any one or more channels including PC, mobile application, web H5 page, WeChat public account applet.
4. The method according to claim 1, characterized in that The receiving the access token acquisition request sent by the third-party application and sending the access token to the third-party application includes: Receiving an access token acquisition request sent by the third-party application; Determine whether a time interval between a time of receiving the access token acquisition request and a time of returning a temporary token to the third-party application is less than a validity period of the temporary token; If the time is less than the validity period of the temporary token, the access token is sent to the third-party application.
5. An open platform authentication and authorization method, characterized in that: Applied to third-party applications, the method includes: Sending a login authorization request to the open platform, so that the open platform verifies the identity of the third-party application according to the login authorization request; When receiving the temporary token sent by the open platform, generating an access token acquisition request according to the temporary token; Sending the access token acquisition request to the open platform; When receiving the access token sent by the open platform, generating a user information call request based on the access token and sending the request to the open platform; Receiving user information sent by the open platform; The open platform verifies the identity of the third-party application according to the login authorization request, including: Obtaining a login authorization request sent by a third-party application, and performing identity verification on the third-party application using the identity information of the third-party application included in the login authorization request; Determine whether the user corresponding to the user information requested by the third-party application is logging into the open platform for the first time; If it is not the first time to log in to the open platform, when the third-party application identity is verified to be legitimate, confirming that the third-party application has passed the identity verification; If it is the first time to log in to the open platform, a user information authorization request is sent to the user terminal so that the user authorizes the third-party application to obtain the user information; If the identity of the third-party application is legitimate and the user authorizes the third-party application to obtain user information, confirming that the third-party application has passed the identity verification; The login authorization request also includes authorization domain information, and the authorization domain information indicates the category of information for which the calling authority is requested; The open platform verifies the identity of the third-party application according to the login authorization request, further comprising: If the user corresponding to the user information requested by the third-party application is not logging into the open platform for the first time, determining whether the authorization domain information in the login authorization request matches the user information calling authority pre-acquired by the third-party application; If the identity of the third-party application is legitimate, and the authorization domain information in the login authorization request matches the user information calling authority pre-acquired by the third-party application, confirming that the third-party application has passed the identity verification; The sending of the user information authorization request to the user terminal includes: Send a user information authorization request including the authorized domain information to the user terminal.
6. An open platform authentication and authorization device, characterized in that: Applied to an open platform, the device comprises: A request acquisition unit, used to acquire a login authorization request sent by a third-party application and verify the identity of the third-party application; A first response unit, configured to return a temporary token to the third-party application when the identity of the third-party application passes the identity verification; A second response unit, configured to receive an access token acquisition request sent by the third-party application, and send the access token to the third-party application; wherein the access token acquisition request is generated by the third-party application according to the temporary token; A third response unit is configured to send the requested user information to the third-party application based on the user information call request sent by the third-party application; wherein the user information call request is generated by the third-party application based on the access token; The request acquisition unit is specifically used for: Obtaining a login authorization request sent by a third-party application, and performing identity verification on the third-party application using the identity information of the third-party application included in the login authorization request; Determine whether the user corresponding to the user information requested by the third-party application is logging into the open platform for the first time; If it is not the first time to log in to the open platform, when the third-party application identity is verified to be legitimate, confirming that the third-party application has passed the identity verification; If it is the first time to log in to the open platform, a user information authorization request is sent to the user terminal so that the user authorizes the third-party application to obtain the user information; If the identity of the third-party application is legitimate and the user authorizes the third-party application to obtain user information, confirming that the third-party application has passed the identity verification; The login authorization request also includes authorization domain information, and the authorization domain information indicates the category of information for which the calling authority is requested. The request obtaining unit is further used to: If the user corresponding to the user information requested by the third-party application is not logging into the open platform for the first time, determining whether the authorization domain information in the login authorization request matches the user information calling authority pre-acquired by the third-party application; If the identity of the third-party application is legitimate, and the authorization domain information in the login authorization request matches the user information calling authority pre-acquired by the third-party application, confirming that the third-party application has passed the identity verification; The request acquisition unit is specifically used for: Send a user information authorization request including the authorized domain information to the user terminal.
7. The device according to claim 6, characterized in that The open platform includes: a server session layer, a server interface layer and a server business layer; The server session layer is used to implement access control processing for third-party application requests, two-way identity authentication processing for signature verification, anti-replay processing for requests, and encryption and decryption processing for communication data; The server interface layer is used to filter and verify request parameters to prevent cross-site request forgery attacks and cross-site scripting attacks; The server-side business layer is used to strictly verify third-party application requests and perform real-time verification and blocking of user behaviors through at least input parameter verification, process bypass prevention, password control, token validity period, authorization domain verification, and callback address verification; Each unit of the open platform authentication and authorization device realizes its own function by calling the server session layer, and / or the server interface layer, and / or the server business layer of the open platform.
8. An open platform authentication and authorization device, characterized in that: Applied to third-party applications, the device includes: A first request sending unit, configured to send a login authorization request to the open platform, so that the open platform verifies the identity of the third-party application according to the login authorization request; A first receiving unit, configured to generate an access token acquisition request according to the temporary token when receiving the temporary token sent by the open platform; A second request sending unit, configured to send the access token acquisition request to the open platform; A third request sending unit, configured to, when receiving an access token sent by the open platform, generate a user information calling request based on the access token and send the request to the open platform; A second receiving unit, configured to receive user information sent by the open platform; The open platform verifies the identity of the third-party application according to the login authorization request, including: Obtaining a login authorization request sent by a third-party application, and performing identity verification on the third-party application using the identity information of the third-party application included in the login authorization request; Determine whether the user corresponding to the user information requested by the third-party application is logging into the open platform for the first time; If it is not the first time to log in to the open platform, when the third-party application identity is verified to be legitimate, confirming that the third-party application has passed the identity verification; If it is the first time to log in to the open platform, a user information authorization request is sent to the user terminal so that the user authorizes the third-party application to obtain the user information; If the identity of the third-party application is legitimate and the user authorizes the third-party application to obtain user information, confirming that the third-party application has passed the identity verification; The login authorization request also includes authorization domain information, and the authorization domain information indicates the category of information for which the calling authority is requested; The open platform verifies the identity of the third-party application according to the login authorization request, further comprising: If the user corresponding to the user information requested by the third-party application is not logging into the open platform for the first time, determining whether the authorization domain information in the login authorization request matches the user information calling authority pre-acquired by the third-party application; If the identity of the third-party application is legitimate, and the authorization domain information in the login authorization request matches the user information calling authority pre-acquired by the third-party application, confirming that the third-party application has passed the identity verification; The sending of the user information authorization request to the user terminal includes: Send a user information authorization request including the authorized domain information to the user terminal.
