Redis-based iot device permission checking method and system
By using Redis-based permission verification methods to generate and manage user keys and refresh keys, the problem of verifying the legitimacy of IoT devices is solved, ensuring data security and consistency and preventing counterfeit devices and data tampering.
Patent Information
- Application Number
- CN202410667410.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-28
- Publication Date
- 2026-01-13
- Estimated Expiration
- 2044-05-28
AI Technical Summary
How can the legitimacy of IoT devices be verified when they are connected to an IoT platform to ensure data security and consistency and prevent counterfeit devices and data tampering?
A Redis-based permission verification method is adopted to generate user keys and refresh keys. Through key request, verification and refresh mechanisms, the legitimacy of IoT devices and data security are ensured. A unique device identifier is generated using username and password. Redis is used to store the key and set an expiration policy to realize permission authentication and refresh.
It effectively prevents counterfeit devices and data tampering, ensuring the authenticity and consistency of IoT platform and device data, and improving the security and reliability of data circulation.
Smart Images

Figure CN118473778B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Internet of Things (IoT) technology, specifically to a method and system for verifying IoT device permissions based on Redis. Background Technology
[0002] The Internet of Things (IoT) technology integrates technologies from the electronics, communications, and computer fields to enable interconnection of things on the basis of the internet. The IoT is the foundation for the interconnection of everything and also the basis for future applications such as smart factories, smart cities, smart communities, and smart homes.
[0003] Access permissions refer to the information and resources a user is entitled to access and how they can interact with that information, such as viewing or modifying content. Access control is used to verify a person's identity (authentication) and whether they are authorized to perform specific activities (authorization).
[0004] The Internet of Things (IoT) is more vulnerable to attacks and faces frequent security threats. Compared to traditional networks, the IoT connects a large number of IoT sensor terminals of various types. Due to the highly decentralized and weakly organized nature of IoT terminal devices, they face a higher risk of being tampered with and counterfeited.
[0005] When IoT devices are connected, it is necessary to verify the authenticity of the device information to prevent counterfeit devices from sending messages, which could lead to the influx of illegal or even destructive data. At the same time, permission verification helps ensure that data mismatches between devices are not caused by negligence or other reasons, preventing unpredictable consequences.
[0006] How to verify the legitimacy of devices connected to the IoT platform and ensure the security and consistency of data are technical problems that need to be solved. Summary of the Invention
[0007] The technical objective of this invention is to address the above-mentioned shortcomings by providing a Redis-based method and system for verifying the permissions of IoT devices, thereby solving the technical problem of how to verify the legitimacy of devices connected to the IoT platform and ensure the security and consistency of data.
[0008] In a first aspect, the present invention provides a Redis-based method for verifying the permissions of IoT devices, comprising the following steps:
[0009] Key generation: The IoT device initiates a key request to the IoT platform based on a username and password. Based on the key request, the IoT platform's server verifies the validity of the username and password, generates a key for the IoT device, returns the key to the IoT device, and stores the username, key, and key validity period in the IoT platform's server-side Redis. The key includes a user key and a refresh key. The user key is used for authorization, and the refresh key is used to refresh the user key. The key validity period is customized based on the data reporting cycle. The username serves as a unique device identifier for the IoT device.
[0010] Key verification: IoT devices report data to the IoT platform, and the data carries the username and user key. The IoT platform verifies the legitimacy of the IoT devices based on the user key. If the verification is successful, the platform receives and processes the data; if the verification fails, the platform discards the data and refuses to process it.
[0011] Key refresh: During key verification, the IoT platform verifies the user's key based on the key stored in the server-side Reids and the key's validity period. If the user's key has expired but the refresh key has not expired, the user's key is refreshed based on the refresh key. If both the user's key and the refresh key have expired, a new key is generated for the IoT device through key generation.
[0012] Preferably, for user keys, the username and user key are converted into key values based on predetermined rules, and an expiration policy is configured for the user keys. The key values corresponding to the user keys and the expiration policy are stored in the Redis server of the IoT platform. The expiration policy for user keys is N times the default data reporting interval of IoT devices as the expiration time of the user keys.
[0013] For refresh keys, the username and refresh key are converted into key values based on predetermined rules, and an expiration policy is configured for the refresh key. The key value corresponding to the refresh key and the expiration policy are stored in the Redis server of the IoT platform. The expiration policy of the refresh key is to use M times the default data reporting interval of the IoT device as the expiration time of the user key, where N and M are natural numbers, and M is greater than N.
[0014] Preferably, when the IoT platform verifies the legitimacy of IoT devices based on the user key, after receiving data uploaded by the IoT device, it checks whether the data carries the user key. For data that does not carry the user key, the data is considered invalid, discarded, and rejected. For data that carries the user key, the following legitimacy verification is performed:
[0015] Verify the correctness of the key: For the user key uploaded by the IoT device, the user key is converted into a key value according to the predetermined rules. If the generated key value is consistent with the key value stored in the Redis server, it means that the key is correct, and the validity of the key is verified.
[0016] Verify the validity of the key: For the user key uploaded by the IoT device, verify the validity of the user key based on the validity period specified in the Redis server. If the user key has not expired, the verification is successful. If the user key has expired but the corresponding refresh key is valid, update the user key with the refresh key. If the user key has expired and the corresponding refresh key has also expired, regenerate the key for the IoT device using the key generation function.
[0017] As a preferred method, key refresh includes the following three scenarios:
[0018] Scenario 1, before the message reporting cycle of device M: neither the user key nor the refresh key has expired. After successfully verifying the user key, the expiration time of the key in the server-side Redis is extended by M times.
[0019] Scenario 2, message reporting interval for M to N devices: The user key has expired, but the refresh key has not expired. A new user key is generated for the IoT device through key generation, and the expiration time of the key in the server-side Redis is extended by M times.
[0020] Scenario 3: More than N device message reporting intervals: Both the user key and refresh key have expired. A new key is generated for the IoT device through key generation, and the key and its expiration date are stored in the IoT platform's server-side Redis.
[0021] In a second aspect, the present invention provides a Redis-based IoT device permission verification system, used to verify the permissions of IoT devices using a Redis-based IoT device permission verification method as described in any of the first aspects, wherein the system includes IoT devices and an IoT platform.
[0022] The IoT device initiates a key request to the IoT platform based on a username and password. Correspondingly, based on the key request, the IoT platform performs the following key generation: after verifying the validity of the username and password through the server, it generates a key for the IoT device, returns the key to the IoT device, and stores the username, key, and key validity period in the IoT platform's server-side Redis. The key includes a user key and a refresh key. The user key is used for authorization, and the refresh key is used to refresh the user key. The key validity period is customized based on the data reporting cycle. The username serves as the unique device identifier for the IoT device.
[0023] IoT devices are used to report data to the IoT platform. The data carries the username and user key. The IoT platform then performs the following actions: it verifies the legitimacy of the IoT device based on the user key. If the verification passes, the platform receives and processes the data. If the verification fails, the platform discards and rejects the data.
[0024] During key verification, the IoT platform performs the following: It verifies the user's key based on the key stored in the server-side Reids and the key's validity period. If the user's key has expired but the refresh key has not expired, it refreshes the user's key based on the refresh key. If both the user's key and the refresh key have expired, it regenerates a key for the IoT device through key generation.
[0025] Preferably, for user keys, the IoT platform's server converts usernames and user keys into key values based on predetermined rules, configures expiration policies for user keys, and stores the corresponding key values and expiration policies in the IoT platform's server-side Redis. The expiration policy for user keys is to use N times the default data reporting interval of IoT devices as the expiration time for the user keys.
[0026] For the refresh key, the server of the IoT platform converts the username and refresh key into a key value based on predetermined rules, configures an expiration policy for the refresh key, and stores the key value corresponding to the refresh key and the expiration policy in the Redis server of the IoT platform. The expiration policy of the refresh key is to use M times the default data reporting interval of the IoT device as the expiration time of the user key, where N and M are natural numbers, and M is greater than N.
[0027] Preferably, when verifying the legitimacy of IoT devices based on user keys, after receiving data uploaded by the IoT device, the IoT platform performs the following: It checks whether the data carries a user key. For data without a user key, the data is considered invalid, discarded, and rejected. For data carrying a user key, the following legitimacy verification is performed:
[0028] Verify the correctness of the key: For the user key uploaded by the IoT device, the user key is converted into a key value according to the predetermined rules. If the generated key value is consistent with the key value stored in the Redis server, it means that the key is correct, and the validity of the key is verified.
[0029] Verify the validity of the key: For the user key uploaded by the IoT device, verify the validity of the user key based on the validity period specified in the Redis server. If the user key has not expired, the verification is successful. If the user key has expired but the corresponding refresh key is valid, update the user key with the refresh key. If the user key has expired and the corresponding refresh key has also expired, regenerate the key for the IoT device using the key generation function.
[0030] As a preferred method, key refresh includes the following three scenarios:
[0031] Scenario 1, before the message reporting cycle of device M: neither the user key nor the refresh key has expired. After successfully verifying the user key, the expiration time of the key in the server-side Redis is extended by M times.
[0032] Scenario 2, message reporting interval for M to N devices: The user key has expired, but the refresh key has not expired. A new user key is generated for the IoT device through key generation, and the expiration time of the key in the server-side Redis is extended by M times.
[0033] Scenario 3: More than N device message reporting intervals: Both the user key and refresh key have expired. A new key is generated for the IoT device through key generation, and the key and its expiration date are stored in the IoT platform's server-side Redis.
[0034] The IoT device permission verification system and method based on Redis of the present invention has the following advantages: by distributing unique identifiers and passwords to IoT devices through the IoT platform, and distributing keys according to the identifiers and passwords, the permission verification of IoT devices is realized through the keys, which ensures the security and reliability of data circulation, avoids third parties from tampering with and forging the data of real devices to a certain extent, and ensures the authenticity and consistency of IoT platform and device data. Attached Figure Description
[0035] To more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0036] The invention will be further described below with reference to the accompanying drawings.
[0037] Figure 1 Here is a flowchart of a Redis-based IoT device permission verification method as shown in Example 1.
[0038] Figure 2This is a flowchart illustrating the data interaction process between the IoT device and the IoT platform server in an IoT device permission verification method based on Redis, as described in Example 1. Detailed Implementation
[0039] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments are not intended to limit the present invention. In the absence of conflict, the embodiments of the present invention and the technical features in the embodiments can be combined with each other.
[0040] This invention provides a Redis-based method and system for verifying the permissions of IoT devices, which addresses the technical problem of how to verify the legitimacy of devices connected to an IoT platform and ensure the security and consistency of data.
[0041] Example 1:
[0042] This invention provides a Redis-based method for verifying permissions of IoT devices, comprising three steps: key generation, key verification, and key refresh.
[0043] Step S100 Key Generation: The physical network device initiates a key request to the IoT platform based on the username and password. Based on the key request, the IoT platform's server verifies the validity of the username and password, generates a key for the IoT device, returns the key to the IoT device, and stores the username, key, and key validity period in the IoT platform's server-side Redis. The key includes a user key and a refresh key. The user key is used for authorization, and the refresh key is used to refresh the user key. The key validity period is customized based on the data reporting cycle. The username serves as the unique device identifier for the physical network device.
[0044] As a specific implementation of key generation, for user keys, the username and user key are converted into key values based on predetermined rules, and an expiration policy is configured for the user key. The key value corresponding to the user key and the expiration policy are stored in the Redis server of the IoT platform. The expiration policy of the user key is to use N times the default data reporting interval of the IoT device as the expiration time of the user key.
[0045] For refresh keys, the username and refresh key are converted into key values based on predetermined rules, and an expiration policy is configured for the refresh key. The key value corresponding to the refresh key and the expiration policy are stored in the Redis server of the IoT platform. The expiration policy of the refresh key is to use M times the default data reporting interval of the IoT device as the expiration time of the user key, where N and M are natural numbers, and M is greater than N.
[0046] In this embodiment, existing real IoT devices are mapped within the IoT platform. The username and password required for the device to access the platform are obtained from the IoT platform.
[0047] The device sends a request to the IoT platform's authentication service to obtain a key using its username and password. After the server verifies the validity of the username and password, it generates the relevant key for the IoT device and stores the key in Redis.
[0048] The key includes a user key and a refresh key. The user key is responsible for authorization, indicating that the information uploaded by the device is legitimate. The refresh key is used to request the server to refresh the user key after it expires.
[0049] The key storage method involves user keys and refresh keys. The user keys are as follows:
[0050] key value: Uses the device's unique identifier plus ":secret_key"
[0051] Expiration policy: The user key expires at twice the default data reporting interval of IoT devices.
[0052] The refresh key is as follows:
[0053] key value: Uses the device's unique identifier plus ":secret_key"
[0054] Expiration policy: The user key expires at a time four times the default data reporting interval of IoT devices.
[0055] Step S200 Key Verification: The IoT device reports data to the IoT platform, which carries the username and user key. The IoT platform verifies the legitimacy of the IoT device based on the user key. If the verification passes, the platform receives and processes the data; otherwise, the platform discards and refuses to process the data.
[0056] Regarding the specific implementation of key verification, when the IoT platform verifies the legitimacy of IoT devices based on user keys, after receiving data uploaded by IoT devices, it checks whether the data carries the user key. For data that does not carry the user key, the data is considered invalid, discarded, and rejected. For data that carries the user key, the following legitimacy verification is performed:
[0057] (1) Verify the correctness of the key: For the user key uploaded by the IoT device, the user key is converted into a key value based on the predetermined rules. If the generated key value is consistent with the key value stored in the Redis server, it means that the key is correct, and the validity of the key is verified.
[0058] (2) Verify the validity of the key: For the user key uploaded by the IoT device, the validity of the user key is verified based on the validity period specified in the Redis server. If the user key has not expired, the verification is passed. If the user key has expired but the corresponding refresh key is valid, the user key is updated by refreshing the key. If the user key has expired and the corresponding refresh key has expired, the key is regenerated for the IoT device by key generation.
[0059] In this embodiment, after obtaining the key through step S100, the IoT device, holding the key, can then use the key to upload data to the IoT platform.
[0060] When IoT devices report data, they need to possess a user key and ensure that the user key has not expired.
[0061] The specific steps are as follows:
[0062] (1) Every time an IoT device reports device data, it needs to carry the user's secret key;
[0063] (2) When the IoT platform's server receives a message uploaded by a device, it first checks whether the message carries a user key. Messages without a user key are considered invalid and discarded. For messages carrying a user key, their validity is verified, including:
[0064] Verify the correctness of the key: compare the user key carried in the message uploaded by the IoT device with the key stored in Redis on the server. If the two match, the key is considered correct.
[0065] Verify the validity of the key: The key in the message reported by the IoT device is converted into a key value according to the rules. If the key does not exist, and the refresh key of the device exists, it proves that the user's key has expired.
[0066] Step S300 Key Refresh: During key verification, the IoT platform verifies the user's key based on the key stored in the server Reids and the key's validity period. If the user's key has expired but the refresh key has not expired, the user's key is refreshed based on the refresh key. If both the user's key and the refresh key have expired, a new key is generated for the IoT device through key generation.
[0067] In this embodiment, key refresh includes the following three cases:
[0068] Scenario 1, before the message reporting cycle of device M: neither the user key nor the refresh key has expired. After successfully verifying the user key, the expiration time of the key in the server-side Redis is extended by M times.
[0069] Scenario 2, message reporting interval for M to N devices: The user key has expired, but the refresh key has not expired. A new user key is generated for the IoT device through key generation, and the expiration time of the key in the server-side Redis is extended by M times.
[0070] Scenario 3: More than N device message reporting intervals: Both the user key and refresh key have expired. A new key is generated for the IoT device through key generation, and the key and its expiration date are stored in the IoT platform's server-side Redis.
[0071] In this embodiment, as mentioned in step S100, the keys stored in the server-side Redis have an expiration date. If the device does not use the key after it is generated and obtained, the key will expire without the expiration time being extended.
[0072] As can be seen from step S200, after the permission verification, it can be detected whether the key has expired. If the key has expired, it needs to be refreshed.
[0073] The key refresh can be divided into the following situations:
[0074] ① Two device message reporting cycles prior: The user key and refresh key have not expired. After successfully verifying the user key, the expiration time of the key in Redis is extended by twice the previous time.
[0075] ② 2-4 device message reporting intervals: The user key expires, but the refresh key does not. At this time, using the held refresh key and the device's unique identifier, a new user key is requested from the IoT platform server. The server verifies the refresh key by comparing it with the one cached in Redis using the device's unique identifier and refresh key. If successful, the server returns the new user key, and the expiration time of the original refresh key is doubled.
[0076] ③ More than 4 device message reporting intervals: Both the user key and refresh key have expired. In this case, the unique identifier and password of the device are required to request a new key from the IoT platform server.
[0077] Example 2:
[0078] This invention discloses a Redis-based IoT device permission verification system, which includes an IoT platform and IoT devices, and implements IoT device permission verification through the method disclosed in Example 1.
[0079] The IoT device initiates a key request to the IoT platform based on a username and password. Correspondingly, based on the key request, the IoT platform performs the following key generation: after verifying the validity of the username and password through the server, it generates a key for the IoT device, returns the key to the IoT device, and stores the username, key, and key validity period in the IoT platform's server-side Redis. The key includes a user key and a refresh key. The user key is used for authorization, and the refresh key is used to refresh the user key. The key validity period is customized based on the data reporting cycle. The username serves as the unique device identifier for the IoT device.
[0080] IoT devices are used to report data to the IoT platform. The data carries the username and user key. The IoT platform then performs the following actions: it verifies the legitimacy of the IoT device based on the user key. If the verification passes, the platform receives and processes the data. If the verification fails, the platform discards and rejects the data.
[0081] In a specific implementation, the IoT platform performs the following actions for user keys: converting usernames and user keys into key values based on predetermined rules, configuring expiration policies for user keys, and storing the key values corresponding to user keys and expiration policies in the IoT platform's server-side Redis. The expiration policy for user keys is to use N times the default data reporting interval of IoT devices as the expiration time for user keys.
[0082] For refresh keys, the IoT platform performs the following: converts the username and refresh key into a key value based on predetermined rules, configures an expiration policy for the refresh key, and stores the key value corresponding to the refresh key and the expiration policy in the IoT platform's server-side Redis. The expiration policy for refresh keys is to use M times the default data reporting interval of IoT devices as the expiration time of the user key, where N and M are both natural numbers, and M is greater than N.
[0083] In this embodiment, existing real IoT devices are mapped within the IoT platform. The username and password required for the device to access the platform are obtained from the IoT platform.
[0084] The device sends a request to the IoT platform's authentication service to obtain a key using its username and password. After the server verifies the validity of the username and password, it generates the relevant key for the IoT device and stores the key in Redis.
[0085] The key includes a user key and a refresh key. The user key is responsible for authorization, indicating that the information uploaded by the device is legitimate. The refresh key is used to request the server to refresh the user key after it expires.
[0086] The key storage method involves user keys and refresh keys. The user keys are as follows:
[0087] key value: Uses the device's unique identifier plus ":secret_key"
[0088] Expiration policy: The user key expires at twice the default data reporting interval of IoT devices.
[0089] The refresh key is as follows:
[0090] key value: Uses the device's unique identifier plus ":secret_key"
[0091] Expiration policy: The user key expires at a time four times the default data reporting interval of IoT devices.
[0092] During key verification, the IoT platform performs the following: It verifies the user's key based on the key stored in the server-side Reids and the key's validity period. If the user's key has expired but the refresh key has not expired, it refreshes the user's key based on the refresh key. If both the user's key and the refresh key have expired, it regenerates a key for the IoT device through key generation.
[0093] In specific implementation, the IoT platform performs the following: When verifying the legitimacy of IoT devices based on user keys, upon receiving data uploaded by the IoT device, it confirms whether the data carries the user key. For data without the user key, the data is considered invalid, discarded, and rejected. For data carrying the user key, the following legitimacy verification is performed:
[0094] (1) Verify the correctness of the key: For the user key uploaded by the IoT device, the user key is converted into a key value based on the predetermined rules. If the generated key value is consistent with the key value stored in the Redis server, it means that the key is correct, and the validity of the key is verified.
[0095] (2) Verify the validity of the key: For the user key uploaded by the IoT device, the validity of the user key is verified based on the validity period specified in the Redis server. If the user key has not expired, the verification is passed. If the user key has expired but the corresponding refresh key is valid, the user key is updated by refreshing the key. If the user key has expired and the corresponding refresh key has expired, the key is regenerated for the IoT device by key generation.
[0096] In this embodiment, after the IoT device holds the key, it can use the key to upload data to the IoT platform.
[0097] When IoT devices report data, they need to hold a user key and ensure that the user key has not expired.
[0098] The specific steps are as follows:
[0099] (1) Every time an IoT device reports device data, it needs to carry the user's secret key;
[0100] (2) When the IoT platform's server receives a message uploaded by a device, it first checks whether the message carries a user key. Messages without a user key are considered invalid and discarded. For messages carrying a user key, their validity is verified, including:
[0101] Verify the correctness of the key: compare the user key carried in the message uploaded by the IoT device with the key stored in Redis on the server. If the two match, the key is considered correct.
[0102] Verify the validity of the key: The key in the message reported by the IoT device is converted into a key value according to the rules. If the key does not exist, and the refresh key of the device exists, it proves that the user's key has expired.
[0103] During key verification, the IoT platform performs the following: It verifies the user's key based on the key stored in the server-side Reids and the key's validity period. If the user's key has expired but the refresh key has not expired, it refreshes the user's key based on the refresh key. If both the user's key and the refresh key have expired, it regenerates a key for the IoT device through key generation.
[0104] In this embodiment, key refresh includes the following three cases:
[0105] Scenario 1, before the message reporting cycle of device M: neither the user key nor the refresh key has expired. After successfully verifying the user key, the expiration time of the key in the server-side Redis is extended by M times.
[0106] Scenario 2, message reporting interval for M to N devices: The user key has expired, but the refresh key has not expired. A new user key is generated for the IoT device through key generation, and the expiration time of the key in the server-side Redis is extended by M times.
[0107] Scenario 3: More than N device message reporting intervals: Both the user key and refresh key have expired. A new key is generated for the IoT device through key generation, and the key and its expiration date are stored in the IoT platform's server-side Redis.
[0108] The system in this embodiment performs three operations: key generation, key verification, and key refresh.
[0109] During key generation, two unique keys are generated for each IoT device based on the platform-distributed unique identifier and password: a user key and a refresh key. The user key and refresh key are stored in Redis with expiration times set to be twice the data reporting interval and four times the data reporting interval, respectively.
[0110] During key verification, the device needs to include the user's key when reporting data. The server compares the user's key stored in Redis with the key carried in the reported data to determine whether it has permission to process the data.
[0111] When refreshing the key, after the device obtains the key and successfully authenticates it through data reporting, it automatically extends the expiration time of both the user key and the refresh key by two reporting intervals. If the user key expires but the refresh key has not expired, the user key can be obtained again by refreshing the key.
[0112] The present invention has been shown and described in detail above with reference to the accompanying drawings and preferred embodiments. However, the present invention is not limited to these disclosed embodiments. Based on the above embodiments, those skilled in the art will know that more embodiments of the present invention can be obtained by combining the code review methods in the different embodiments. These embodiments are also within the protection scope of the present invention.
Claims
1. A Redis-based method for verifying permissions of IoT devices, characterized in that, Includes the following steps: Key generation: The IoT device initiates a key request to the IoT platform based on a username and password. Based on the key request, the IoT platform's server verifies the validity of the username and password, generates a key for the IoT device, returns the key to the IoT device, and stores the username, key, and key validity period in the IoT platform's server-side Redis. The key includes a user key and a refresh key. The user key is used for authorization, and the refresh key is used to refresh the user key. The key validity period is customized based on the data reporting cycle. The username serves as a unique device identifier for the IoT device. Key verification: IoT devices report data to the IoT platform, and the data carries the username and user key. The IoT platform verifies the legitimacy of the IoT devices based on the user key. If the verification is successful, the platform receives and processes the data; if the verification fails, the platform discards the data and refuses to process it. Key refresh: During key verification, the IoT platform verifies the user's key based on the key stored in the server Reids and the key's validity period. If the user's key has expired but the refresh key has not expired, the user's key is refreshed based on the refresh key. If both the user's key and the refresh key have expired, a new key is generated for the IoT device through key generation. Specifically, for user keys, the username and user key are converted into key values based on predetermined rules, and an expiration policy is configured for the user key. The key value corresponding to the user key and the expiration policy are stored in the Redis server of the IoT platform. The expiration policy for user keys is to use N times the default data reporting interval of IoT devices as the expiration time of the user key. For refresh keys, the username and refresh key are converted into key values based on predetermined rules, and an expiration policy is configured for the refresh key. The key value corresponding to the refresh key and the expiration policy are stored in the Redis server of the IoT platform. The expiration policy of the refresh key is to use M times the default data reporting interval of the IoT device as the expiration time of the user key, where N and M are natural numbers, and M is greater than N.
2. The IoT device permission verification method based on Redis according to claim 1, characterized in that, When the IoT platform verifies the legitimacy of IoT devices based on user keys, after receiving data uploaded by the IoT devices, it checks whether the data carries the user key. Data without a user key is considered invalid, discarded, and rejected. For data carrying a user key, the following legitimacy verification is performed: Verify the correctness of the key: For the user key uploaded by the IoT device, the user key is converted into a key value according to the predetermined rules. If the generated key value is consistent with the key value stored in the Redis server, it means that the key is correct, and the validity of the key is verified. Verify the validity of the key: For the user key uploaded by the IoT device, verify the validity of the user key based on the validity period specified in the Redis server. If the user key has not expired, the verification is successful. If the user key has expired but the corresponding refresh key is valid, update the user key with the refresh key. If the user key has expired and the corresponding refresh key has also expired, regenerate the key for the IoT device using the key generation function.
3. The IoT device permission verification method based on Redis according to any one of claims 1-2, characterized in that, Key refresh includes the following three scenarios: Scenario 1, before the message reporting cycle of device M: neither the user key nor the refresh key has expired. After successfully verifying the user key, the expiration time of the key in the server-side Redis is extended by M times. Scenario 2, message reporting interval for M to N devices: The user key has expired, but the refresh key has not expired. A new user key is generated for the IoT device through key generation, and the expiration time of the key in the server-side Redis is extended by M times. Scenario 3: More than N device message reporting intervals: Both the user key and refresh key have expired. A new key is generated for the IoT device through key generation, and the key and its expiration date are stored in the IoT platform's server-side Redis.
4. A Redis-based IoT device permission verification system, characterized in that, The system is used to perform permission verification on IoT devices using a Redis-based IoT device permission verification method as described in any one of claims 1-3, wherein the system includes IoT devices and an IoT platform; The IoT device initiates a key request to the IoT platform based on a username and password. Correspondingly, based on the key request, the IoT platform performs the following key generation: after verifying the validity of the username and password through the server, it generates a key for the IoT device, returns the key to the IoT device, and stores the username, key, and key validity period in the IoT platform's server-side Redis. The key includes a user key and a refresh key. The user key is used for authorization, and the refresh key is used to refresh the user key. The key validity period is customized based on the data reporting cycle. The username serves as the unique device identifier for the IoT device. IoT devices are used to report data to the IoT platform. The data carries the username and user key. The IoT platform then performs the following actions: it verifies the legitimacy of the IoT device based on the user key. If the verification passes, the platform receives and processes the data. If the verification fails, the platform discards and rejects the data. During key verification, the IoT platform performs the following: It verifies the user's key based on the key stored in the server Reids and the key's validity period. If the user's key has expired but the refresh key has not expired, it refreshes the user's key based on the refresh key. If both the user's key and the refresh key have expired, it regenerates the key for the IoT device through key generation. Specifically, for user keys, the IoT platform's server converts usernames and user keys into key values based on predetermined rules, configures expiration policies for user keys, and stores the corresponding key values and expiration policies in the IoT platform's server-side Redis. The expiration policy for user keys is N times the default data reporting interval of IoT devices as the expiration time. For the refresh key, the server of the IoT platform converts the username and refresh key into a key value based on predetermined rules, configures an expiration policy for the refresh key, and stores the key value corresponding to the refresh key and the expiration policy in the Redis server of the IoT platform. The expiration policy of the refresh key is to use M times the default data reporting interval of the IoT device as the expiration time of the user key, where N and M are natural numbers, and M is greater than N.
5. The IoT device permission verification system based on Redis according to claim 4, characterized in that, When verifying the legitimacy of IoT devices based on user keys, after receiving data uploaded by the IoT device, the IoT platform performs the following: It checks whether the data carries a user key. For data without a user key, the data is considered invalid, discarded, and rejected. For data carrying a user key, the following legitimacy verification is performed: Verify the correctness of the key: For the user key uploaded by the IoT device, the user key is converted into a key value according to the predetermined rules. If the generated key value is consistent with the key value stored in the Redis server, it means that the key is correct, and the validity of the key is verified. Verify the validity of the key: For the user key uploaded by the IoT device, verify the validity of the user key based on the validity period specified in the Redis server. If the user key has not expired, the verification is successful. If the user key has expired but the corresponding refresh key is valid, update the user key with the refresh key. If the user key has expired and the corresponding refresh key has also expired, regenerate the key for the IoT device using the key generation function.
6. The Redis-based IoT device permission verification system according to any one of claims 4-5, characterized in that, Key refresh includes the following three scenarios: Scenario 1, before the message reporting cycle of device M: neither the user key nor the refresh key has expired. After successfully verifying the user key, the expiration time of the key in the server-side Redis is extended by M times. Scenario 2, message reporting interval for M to N devices: The user key has expired, but the refresh key has not expired. A new user key is generated for the IoT device through key generation, and the expiration time of the key in the server-side Redis is extended by M times. Scenario 3: More than N device message reporting intervals: Both the user key and refresh key have expired. A new key is generated for the IoT device through key generation, and the key and its expiration date are stored in the IoT platform's server-side Redis.
Citation Information
Patent Citations
Unified identity authentication interface and method based on Token
CN111371805A
Equipment information management method and device, electronic equipment and storage medium
CN112860679A