A smart parking management platform authentication method and system

By storing user information in Redis after the authentication server is successfully verified, it solves the problem of excessive load and slow response speed of the authentication server of the smart parking management platform, achieves more efficient user authentication and access rights management, and improves system security. performance and response speed.

CN118646594BActive Publication Date: 2024-10-29CHENGDU DUBO DIGITAL TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411089151.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2024-10-29
Estimated Expiration
2044-08-09

AI Technical Summary

Technical Problem

When the number of users increases, the existing authentication method of the smart parking management platform leads to problems such as excessive load pressure on the authentication server and slow request response speed.

Method used

After successful verification by the authentication server, the user information and its corresponding Token string are stored in Redis. When the client subsequently accesses the resource server, the gateway server verifies the user's identity based on the Token string in Redis, thus avoiding the need for each request. User information needs to be queried to reduce the load on the authentication server.

Benefits of technology

It relieves the load pressure on the authentication server, improves the request response speed, and ensures the security and efficiency of the access system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118646594B_ABST
    Figure CN118646594B_ABST
Patent Text Reader

Abstract

This application relates to the field of communication technology and discloses an authentication and authorization method and system for a smart parking management platform. It aims to solve the problems of excessive load on the authentication server and slow request response speed in existing smart parking management platform authentication and authorization methods. The solution mainly includes: the client sending an authentication request; the gateway server verifying the verification code, and after successful verification, routing the authentication request to the authentication server; the authentication server verifying the account and password, generating a token string after successful verification and storing it in Redis, and simultaneously issuing it to the client; the client sending a resource access request carrying the token string; the gateway server verifying the token string, and after successful verification, routing the resource access request to the resource server; and the resource server returning the corresponding resource to the client when the user has the necessary resource access permissions. This application alleviates the load pressure on the authentication server and improves the request response speed, making it particularly suitable for Android terminal devices.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and specifically to an authentication method and system for a smart parking management platform. Background Art

[0002] OAuth (Open Authorization) is an open network standard for authorizing third-party applications to access protected resources stored by resource owners, such as photos, videos, contact lists, etc., without providing usernames and passwords to third parties. OAuth is mainly used to securely delegate authorization on the Internet and is widely used in authentication and authorization scenarios. The current version is version 2.0.

[0003] At present, some smart parking management platforms on the market have built an authentication center based on Oauth2.0 for unified authentication. As a third-party user, users of the smart parking management platform can access protected resources on the resource server of the smart parking management platform through client requests after passing the authentication. The main means is to integrate OAuth2 and SpringSecurity, build an authentication server through Spring Security OAuth2 to verify the user's identity, and request resource data from the resource server after passing the authentication. Among them, Spring Security is a security framework that can provide declarative security access control solutions for Spring-based enterprise application systems.

[0004] However, in the authentication process of the existing method, each time the client requests to access the resource server, the authentication server needs to query the user information to determine whether the user has access rights. As the number of users increases, it is easy to cause performance bottlenecks in the OAuth2.0 protocol, causing excessive load pressure on the authentication server and slow request response speed. Summary of the invention

[0005] The present application aims to solve the problems of excessive load pressure on the authentication server and slow request response speed in the existing authentication and authorization method of the smart parking management platform, and proposes an authentication and authorization method and system for the smart parking management platform.

[0006] The technical solution adopted by this application to solve the above technical problems is:

[0007] In a first aspect, the present application provides an authentication method for a smart parking management platform, the method comprising:

[0008] Step 1: The client sends an authentication request including account number, password and verification code to the gateway server;

[0009] Step 2: The gateway server verifies the verification code in the authentication request. If the verification is successful, the authentication request is routed to the authentication server.

[0010] Step 3: The authentication server queries the database for user information according to the account number and password in the authentication request, wherein the user information includes at least the user type and its corresponding user authority information;

[0011] Step 4: The authentication server generates a Token string corresponding to the user type based on the queried user information, stores the user information and its corresponding Token string in Redis, and sends the Token string to the client;

[0012] Step 5: The client sends a resource access request carrying the Token string to the gateway server;

[0013] Step 6: The gateway server compares the Token string in the resource access request with the Token string in Redis. If the Token strings match, the gateway server obtains the user permission information from Redis and routes the resource access request carrying the user permission information to the resource server.

[0014] Step 7: The resource server determines whether the corresponding user has access rights to the resource corresponding to the resource access request based on the user authority information. If so, the resource server returns the resource corresponding to the resource access request to the client.

[0015] Furthermore, the step 2 further comprises:

[0016] If the gateway server fails to verify the verification code in the authentication request, a verification code error is returned to the client.

[0017] Furthermore, the step 3 also includes:

[0018] If the authentication server fails to find the user information in the database according to the account number and password in the authentication request, it returns an account number or password error to the client.

[0019] Furthermore, in step 4, the method for generating the Token string includes:

[0020] The authentication server obtains the string corresponding to the user type and the current timestamp, and generates a Token string corresponding to the user type based on the string corresponding to the user type and the current timestamp.

[0021] Furthermore, the user types include an administrator user and a parking user, the character string corresponding to the administrator user is, and the character string corresponding to the parking user is;

[0022] The formula for generating the Token string corresponding to the administrator user is:

[0023] ;

[0024] The generation formula of the Token string corresponding to the parking user is:

[0025] ;

[0026] in, Indicates the Token string corresponding to the administrator user. Indicates the Token string corresponding to the parking user. Indicates the user ID, Indicates the current timestamp, The middle number representing the current timestamp, Indicates the last digit of the current timestamp. represents the modulo operation, Indicates or.

[0027] Furthermore, the step 6 also includes:

[0028] After the gateway server compares the Token string in the resource access request with the Token string in Redis, if the Token strings do not match, a Token exception is returned to the client.

[0029] Furthermore, the step 7 also includes:

[0030] If the resource server determines, based on the user authority information, that the corresponding user does not have the access authority to the resource corresponding to the resource access request, then the resource server returns a message indicating that the corresponding user does not have the access authority to the resource.

[0031] In a second aspect, the present application provides an authentication system for a smart parking management platform, the system comprising:

[0032] The client is used to send an authentication request including an account, password and verification code to the gateway server; receive a Token string sent by the authentication server; and send a resource access request carrying the Token string to the gateway server;

[0033] The gateway server is used to verify the verification code in the authentication request. If the verification is successful, the authentication request is routed to the authentication server; the Token string in the resource access request is compared with the Token string in Redis. If the Token strings match, the user permission information is obtained from Redis, and the resource access request carrying the user permission information is routed to the resource server;

[0034] The authentication server is used to query the user information in the database according to the account and password in the authentication request, wherein the user information includes at least the user type and its corresponding user authority information; generate a Token string corresponding to the user type according to the queried user information, store the user information and its corresponding Token string in Redis, and send the Token string to the client;

[0035] The resource server is used to determine whether the corresponding user has access rights to the resource corresponding to the resource access request according to the user authority information, and if so, return the resource corresponding to the resource access request to the client.

[0036] Furthermore, the authentication server is specifically used to obtain a character string corresponding to the user type and a current timestamp, and generate a Token character string corresponding to the user type according to the character string corresponding to the user type and the current timestamp.

[0037] Furthermore, the user types include administrator users and parking users, and the character string corresponding to the administrator user is , the string corresponding to the parking user is ;

[0038] The formula for generating the Token string corresponding to the administrator user is:

[0039] ;

[0040] The generation formula of the Token string corresponding to the parking user is:

[0041] ;

[0042] in, Indicates the Token string corresponding to the administrator user. Indicates the Token string corresponding to the parking user. Indicates the user ID, Indicates the current timestamp, The middle number representing the current timestamp, Indicates the last digit of the current timestamp. represents the modulo operation, Indicates or.

[0043] The beneficial effect of the present application is that the authentication and authorization method and system of the smart parking management platform provided by the present application stores the user information and its corresponding Token string in Redis after the authentication server successfully authenticates the user. When the client subsequently requests to access the resource server, the gateway server verifies the user identity according to the Token string in Redis, and obtains the user permission information from Redis, thereby avoiding the need for the authentication server to query the user information to determine whether the user has access rights every time the client requests to access the resource server, thereby alleviating the load pressure of the authentication server, improving the request response speed, and ensuring the security and efficiency of the access system. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 A flowchart of an authentication method for a smart parking management platform provided in an embodiment of the present application;

[0045] Figure 2 A flowchart of another authentication method for a smart parking management platform provided in an embodiment of the present application;

[0046] Figure 3 A structural diagram of an authentication system for a smart parking management platform provided in an embodiment of the present application. DETAILED DESCRIPTION

[0047] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0048] The technical solution of the embodiment of the present application is applicable to the application scenario in which users of the smart parking management platform access the protected resources of its resource server, such as the administrator user or parking user of the smart parking management platform. Since the authentication center of the current smart parking management platform is based on Oauth2.0, during the authentication and authorization process, each time the client requests to access the resource server, the authentication server needs to query the user information to determine whether the user has access rights. As the number of users increases, it is easy to cause the performance bottleneck of the OAuth2.0 protocol, resulting in excessive load pressure on the authentication server and slow request response speed.

[0049] Based on this, a technical solution of the present application is proposed. In an embodiment of the present application, a client sends an authentication request including an account, a password and a verification code to a gateway server; the gateway server verifies the verification code in the authentication request, and if the verification is successful, the authentication request is routed to the authentication server; the authentication server queries the user information in the database according to the account and password in the authentication request, and the user information at least includes the user type and its corresponding user authority information; the authentication server generates a Token string corresponding to the user type according to the queried user information, stores the user information and its corresponding Token string in Redis, and sends the Token string to the client; the client sends a resource access request carrying the Token string to the gateway server; the gateway server compares the Token string in the resource access request with the Token string in Redis, and if the Token strings match, the user authority information is obtained from Redis, and the resource access request carrying the user authority information is routed to the resource server; the resource server determines whether the corresponding user has access rights to the resource corresponding to the resource access request according to the user authority information, and if so, returns the resource corresponding to the resource access request to the client.

[0050] Specifically, in the embodiment of the present application, when a third-party application, i.e., a client, needs to access the resource server of the smart parking management platform, it is necessary to execute the user login authentication process and the resource access authentication process. The user can access the resource only after the login is successful. In the login authentication process, the client sends an authentication request containing an account, password, and verification, and verifies the verification code in the authentication request through the gateway server. Only after the verification code is verified, the authentication request is routed to the authentication server, and the authentication server verifies the account and password. If the user information is queried in the database, the verification is passed. At this time, a Token string corresponding to the user type is generated, and the user information and its corresponding Token string are stored in Redis, and the Token string is saved. The login authentication process is completed. In the resource access authentication process, the client needs to carry a Token string when sending a resource access request. The gateway server verifies the Token string carried in the resource access request according to the information stored in Redis. After the verification is passed, the user permission information is added to the resource access request, and the resource access request is routed to the resource server. The resource server determines whether the user has the permission for the resource based on the user permission information in the resource access request. If yes, the resource result is returned to the client. If not, "404" is returned, that is, no access rights.

[0051] In the above process, only the first time the client sends a request for access, the authentication server needs to perform authentication. When the client subsequently requests to access the resource server, the gateway server verifies the user's identity based on the Token string in Redis and obtains the user's permission information from Redis. This avoids the need for the authentication server to query user information to determine whether the user has access rights every time the client requests to access the resource server, thereby alleviating the load pressure on the authentication server, improving the request response speed, and ensuring the security and efficiency of the access system.

[0052] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.

[0053] See also Figure 1 The authentication method of the smart parking management platform provided in the embodiment of the present application includes the following steps:

[0054] S1. The client sends an authentication request including account number, password and verification code to the gateway server;

[0055] In the embodiment of the present application, the client is a third-party application, which can be a terminal program, a server program, a desktop program, etc., such as a browser, an Android APP, an IOS APP, an Alipay applet, or a WeChat applet. When a user needs to access the resource server of the smart parking management platform, an authentication request including an account, password, and verification code can be sent through the client. Among them, the user of the smart parking management platform can be an administrator user or a parking user, the account can be the user's mobile phone number, ID number, email address, etc., the password is the password set by the user when registering, and the verification code can be a text message verification code, a voice verification code, a video verification code, etc.

[0056] S2. The gateway server verifies the verification code in the authentication request. If the verification is successful, the authentication request is routed to the authentication server.

[0057] See also Figure 2After the client sends an authentication request, before the authentication request reaches the authentication server (AuthorizationServer), the gateway server (Getway Server) will first judge the legitimacy of the verification code in the authentication request. When the gateway server verifies that the verification code is legal, the authentication request will be routed to the authentication server. In an embodiment of the present application, if the gateway server fails to verify the verification code in the authentication request, the authentication request will not be routed to the authentication server, and a prompt of "verification code error" will be returned to the client so that the user can re-enter the verification code. Since the verification code is highly random and simple, by setting the verification code, malicious password cracking can be prevented, which can hinder access to malicious behaviors on the network to a certain extent.

[0058] S3. The authentication server queries the database for user information according to the account number and password in the authentication request, where the user information at least includes the user type and its corresponding user authority information;

[0059] It is understood that the database of the resource server stores the information of registered users, including the user's account, password and corresponding user information. The user information includes the user type and its corresponding user authority information. Figure 2 After receiving the authentication request, the authentication server compares and verifies the account and password in the authentication request by querying the database. Specifically, if the corresponding user information is found in the database, it means that the verification is successful, and enters S4. If the corresponding user information is not found in the database, it means that the verification is not successful. At this time, a prompt "account or password is wrong" is returned to the client so that the user can re-enter the account or password.

[0060] In an embodiment of the present application, different user types correspond to different user authority information. For example, an administrator user corresponds to administrator authority, and a parking user corresponds to parking authority. Different authorities can access different resources of the resource server.

[0061] S4. The authentication server generates a Token string corresponding to the user type according to the queried user information, stores the user information and its corresponding Token string in Redis, and sends the Token string to the client;

[0062] Specifically, when the authentication server verifies the account and password, it obtains the string corresponding to the user type and the current timestamp, and generates a Token string corresponding to the user type based on the string corresponding to the user type and the current timestamp.

[0063] In the embodiment of the present application, the string corresponding to the administrator user is , the string corresponding to the parking user is ; The formula for generating the Token string corresponding to the administrator user is:

[0064] ;

[0065] The generation formula of the Token string corresponding to the parking user is:

[0066] ;

[0067] in, Indicates the Token string corresponding to the administrator user. Indicates the Token string corresponding to the parking user. Indicates the user ID, Indicates the current timestamp, The middle number representing the current timestamp, Indicates the last digit of the current timestamp. represents the modulo operation, Indicates or. User ID can be the user's ID number, account number, unique code, etc.

[0068] See also Figure 2 After the authentication server generates the token string corresponding to the user type, it saves the token string and user information in Redis and issues the token string to the client so that the client can use the token string as access credentials. Redis is an open source key-value pair storage database written in ANSI C language, compliant with the BSD protocol, network-supported, memory-based, distributed, and optionally persistent, and provides APIs in multiple languages. By saving the token string and user information in Redis, the client can perform authentication based on the information saved in Redis when making subsequent requests to access the resource server, avoiding the need for the authentication server to query user information every time to determine whether the user has access rights, thereby alleviating the load pressure of the authentication server, improving the request response speed, and ensuring the security and efficiency of the access system.

[0069] S5. The client sends a resource access request carrying the Token string to the gateway server;

[0070] Users of the smart parking management platform need to access the corresponding protected resources under the resource server. When sending a resource access request through the client, it is necessary to carry the Token string issued by the authentication server in the resource access request.

[0071] S6. The gateway server compares the Token string in the resource access request with the Token string in Redis. If the Token strings match, the gateway server obtains the user permission information from Redis and routes the resource access request carrying the user permission information to the resource server.

[0072] See also Figure 2 After the client sends a resource access request, the gateway server verifies the Token string carried in the resource access request, that is, it compares the Token string carried in the resource access request with the Token string in Redis. If the Token strings match, it means that the verification is successful. At this time, the user permission information is obtained from Redis, the user permission information is added to the resource access request, and the resource access request carrying the user permission information is routed to the resource server for access. If the Token strings do not match, it means that the verification fails. At this time, a "Token exception" prompt is returned to the client so that the user can re-login and authenticate.

[0073] S7. The resource server determines whether the corresponding user has access rights to the resource corresponding to the resource access request according to the user authority information. If so, the resource server returns the resource corresponding to the resource access request to the client.

[0074] See also Figure 2 After receiving a resource access request carrying user permission information, the resource server determines whether the corresponding user has the access permission to the resource requested in the resource access request based on the user permission information. If the corresponding user has the access permission, the resource server responds and returns the resource requested by the corresponding user to the corresponding client. If the corresponding user does not have the access permission, the resource server returns a "404" prompt to the client, which means "no access permission".

[0075] To summarize, the authentication and authorization method of the smart parking management platform provided in the embodiment of the present application stores the user information and its corresponding Token string in Redis after the authentication server successfully authenticates the user. When the client subsequently requests to access the resource server, the gateway server verifies the user identity according to the Token string in Redis, and obtains the user permission information from Redis, thereby avoiding the need for the authentication server to query the user information to determine whether the user has access rights every time the client requests to access the resource server, thereby alleviating the load pressure on the authentication server, improving the request response speed, and ensuring the security and efficiency of the access system.

[0076] Based on the above technical solution, this embodiment also proposes an authentication system for a smart parking management platform. Figure 3 , the system comprising:

[0077] The client is used to send an authentication request including an account, password and verification code to the gateway server; receive a Token string sent by the authentication server; and send a resource access request carrying the Token string to the gateway server;

[0078] The gateway server is used to verify the verification code in the authentication request. If the verification is successful, the authentication request is routed to the authentication server; the Token string in the resource access request is compared with the Token string in Redis. If the Token strings match, the user permission information is obtained from Redis, and the resource access request carrying the user permission information is routed to the resource server;

[0079] The authentication server is used to query the user information in the database according to the account and password in the authentication request, wherein the user information includes at least the user type and its corresponding user authority information; generate a Token string corresponding to the user type according to the queried user information, store the user information and its corresponding Token string in Redis, and send the Token string to the client;

[0080] The resource server is used to determine whether the corresponding user has access rights to the resource corresponding to the resource access request according to the user authority information, and if so, return the resource corresponding to the resource access request to the client.

[0081] It can be understood that since the authentication and authorization system of the smart parking management platform described in the embodiment of the present application is a system for implementing the authentication and authorization method of the smart parking management platform described in the embodiment, for the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple. For relevant matters, please refer to the partial description of the method, which will not be repeated here.

Claims

1. An authentication method for a smart parking management platform, characterized in that: The method comprises: Step 1: The client sends an authentication request including account number, password and verification code to the gateway server; Step 2: The gateway server verifies the verification code in the authentication request. If the verification is successful, the authentication request is routed to the authentication server. Step 3: The authentication server queries the database for user information according to the account number and password in the authentication request, wherein the user information includes at least the user type and its corresponding user authority information; Step 4: The authentication server generates a Token string corresponding to the user type based on the queried user information, stores the user information and its corresponding Token string in Redis, and sends the Token string to the client; The method for generating the Token string includes: The authentication server obtains the string corresponding to the user type and the current timestamp, and generates a Token string corresponding to the user type based on the string corresponding to the user type and the current timestamp; The user types include administrator users and parking users. The string corresponding to the administrator user is sys, and the string corresponding to the parking user is pu; The formula for generating the Token string corresponding to the administrator user is: The generation formula of the Token string corresponding to the parking user is: Among them, S1 represents the token string corresponding to the administrator user, S2 represents the token string corresponding to the parking user, i represents the user ID, t represents the current timestamp, and t n Indicates the middle number of the current timestamp, t m Indicates the last digit of the current timestamp, mod indicates the modulus operation, and ∥ indicates or; Step 5: The client sends a resource access request carrying the Token string to the gateway server; Step 6: The gateway server compares the Token string in the resource access request with the Token string in Redis. If the Token strings match, the gateway server obtains the user permission information from Redis and routes the resource access request carrying the user permission information to the resource server. Step 7: The resource server determines whether the corresponding user has access rights to the resource corresponding to the resource access request based on the user authority information. If so, the resource server returns the resource corresponding to the resource access request to the client.

2. The authentication method of the smart parking management platform according to claim 1 is characterized in that: The step 2 also includes: If the gateway server fails to verify the verification code in the authentication request, a verification code error is returned to the client.

3. The authentication method of the smart parking management platform according to claim 1 is characterized in that: The step 3 also includes: If the authentication server fails to find the user information in the database according to the account number and password in the authentication request, it returns an account number or password error to the client.

4. The authentication method of the smart parking management platform according to claim 1 is characterized in that: The step 6 also includes: After the gateway server compares the Token string in the resource access request with the Token string in Redis, if the Token strings do not match, a Token exception is returned to the client.

5. The authentication method of the smart parking management platform according to claim 1 is characterized in that: The step 7 also includes: If the resource server determines, based on the user authority information, that the corresponding user does not have the access authority to the resource corresponding to the resource access request, then the resource server returns a message indicating that the corresponding user does not have the access authority to the resource.

6. An authentication system for a smart parking management platform, characterized in that: The system comprises: The client is used to send an authentication request including an account, password and verification code to the gateway server; receive a Token string sent by the authentication server; and send a resource access request carrying the Token string to the gateway server; The gateway server is used to verify the verification code in the authentication request. If the verification is successful, the authentication request is routed to the authentication server; the Token string in the resource access request is compared with the Token string in Redis. If the Token strings match, the user permission information is obtained from Redis, and the resource access request carrying the user permission information is routed to the resource server; The authentication server is used to query the user information in the database according to the account and password in the authentication request, wherein the user information includes at least the user type and its corresponding user authority information; generate a Token string corresponding to the user type according to the queried user information, store the user information and its corresponding Token string in Redis, and send the Token string to the client; The authentication server is specifically used to obtain a character string corresponding to the user type and a current timestamp, and generate a Token character string corresponding to the user type according to the character string corresponding to the user type and the current timestamp; The user types include administrator users and parking users. The string corresponding to the administrator user is sys, and the string corresponding to the parking user is pu; The formula for generating the Token string corresponding to the administrator user is: The generation formula of the Token string corresponding to the parking user is: Among them, S1 represents the token string corresponding to the administrator user, S2 represents the token string corresponding to the parking user, i represents the user ID, t represents the current timestamp, and t n Indicates the middle number of the current timestamp, t m Indicates the last digit of the current timestamp, mod indicates the modulus operation, and ∥ indicates or; The resource server is used to determine whether the corresponding user has access rights to the resource corresponding to the resource access request according to the user authority information, and if so, return the resource corresponding to the resource access request to the client.

Citation Information

Patent Citations

  • Gateway routing forwarding based authentication method

    CN108512784A

  • Duplex full-duplex communication method and device, computer equipment and storage medium

    CN112689014A

  • Zero-trust forestry Internet of Things management platform system and security protection method

    CN117749533A

  • API gateway rapid authentication method based on Redis

    CN118400177A