Resource authorization method, device, electronic device and readable storage medium
By generating a key based on the original key and the identity of the person being shared on the first terminal device, and generating a token for authentication, the problem of key leakage during resource sharing in the RBAC solution is solved, and the security and safety of resource authorization are achieved. Efficiency.
Patent Information
- Application Number
- CN202010996233.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-21
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2040-09-21
AI Technical Summary
Existing role-based access control (RBAC) solutions can easily lead to the leakage of the original keys of shared resources when sharing resources, and lack an effective key management mechanism.
By generating a key based on the original key and the identity of the person being shared on the first terminal device, a token is generated for authentication, avoiding direct exposure of the original key. When the authentication is passed, the server authorizes resources to the person being shared, ensuring that the password is authenticated. The key is not disclosed.
It effectively avoids the leakage of resource original keys, improves the security of the resource authorization process, reduces the pressure on the database, and supports authorization management of large-scale IoT devices.
Smart Images

Figure CN114254332B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet of Things, and more specifically, to a resource authorization method, device, electronic device and readable storage medium. Background Art
[0002] For the management of resource sharing authorization, existing solutions are generally incorporated into the access control system for management. The most common access control solution is RBAC (Role-Based Access Control). First, the scope of the role's authority is defined (what kind of operation authority is granted to which resources), and then the role is assigned to the user. The user's access rights to the resource are determined based on the role he plays. Based on this solution, the resource manager can successfully share the resource by granting the sharee a role with resource management authority. RBAC-based access control only defines the authority control for resource sharing, but the original key of the shared resource may be leaked. Summary of the invention
[0003] The embodiments of the present application provide a resource authorization method, device, electronic device and readable storage medium to solve the problem of leakage of the original key of the shared resource.
[0004] In a first aspect, an embodiment of the present application provides a resource authorization method, which is applied to a first terminal device, including:
[0005] Sending an authentication request to a server, the authentication request including a first token generated according to a first key or a second token generated according to a first original key of a shared resource, wherein the first key is a key generated according to the first original key and an identifier of a sharee;
[0006] Receive a first authentication result sent by the server in response to the authentication request, wherein the first authentication result is an authentication result obtained by the server based on the first token or the second token, and the first authentication result includes authentication passed or authentication failed. When the first authentication result is authentication passed, the server authorizes the shared resource to the sharee or the sharer of the shared resource.
[0007] In a second aspect, an embodiment of the present application further provides a resource authorization method, which is applied to a server, comprising:
[0008] Receiving an authentication request sent by a first terminal device, the authentication request including a first token generated by the first terminal device according to a first key or a second token generated according to a first original key of a shared resource, wherein the first key is a key generated by the first terminal device according to the first original key and an identifier of a shared resource;
[0009] In response to the authentication request, performing authentication based on the first token or the second token to obtain a first authentication result, wherein the first authentication result includes authentication passed or authentication failed, and when the first authentication result is authentication passed, authorizing the shared resource to the sharee or the sharer of the shared resource;
[0010] Send the first authentication result to the first terminal device.
[0011] In a third aspect, an embodiment of the present application further provides a first terminal device, including:
[0012] a sending module, configured to send an authentication request to a server, wherein the authentication request includes a first token generated according to a first key or a second token generated according to a first original key of a shared resource, wherein the first key is a key generated according to the first original key and an identifier of a sharee;
[0013] The first receiving module is used to receive a first authentication result sent by the server in response to the authentication request, wherein the first authentication result is an authentication result obtained by the server based on the first token or the second token, and the first authentication result includes authentication passed or authentication failed. When the first authentication result is authentication passed, the server authorizes the shared resource to the sharee or the sharer of the shared resource.
[0014] In a fourth aspect, the embodiment of the present invention further provides a server, including:
[0015] a receiving module, configured to receive an authentication request sent by a first terminal device, wherein the authentication request includes a first token generated by the first terminal device according to a first key or a second token generated according to a first original key of a shared resource, wherein the first key is a key generated by the first terminal device according to the first original key and an identifier of a shared resource;
[0016] a response module, configured to respond to the authentication request, authenticate based on the first token or the second token to obtain a first authentication result, wherein the first authentication result includes authentication passed or authentication failed, and when the first authentication result is authentication passed, authorize the shared resource to the sharee or the sharer of the shared resource;
[0017] A sending module is used to send the first authentication result to the first terminal device.
[0018] In the fifth aspect, an embodiment of the present application also provides a first terminal device, comprising: a memory, a processor, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps in the resource authorization method disclosed in the first aspect of the embodiment of the present application.
[0019] In the sixth aspect, an embodiment of the present application also provides a server device, comprising: a memory, a processor, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps in the resource authorization method disclosed in the second aspect of the embodiment of the present application.
[0020] In a seventh aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps in the resource authorization method disclosed in the first aspect of the embodiment of the present application are implemented.
[0021] In an eighth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps in the resource authorization method disclosed in the second aspect of the embodiment of the present application are implemented.
[0022] Thus, in this embodiment, the first key generated by the first terminal device is used by the sharee for authentication, and the original key of the shared resource may not be exposed. When the first authentication result is that the authentication is passed, the server authorizes the shared resource to the sharee or the sharer of the shared resource. Therefore, during the resource authorization process, the sharee cannot obtain the original key of the shared resource, and the technical effect of avoiding the leakage of the original key of the resource can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, 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 some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0024] Figure 1 It is a flowchart of a resource authorization method provided in an embodiment of the present application;
[0025] Figure 2 It is a flowchart of another resource authorization method provided in an embodiment of the present application;
[0026] Figure 3It is a flowchart of another resource authorization method provided in an embodiment of the present application;
[0027] Figure 4 This is a schematic diagram of a security authentication process provided by an embodiment of the present application;
[0028] Figure 5 is a structural diagram of another first terminal device provided in an embodiment of the present application;
[0029] Figure 6 is a structural diagram of another first terminal device provided in an embodiment of the present application;
[0030] Figure 7 It is a structural diagram of another server provided in an embodiment of the present application;
[0031] Figure 8 is a structural diagram of another first terminal device provided in an embodiment of the present application;
[0032] Fig. 9 It is a structural diagram of another server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] 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 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.
[0034] See also Figure 1 , Figure 1 A resource authorization method provided in an embodiment of the present application is applied to a first terminal device, such as Figure 1 As shown, the following steps are included:
[0035] Step 101: Send an authentication request to a server, wherein the authentication request includes a first token generated according to a first key or a second token generated according to a first original key of a shared resource, wherein the first key is a key generated according to the first original key and an identifier of a sharee.
[0036] The shared resources mentioned above may be any IoT devices and products, such as sweeping robots, smart watches, smart power strips, smart air conditioners, smart wearable devices, etc.
[0037] The shared resources and sharees mentioned above may be pre-selected. For example, the shared resource 1 may be pre-selected to be shared with the sharee A, and the shared resource 2 may be pre-selected to be shared with the sharee B.
[0038] Among them, the above-mentioned first key can be different according to different sharees. The above-mentioned first key is generated according to the first original key of the shared resource and the identifier of the sharee. The original key of the shared resource is unique, but the sharee cannot view the first original key of the shared resource, but operates according to the regenerated first key. After the authorization of the shared resource obtained by the sharee is cancelled, the sharee cannot continue to operate according to the generated first key. For example: when the same shared resource is shared with two sharees, the resource keys that the two sharees can view are two different keys generated by the original key. The two different keys are generated by the same original key, which can ensure that no sharee can obtain the original key of the resource for operation. In addition, when replacing the sharee, only the identifier of the replaced sharee needs to be used to regenerate the key of the shared resource in the memory, and share the key with the new sharee, thereby avoiding large-scale updates of keys and improving the efficiency of authorization changes.
[0039] Step 102, receiving a first authentication result sent by the server in response to the authentication request, wherein the first authentication result is an authentication result obtained by the server based on the first token or the second token, and the first authentication result includes authentication passed or authentication failed. When the first authentication result is authentication passed, the server authorizes the shared resource to the sharee or the sharer of the shared resource.
[0040] The above-mentioned sharer may be the resource owner of the shared resource. For example, the resource owner owns resource 1 and resource 2. The resource owner may share resource 1 with sharee A. Then the above-mentioned resource owner is the sharer of shared resource 1.
[0041] The sharee can view the relevant information of the shared resource through the first key, such as the name, specification, function, type, etc. of the product or device, and can also perform related operations through the first key.
[0042] In this embodiment, the first key generated by the first terminal device is used by the sharee for authentication, and the original key of the shared resource may not be exposed. When the first authentication result is that the authentication is passed, the server authorizes the shared resource to the sharee or the sharer of the shared resource. During the resource authorization process, the sharee cannot obtain the original key of the shared resource, thereby achieving the technical effect of avoiding the leakage of the original key of the resource.
[0043] Optionally, the authentication request includes the first token; before step 101, the method may further include the following steps:
[0044] Step 103: Receive the first key shared by the second terminal device, where the first key is a key generated by the second terminal device according to the first original key of the shared resource and the identifier of the shared resource, after the second terminal device receives the shared resource and the identifier of the shared resource selected by the sharer.
[0045] The second terminal device may be a sharee's terminal device, and the first terminal device may be a sharee's terminal device. For example, the sharee's terminal device may receive the first key shared by the sharee's terminal device.
[0046] Among them, the above-mentioned first key can hide the original key of the shared resource. For example, the above-mentioned first original key generates the first key through HMAC (Hash-based Message Authentication Code): base64 (hmac_sha256 (secretKey, uid)), wherein secretKey represents the first original key, uid represents the identifier of the sharee, and base64 represents binary data based on 64 printable characters. The sharee can only obtain the above-mentioned first key but cannot obtain the original key of the resource.
[0047] Step 104: Generate the first token based on the first key.
[0048] The first token may be generated in the memory of the first terminal device. For example, after the first terminal device receives the first key shared by the second terminal device, the first token is obtained by using a token generation algorithm in the memory.
[0049] The first token may include multiple fields, such as res (resource), et (expiration time), version, method (signature method), sign (signature), etc. The sign field may be generated by the first key, and the generation algorithm may be base64 (hmac_ <method>(accessKey,utf-8(msg))), where msg is a string consisting of et+'\n'+method+'\n'+res+'\n'+version. The first token can be composed of the above fields in the form of key=value and separated by &, for example:
[0050] version=1&res=uid / * / pid / *&et=1537255523&method=md5&sign=Z***a=.
[0051] In this implementation, by receiving the first key shared by the second terminal device and generating the first token based on the first key, leakage of the original key of the resource can be avoided, and by generating the first token in the memory, pressure on the database can be reduced.
[0052] Optionally, the first token includes the identifier of the sharee;
[0053] The first authentication result is that the server obtains the second original key of the target resource corresponding to the identifier of the target resource; generates a second key according to the identifier of the sharee and the second original key; generates a third token according to the second key; and obtains the authentication result based on the comparison between the third token and the first token;
[0054] When the first authentication result is authentication passed, the server authorizes the shared resource to the sharee.
[0055] The target resource may be a shared resource, and the server may obtain the second original key of the target resource corresponding to the identifier of the target resource.
[0056] In this implementation, a second key is generated based on the second original key of the target resource corresponding to the identifier of the sharee and the identifier of the target resource in the above-mentioned first token, a third token is generated based on the second key, and an authentication result is obtained based on the comparison between the third token and the first token. When the sharee initiates an authentication request, the authentication result can be quickly obtained.
[0057] Optionally, in step 101, the second token includes the identifier of the sharer, and the authentication request includes the second token;
[0058] The first authentication result is that the server obtains the second original key of the target resource corresponding to the identifier of the target resource; a fourth token is generated according to the identifier of the sharer and the second original key; and an authentication result is obtained based on the comparison between the fourth token and the second token;
[0059] When the first authentication result is authentication passed, the server authorizes the shared resource to the sharer of the shared resource.
[0060] In this implementation, the second key is generated based on the second original key of the target resource corresponding to the identifier of the sharee and the identifier of the target resource in the first token, and the authentication result is obtained based on the comparison between the third token and the first token. When the sharer initiates an authentication request, the original key of the shared resource is directly used to generate a token, so that the authentication result can be quickly obtained.
[0061] Optionally, the first token and the second token include a resource field, and the resource field includes an identifier of a target resource, wherein:
[0062] When sending a northbound authentication request to the server, the identifier of the target resource includes a product identifier;
[0063] When initiating a southbound authentication request to the server, the identifier of the target resource includes a product identifier and a device identifier.
[0064] Among them, the resource field of the above-mentioned first token may be different, for example: during northbound authentication, the resource field is in the form of uid / ${uid} / pid / ${pid}, and during southbound authentication, the resource field is in the form of uid / ${uid} / pid / ${pid} / did / ${did}, wherein uid represents the user identity identifier requesting resource permissions, pid represents the product identity identifier, and did represents the device identity identifier.
[0065] Among them, the above-mentioned northbound authentication can use the product key to generate a token, and the above-mentioned southbound authentication can use the device key to generate a token. For example: when performing API (Application Programming Interface) access authentication through the northbound interface, a product-level key is required, and when performing device connection authentication through the southbound interface, a device-level key is required.
[0066] In this implementation, the Internet of Things is hierarchically authorized by using different resource fields carried by the first token, thereby achieving authorization for products and devices, and expanding the scope of application of the resource authorization method.
[0067] Optionally, the first token and the second token include an expiration time field, and the expiration time field identifies the expiration time of the first token or the second token through a timestamp.
[0068] Among them, the above expiration time can be set by the sharer. For example, if the expiration time is set to 15:00:00 on January 1, 2020, Beijing time, when the sharee accesses the shared resource at 15:00:00 on January 2, 2020, Beijing time, the sharee is denied access to the resource because the expiration time is less than the current time.
[0069] In this implementation, an expiration time is added to the first token when authorizing a resource, and the resource authorization may automatically become invalid when the expiration time comes, thereby achieving control over the effective time of the resource authorization.
[0070] In addition, the above-mentioned first token is generated based on the first key, and the first key is generated based on the original key of the shared resource and the identifier of the sharee. The key obtained by the sharee for each shared resource is different, and the token generated during authentication is also different, which can realize fine-grained authorization of resources.
[0071] See also Figure 2 , Figure 2 Another resource authorization method provided in the embodiment of the present application is applied to a server, such as Figure 2 As shown, the following steps are included:
[0072] Step 201, receive an authentication request sent by a first terminal device, wherein the authentication request includes a first token generated by the first terminal device based on a first key or a second token generated based on a first original key of a shared resource, wherein the first key is a key generated by the first terminal device based on the first original key and an identifier of a sharee.
[0073] Among them, the above-mentioned first terminal device can be a sharing terminal device or a shared terminal device. For example, the sharing terminal device can send a second token generated according to the first original key of the shared resource, and the shared terminal device can send a first token generated according to the first key.
[0074] Step 202, in response to the authentication request, authentication is performed based on the first token or the second token to obtain a first authentication result, wherein the first authentication result includes authentication passed or authentication failed, and when the first authentication result is authentication passed, the shared resource is authorized to the sharee or the sharer of the shared resource.
[0075] Step 203: Send the first authentication result to the first terminal device.
[0076] In this embodiment, the server authenticates the rights of both the sharer and the sharee to the authorized resources, and generates authentication tokens in the same way, which can improve the accuracy of authentication and achieve secure authorization of resources.
[0077] Optionally, the authentication request includes the first token and an identifier of the target resource, and the first token includes an identifier of the sharee;
[0078] The step of performing authentication based on the first token in response to the authentication request to obtain a first authentication result includes:
[0079] Obtaining a second original key of the target resource corresponding to the identifier of the target resource;
[0080] Generate a third token according to the identifier of the sharee and the second original key;
[0081] Based on the comparison between the third token and the first token, the first authentication result is obtained.
[0082] The second original key can be the original key of a product or device. For example, each product and device corresponds to a unique original key. When the authentication request resource is a product, the second original key is the product original key. When the authentication request resource is a device, the second original key is the device original key. Tokens generated by the original keys of the above different resources are used for authentication. Tokens generated by different keys can be used to authenticate each resource authorization request, thereby realizing fine-grained authorization of resources.
[0083] The identifier of the sharee can be obtained according to the resource field of the first token. For example, no matter whether the authentication request is a northbound authentication request or a southbound authentication request, the resource field of the first token includes the identifier of the requesting sharee.
[0084] In this implementation, the first authentication result is obtained based on the comparison between the third token and the first token, so that fine-grained authorization of resources can be achieved.
[0085] Optionally, the authentication request includes the second token and an identifier of a target resource, and the second token includes an identifier of the sharer;
[0086] The step of performing authentication based on the second token in response to the authentication request to obtain a first authentication result includes:
[0087] Obtaining a second original key of the target resource corresponding to the identifier of the target resource;
[0088] generating a fourth token according to the identifier of the sharer and the second original key;
[0089] Based on the comparison between the fourth token and the second token, the first authentication result is obtained.
[0090] In this embodiment, the second algorithm for generating the first token and the second token can generate an authorized resource key in the memory, which can avoid the huge pressure on the database caused by the regeneration of keys when massive IoT devices are authorized to other users.
[0091] See also Figure 3 , Figure 3 This is another resource authorization method provided by the embodiment of the present application, such as Figure 3 As shown, the following steps are included:
[0092] Step 301: Resource sharing:
[0093] The resource owner selects the resources (products, equipment) to be shared and the people to be shared with;
[0094] Generate corresponding strategies based on the selected resources and sharers and write them into the database;
[0095] Invite the sharee to share resources;
[0096] The person being shared accepts the invitation;
[0097] The person being shared with can view relevant information about the product or device.
[0098] Among them, the above-mentioned resource owner can be a sharer, and the above-mentioned generated corresponding strategy can include the corresponding relationship between the selected resources and the sharees. For example: when the shared resource 1 can be selected to be shared with the sharee A, the above-mentioned sharing strategy will be associated with the original key of the shared resource 1, the user identity of the sharee A and other information, and stored in the database.
[0099] In addition, the resource owner can cancel the resource sharing authorization to the sharee at any time. To avoid leakage of sensitive information such as product and device keys, after the resource sharing invitation is canceled, the sharee cannot perform illegal operations on the shared resources. In addition, the product and device keys viewed by the sharee are not the original keys, but are generated in the following way: base64(hmac_sha256(secretKey,uid)), where secretKey is the original key, which is used as the key of the hmac method, and uid is the sharee's identifier, which is used as the message of the hmac method.
[0100] Step 302, Token generation: After completing the resource sharing in step 301, a token is generated using a key.
[0101] The token is generated based on the key that the sharer has viewed. Each product and device has a unique key. The product key is used for northbound interface authentication, and the device key is used for southbound access authentication. When initiating an authentication request, the key is not transmitted directly, but the token is generated through the key for authentication. The token generation method is as follows:
[0102] The token mainly includes res, et, version, method and sign fields:
[0103] res: For northbound authentication, the res field is in the form of uid / ${uid} / pid / ${pid}; for southbound authentication, the res field is in the form of uid / ${uid} / pid / ${pid} / did / ${did}, where uid is the ID of the target resource, pid is the product ID, and did is the device ID.
[0104] et: specifies the expiration time of the token, marked with a Unix timestamp;
[0105] version: version number;
[0106] method: signature algorithm, supports md5, sha1, and sha256;
[0107] sign: The signature generated by the key, the generation algorithm is: base64(hmac_ <method>(accessKey,utf-8(msg))), msg is a string composed of et+'\n'+method+'\n'+res+'\n'+version;
[0108] The token is composed of the above fields in the form of key=value, separated by &, for example:
[0109] version=1&res=uid / * / pid / *&et=1537255523&method=md5&sign=Z***a=.
[0110] Step 303: security authentication.
[0111] like Figure 4 As shown, the following steps may be specifically included:
[0112] Step 3031: Initiate an authentication request by passing in the token generated in step 302.
[0113] Step 3032, determine the target resource level. If the target resource level is product level, jump to step 3033; if the requested resource level is device level, jump to step 3034.
[0114] The level of the target resource may be obtained through the token passed in step 302 .
[0115] Step 3033 , obtain the product key corresponding to the target resource from the database, name it key A1 , and jump to step 3035 .
[0116] Step 3034 , obtain the product device key corresponding to the resource from the database, name it key A2 , and jump to step 3035 .
[0117] Step 3035, parse the res field of the token, obtain the uid parameter, and query the user ID of the resource owner to determine whether the uid parameter is the same as the resource owner's ID. If the two are the same, the resource owner itself initiates an authentication request and jumps to step 3036. If they are different, the authentication request is initiated for the sharee and jumps to step 3037.
[0118] Step 3036: Use key A1 or A2 to calculate the token through the token generation algorithm and compare it with the incoming token. If they match successfully, the authentication is successful, otherwise the authentication fails.
[0119] Step 3037: Use key A1 or A2 to generate key B through base64 (hmac_sha256 (secretKey, uid)) and use key B to calculate token through token generation algorithm.
[0120] Step 3038: Compare the token generated by the verification with the incoming token. If they match successfully, the authentication is successful, otherwise the authentication fails.
[0121] In this embodiment, the above three steps ensure that the resource owner does not expose his own key, and the sharee can use the corresponding shared key for north-south development. After the resource owner cancels the sharing, the sharee cannot authenticate using the shared key. In addition, the sharee's key is generated from the original key, and there is no need to generate the corresponding key and save it in the persistent database during the sharing process, which saves storage resources and avoids the impact on the database. Therefore, it can support the millions or even tens of millions of resource authorization scenarios that may exist in the Internet of Things.
[0122] See also Figure 5 , Figure 5 is a first terminal device provided in an embodiment of the present application, such as Figure 5 As shown, the first terminal device 500 includes:
[0123] A sending module 501 is used to send an authentication request to a server, wherein the authentication request includes a first token generated according to a first key or a second token generated according to a first original key of a shared resource, wherein the first key is a key generated according to the first original key and an identifier of a sharee;
[0124] The first receiving module 502 is used to receive a first authentication result sent by the server in response to the authentication request, wherein the first authentication result is an authentication result obtained by the server based on the first token or the second token, and the first authentication result includes authentication passed or authentication failed. When the first authentication result is authentication passed, the server authorizes the shared resource to the sharee or the sharer of the shared resource.
[0125] Optional, such as Figure 6 As shown, the authentication request specifically includes the first token;
[0126] The first terminal device 500 further includes:
[0127] The second receiving module 503 is used to receive the first key shared by the second terminal device, where the first key is a key generated by the second terminal device according to the first original key of the shared resource and the identifier of the shared resource selected by the sharer and the identifier of the shared resource.
[0128] The generating module 504 is configured to generate the first token based on the first key.
[0129] Optionally, the first token includes the identifier of the sharee;
[0130] The first authentication result is that the server obtains the second original key of the target resource corresponding to the identifier of the target resource; generates a third token according to the identifier of the sharee and the second original key; and obtains the authentication result based on the comparison between the third token and the first token;
[0131] When the first authentication result is authentication passed, the server authorizes the shared resource to the sharee.
[0132] Optionally, the second token includes an identifier of the sharer, and the authentication request includes the second token;
[0133] The first authentication result is that the server obtains the second original key of the target resource corresponding to the identifier of the target resource; a fourth token is generated according to the identifier of the sharer and the second original key; and an authentication result is obtained based on the comparison between the fourth token and the second token;
[0134] When the first authentication result is authentication passed, the server authorizes the shared resource to the sharer of the shared resource.
[0135] Optionally, the first token and the second token include a resource field, and the resource field includes an identifier of a target resource, wherein:
[0136] When sending a northbound authentication request to the server, the identifier of the target resource includes a product identifier;
[0137] When initiating a southbound authentication request to the server, the identifier of the target resource includes a product identifier and a device identifier.
[0138] Optionally, the first token and the second token include an expiration time field, and the expiration time field identifies the expiration time of the first token or the second token through a timestamp.
[0139] The device 500 can achieve Figure 1 The various processes implemented by the device in the method embodiment are not described here in detail to avoid repetition. The device 500 can achieve the technical effect of preventing the original key from being leaked during resource authorization.
[0140] See also Figure 7 , Figure 7 is a server provided in an embodiment of the present application, such as Figure 7 As shown, the server 700 includes:
[0141] A receiving module 701 is used to receive an authentication request sent by a first terminal device, wherein the authentication request includes a first token generated by the first terminal device according to a first key or a second token generated according to a first original key of a shared resource, wherein the first key is a key generated by the first terminal device according to the first original key and an identifier of a shared resource;
[0142] A response module 702 is used to respond to the authentication request, perform authentication based on the first token or the second token to obtain a first authentication result, wherein the first authentication result includes authentication passed or authentication failed, and when the first authentication result is authentication passed, authorize the shared resource to the sharee or the sharer of the shared resource;
[0143] The sending module 703 is used to send the first authentication result to the first terminal device.
[0144] Optionally, the authentication request includes the first token and an identifier of the target resource, and the first token includes an identifier of the sharee;
[0145] The response module 702 may be specifically used for:
[0146] Obtaining a second original key of the target resource corresponding to the identifier of the target resource;
[0147] Generate a third token according to the identifier of the sharee and the second original key;
[0148] Based on the comparison between the third token and the first token, the first authentication result is obtained.
[0149] Optionally, the authentication request includes the second token and an identifier of a target resource, and the second token includes an identifier of the sharer;
[0150] The response module 702 may be specifically used for:
[0151] Obtaining a second original key of the target resource corresponding to the identifier of the target resource;
[0152] generating a fourth token according to the identifier of the sharer and the second original key;
[0153] Based on the comparison between the fourth token and the second token, the first authentication result is obtained.
[0154] The device 700 can achieve Figure 2 The various processes implemented by the device in the method embodiment are not described here in detail to avoid repetition. The device 700 can achieve the technical effect of preventing the original key from being leaked during resource authorization.
[0155] See also Figure 8 The embodiment of the present application also provides a first terminal device, which includes a processor 801, a memory 802, and a program or instruction stored in the memory 802 and executable on the processor 801. When the program or instruction is executed by the processor 601, each process of the above-mentioned resource authorization method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0156] See also Fig. 9 The embodiment of the present application also provides a server, the server 900 includes a processor 901, a memory 902, a program or instruction stored in the memory 902 and executable on the processor 901, and the program or instruction, when executed by the processor 901, implements each process of the above-mentioned resource authorization method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0157] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned resource authorization method embodiment applied to the first terminal device is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0158] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned resource authorization method embodiment applied to the server is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0159] The processor is the processor in the electronic device in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0160] It should be noted that, in this article, the terms "comprise", "include" 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, an element defined by the sentence "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved. For example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0161] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods of each embodiment of the present application.
[0162] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.< / method> < / method>
Claims
1. A resource authorization method, characterized in that: Applied to the first terminal device, including: Sending an authentication request to a server, the authentication request including a first token generated according to a first key or a second token generated according to a first original key of a shared resource, wherein the first key is a key generated according to the first original key and an identifier of a sharee; receiving a first authentication result sent by the server in response to the authentication request, wherein the first authentication result is an authentication result obtained by the server based on the first token or the second token, and the first authentication result includes authentication passed or authentication failed, and the server authorizes the shared resource to the sharee or the sharer of the shared resource when the first authentication result is authentication passed; The second token includes the identifier of the sharer, and the authentication request includes the second token; The first authentication result is that the server obtains the second original key of the target resource corresponding to the identifier of the target resource; a fourth token is generated according to the identifier of the sharer and the second original key; and an authentication result is obtained based on the comparison between the fourth token and the second token; When the first authentication result is authentication passed, the server authorizes the shared resource to the sharer of the shared resource.
2. The method according to claim 1, characterized in that The authentication request includes the first token; Before sending the authentication request to the server, the method further includes: receiving the first key shared by the second terminal device, where the first key is a key generated by the second terminal device receiving the shared resource and the identifier of the shared resource selected by the sharer, according to the first original key of the shared resource and the identifier of the shared resource; The first token is generated based on the first key.
3. The method according to claim 2, characterized in that The first token includes the identifier of the sharee; The first authentication result is a second original key of the target resource corresponding to the identifier of the target resource obtained by the server; Generate a second key according to the identifier of the sharee and the second original key; generating a third token according to the second key; An authentication result obtained based on a comparison between the third token and the first token; When the first authentication result is authentication passed, the server authorizes the shared resource to the sharee.
4. The method according to claim 1, characterized in that The first token and the second token include a resource field, the resource field including an identifier of a target resource, wherein: When sending a northbound authentication request to the server, the identifier of the target resource includes a product identifier; When initiating a southbound authentication request to the server, the identifier of the target resource includes a product identifier and a device identifier.
5. The method according to claim 1, characterized in that The first token and the second token include an expiration time field, and the expiration time field identifies the expiration time of the first token or the second token through a timestamp.
6. A resource authorization method, applied to a server, characterized in that: include: Receiving an authentication request sent by a first terminal device, the authentication request including a first token generated by the first terminal device according to a first key or a second token generated according to a first original key of a shared resource, wherein the first key is a key generated by the first terminal device according to the first original key and an identifier of a shared resource; In response to the authentication request, performing authentication based on the first token or the second token to obtain a first authentication result, wherein the first authentication result includes authentication passed or authentication failed, and when the first authentication result is authentication passed, authorizing the shared resource to the sharee or the sharer of the shared resource; Sending the first authentication result to the first terminal device; The authentication request includes the second token and an identifier of a target resource, and the second token includes an identifier of the sharer; The step of performing authentication based on the second token in response to the authentication request to obtain a first authentication result includes: Obtaining a second original key of the target resource corresponding to the identifier of the target resource; generating a fourth token according to the identifier of the sharer and the second original key; Based on the comparison between the fourth token and the second token, the first authentication result is obtained.
7. The method according to claim 6, characterized in that The authentication request includes the first token and an identifier of a target resource, and the first token includes an identifier of the sharee; The step of performing authentication based on the first token in response to the authentication request to obtain a first authentication result includes: Obtaining a second original key of the target resource corresponding to the identifier of the target resource; Generate a second key according to the identifier of the sharee and the second original key; generating a third token according to the second key; Based on the comparison between the third token and the first token, the first authentication result is obtained.
8. A first terminal device, characterized in that: include: a sending module, configured to send an authentication request to a server, wherein the authentication request includes a first token generated according to a first key or a second token generated according to a first original key of a shared resource, wherein the first key is a key generated according to the first original key and an identifier of a sharee; A first receiving module is configured to receive a first authentication result sent by the server in response to the authentication request, wherein the first authentication result is an authentication result obtained by the server based on the first token or the second token, and the first authentication result includes authentication passed or authentication failed. When the first authentication result is authentication passed, the server authorizes the shared resource to the sharee or the sharer of the shared resource; The second token includes the identifier of the sharer, and the authentication request includes the second token; The first authentication result is that the server obtains the second original key of the target resource corresponding to the identifier of the target resource; a fourth token is generated according to the identifier of the sharer and the second original key; and an authentication result is obtained based on the comparison between the fourth token and the second token; When the first authentication result is authentication passed, the server authorizes the shared resource to the sharer of the shared resource.
9. A server, characterized in that: include: a receiving module, configured to receive an authentication request sent by a first terminal device, wherein the authentication request includes a first token generated by the first terminal device according to a first key or a second token generated according to a first original key of a shared resource, wherein the first key is a key generated by the first terminal device according to the first original key and an identifier of a shared resource; a response module, configured to respond to the authentication request, authenticate based on the first token or the second token to obtain a first authentication result, wherein the first authentication result includes authentication passed or authentication failed, and when the first authentication result is authentication passed, authorize the shared resource to the sharee or the sharer of the shared resource; A sending module, used for sending the first authentication result to the first terminal device; The authentication request includes the second token and an identifier of a target resource, and the second token includes an identifier of the sharer; The response module is specifically used for: Obtaining a second original key of the target resource corresponding to the identifier of the target resource; generating a fourth token according to the identifier of the sharer and the second original key; Based on the comparison between the fourth token and the second token, the first authentication result is obtained.
10. A first terminal device, characterized in that: The method comprises a processor, a memory, and a program or instruction stored in the memory and running on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the resource authorization method according to any one of claims 1 to 5.
11. A server, characterized in that: The method comprises a processor, a memory, and a program or instruction stored in the memory and running on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the resource authorization method as described in any one of claims 6 to 7.
12. A readable storage medium, characterized in that: The readable storage medium stores a program or an instruction, and when the program or the instruction is executed by the processor, the steps of the resource authorization method according to any one of claims 1 to 5 are implemented.
13. A readable storage medium, characterized in that: The readable storage medium stores a program or an instruction, and when the program or the instruction is executed by the processor, the steps of the resource authorization method according to any one of claims 6 to 7 are implemented.
Citation Information
Patent Citations
Authentication method, server and access control device
CN106657152A
