Login authentication method and device, computer equipment and storage medium
By using the synchronization mechanism of the master system, slave system and subsystem in the multi-system login scenario, to generate and store tokens, the problems of high cost and security risks of multi-system login in the existing technology are solved, and an efficient and secure login authentication process is achieved.
Patent Information
- Application Number
- CN202411858134.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-17
- Publication Date
- 2025-04-11
AI Technical Summary
When implementing multi-system login, the existing technology needs to build a new management system or reconsider the system architecture, resulting in high labor costs and information security risks.
By selecting the master system, slave system and subsystem, the master system manages user information and organization information, synchronizes user information with the slave system, and synchronizes organization information with the subsystem. The front-end framework Nginx initiates a login request, and the master system calls to generate a token from the system's login service and stores it in Redis. The user and organization information are synchronized and consistent and logged in.
It realizes centralized data management and real-time synchronization, reduces labor costs and maintenance costs, improves system response speed and security, and simplifies the interactive logic between the front-end and the back-end.
Smart Images

Figure CN119814395A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data communication technology, and in particular to a login authentication method, device, computer equipment and storage medium. Background Art
[0002] In the architectural design of enterprise-level application systems, the collaboration between the front-end and the back-end is the key link to achieve user interaction and data processing. The front-end usually refers to the interface layer where users interact directly. It is responsible for displaying information, receiving user input, and improving user experience through a friendly user interface. The back-end plays the role of data processing and business logic implementation. It receives requests sent by the front-end, accesses the database, executes server-side logic, and returns the processing results to the front-end.
[0003] The existing method is to build a unified login for multiple systems, log in uniformly and then jump to the corresponding system. This method is equivalent to building a new management system, which requires a lot of manpower costs.
[0004] There is also the integration of multiple backends into one by connecting multiple system backend networks, and multiple frontends use the same data source, with the same data physical address, to log in. In this way, the integration of backends requires reconsidering the integration cost of system architecture changes.
[0005] There is also a system that is used as a third-party system. Each time the API is called, verification is performed to complete the corresponding business. When calling, the API needs to communicate the relevant information of the permission control required according to the business needs. The unified login platform provided by a third party requires payment to use. It is safe, but it is necessary to provide personnel and organizational information to the third party as basic data. If the information security protection is not appropriate, a large amount of information will be leaked, and the security level is low. Summary of the invention
[0006] In order to solve the above technical problems, the present invention provides a login authentication method, which adopts the following technical solution, including:
[0007] Select a master system, a slave system and a subsystem, wherein the master system is used to manage user information and organization information, the slave system is used to obtain user information from the master system, and the subsystem is used to receive organization information from the master system;
[0008] The master system synchronizes the user information with the slave system;
[0009] The main system synchronizes the organization information with the subsystem;
[0010] The front-end framework Nginx initiates a login request and calls the login interface of the main system;
[0011] After receiving the login request, the master system calls the login service of the slave system proxied by Nginx. After the slave system completes the identity authentication, it generates a unique token;
[0012] The master system and the slave system both store the token in Redis;
[0013] After the user information and the organization information are synchronized, it is verified whether both the user and the organization exist. If both exist, login is performed based on the token.
[0014] Preferably, the step of synchronizing the user information between the master system and the slave system specifically includes:
[0015] Establishing a communication connection between the master system and the slave system;
[0016] The master system compares the user information with the slave system;
[0017] According to the comparison result, the master system sends the user information that needs to be updated to the slave system;
[0018] After receiving the user information sent by the master system, the slave system performs data verification, and sends the verification result to the master system, synchronizing the confirmation information;
[0019] The master system receives synchronization confirmation information from the slave system to confirm that the user information has been successfully synchronized.
[0020] Preferably, the step of synchronizing the organization information between the main system and the subsystem specifically includes:
[0021] The main system acquires the organization information;
[0022] The main system transmits the acquired organizational information to the subsystem;
[0023] The organizational information is stored in the subsystem's database and data records are updated.
[0024] Preferably, the front-end framework Nginx initiates a login request, and the steps of calling the login interface of the main system specifically include:
[0025] Design a login form to collect user input data;
[0026] The data input by the user is converted into request parameters, and the front-end framework Nginx initiates a login request to call the login interface of the main system;
[0027] Parse the response data and process the login results.
[0028] Preferably, after receiving the login request, the master system calls the login service of the slave system of Nginx proxy, and after the slave system completes the identity authentication, the steps of generating a unique token specifically include:
[0029] The master system receives the login request from the user terminal, the login request includes user identity authentication information, and the master system forwards the user identity authentication information to the slave system through the Nginx proxy;
[0030] After the slave system receives the login request forwarded by the master system through the Nginx proxy, it performs an identity authentication operation;
[0031] If the identity authentication is successful, the slave system generates a unique token, and the slave system returns the token to the master system.
[0032] Preferably, the steps of storing the token in Redis by both the master system and the slave system specifically include:
[0033] Install and configure Redis database in the master system and the slave system respectively;
[0034] The token is stored in the Redis of the master system and the slave system respectively.
[0035] Preferably, after the user information and the organization information are synchronized to be consistent, verifying whether both the user and the organization exist, and if both exist, the step of logging in according to the token specifically includes:
[0036] After confirming that the user information is correctly associated with the organization information, verify again whether the user account exists and is active;
[0037] Reconfirm the validity of the organization information to ensure that the organization has not been deleted or its status has not changed;
[0038] If both the user and the organization pass the existence verification, a unique token is generated based on the user's identity information and organization information, and the user uses the token to log in or make access requests.
[0039] In order to solve the above technical problems, the present invention further provides a login authentication device, which adopts the following technical solution, including:
[0040] A selection module, used to select a master system, a slave system and a subsystem, wherein the master system is used to manage user information and organization information, the slave system is used to obtain user information from the master system, and the subsystem is used to receive organization information from the master system;
[0041] A user information synchronization module, used for the master system to synchronize the user information with the slave system;
[0042] An organization information synchronization module, used for the main system and the subsystem to synchronize the organization information;
[0043] A calling module is used for the front-end framework Nginx to initiate a login request and call the login interface of the main system;
[0044] A generation module is used for invoking the login service of the slave system of the Nginx proxy after the master system receives the login request, and generating a unique token after the slave system completes the identity authentication;
[0045] A storage module, used for both the master system and the slave system to store tokens in Redis;
[0046] The login module is used to verify whether the user and organization exist after the user information and the organization information are synchronized. If both exist, the login is performed according to the token.
[0047] In order to solve the above technical problems, the present invention also provides a computer device, which adopts the technical solution described below, including a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the above login authentication method when executing the computer-readable instructions.
[0048] In order to solve the above technical problems, the present invention also provides a computer-readable storage medium, which adopts the technical solution described below, and stores computer-readable instructions on the computer-readable storage medium, which implement the steps of the above login authentication method when executed by the processor.
[0049] Compared with the prior art, the present invention has the following beneficial effects:
[0050] The user information and organizational information are managed through the main system, ensuring the centralization and authority of data and facilitating unified maintenance;
[0051] The slave system obtains user information from the master system for identity authentication, thus achieving data sharing and consistency;
[0052] The subsystem receives organizational information from the main system, making the organizational structure transparent and facilitating collaborative work and authority management among subsystems;
[0053] The information synchronization mechanism between the main system and the slave system and subsystem ensures the real-time and accuracy of the data and improves the response speed of the system;
[0054] The front-end framework Nginx initiates a login request and simplifies the interaction logic between the front-end and the back-end by calling the login interface of the main system, thus improving the user experience.
[0055] The master system then calls the login service of the slave system for identity authentication. This layered design enhances the scalability and flexibility of the system.
[0056] Using Redis to store tokens not only improves data access speed, but also helps to quickly invalidate and update tokens, enhancing system security. After user information and organization information are synchronized, login verification is performed to ensure the rigor and accuracy of the login process.
[0057] It reduces labor costs and maintenance costs, can quickly meet the logging requirements in the project, improve development efficiency, and can also adapt to small programs. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to more clearly illustrate the scheme in the present invention, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0059] Figure 1 is a flow chart of an embodiment of the login authentication method of the present invention;
[0060] Figure 2 is a flow chart of mini-program login verification using the login authentication method of the present invention;
[0061] Figure 3 is an architectural diagram of a login authentication method using the present invention;
[0062] Figure 4 It is a structural diagram of an embodiment of a login authentication device of the present invention;
[0063] Figure 5 It is a schematic structural diagram of an embodiment of a computer device of the present invention. DETAILED DESCRIPTION
[0064] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present invention; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present invention; the terms "including" and "having" and any variations thereof in the specification and claims of the present invention and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present invention or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0065] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0066] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings.
[0067] It should be noted that the login authentication method provided in the embodiment of the present invention is generally executed by a server / terminal device, and accordingly, the login authentication device is generally arranged in the server / terminal device.
[0068] It should be understood that the number of terminal devices, networks and servers is only illustrative. Depending on the implementation requirements, there can be any number of terminal devices, networks and servers.
[0069] Embodiment 1
[0070] Please refer to Figure 1 , shows a flow chart of an embodiment of the login authentication method of the present invention. The login authentication method comprises the following steps:
[0071] Step S1, selecting a main system, a slave system and a subsystem, the main system is used to manage user information and organizational information, the slave system is used to obtain user information from the main system, and the subsystem is used to receive organizational information from the main system.
[0072] In this embodiment, the electronic device (e.g., server / terminal device) on which the login authentication method is running can receive the login authentication request via a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAXX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.
[0073] User information includes but is not limited to user name, contact information, work number, email address, login name, login password, etc.
[0074] Organizational information can include various types of information, such as single user information (name, contact information, etc.), business data (transaction records, inventory information, etc.), system logs (operation records, error messages, etc.), etc.
[0075] You can select one of the systems as the main system to manage user information according to business needs and obtain user information from the main system. Select one system as the main system (for example, set it as system A) and integrate user information into the main system. Then synchronize it to the subsystem (for example, set it as system B). The user name, mobile phone number, work number, email address, etc. are used to create users of the subsystem or users of the associated subsystem.
[0076] Step S2: The master system and the slave system synchronize user information.
[0077] In this embodiment, step S2, the synchronization of user information between the master system and the slave system may further include the following steps:
[0078] S21, a communication connection is established between the master system and the slave system.
[0079] An initial communication connection needs to be established between the master system and the slave system. The purpose of this step is to provide a reliable channel for subsequent data transmission and information sharing, ensuring that data can be transmitted accurately.
[0080] S22, the master system compares the user information with the slave system.
[0081] After the master system and the slave system are connected, user information comparison is required. The purpose of this step is to identify the data differences between the master system and the slave system, providing a basis for subsequent data synchronization.
[0082] S23, based on the comparison result, the master system sends the user information that needs to be updated to the slave system.
[0083] This step is to synchronize data between the master and slave systems. The purpose of this step is to update and make the data consistent, ensuring that the slave system has the same user information as the master system.
[0084] S24, after receiving the user information sent by the master system, the slave system performs data verification, and sends the verification result to the master system, synchronizing the confirmation information.
[0085] The purpose of this step is to verify the integrity and accuracy of the data and ensure that no errors or losses occurred during the data transmission process.
[0086] S25, the master system receives synchronization confirmation information from the slave system to confirm that the user information has been successfully synchronized.
[0087] The purpose of this step is to ensure the integrity and reliability of the synchronization process and provide a basis for subsequent data communication.
[0088] Step S3: The main system and the subsystem synchronize organizational information.
[0089] In this embodiment, step S3, the synchronization of the organization information between the main system and the subsystem may further include the following steps:
[0090] S31, the main system obtains organizational information.
[0091] The main system needs to filter out valuable information from a large number of information sources, which may be business data, user information, transaction records, etc. The purpose of this step is to ensure that the information processed later is accurate and useful, and to avoid useless information interfering with system performance.
[0092] S32, the main system transmits the acquired organizational information to the subsystem.
[0093] Before transmitting the organizational information to the subsystem, the slave system can format and standardize the filtered information so that both the main system and the subsystem can understand and process it correctly. This includes data type conversion, data format unification, etc. The role of this step is to ensure the compatibility of information between different systems and avoid data parsing errors.
[0094] The main system transmits the acquired organizational information to the subsystem, which involves direct connection synchronization, database log parsing synchronization, etc. The key to data transmission is to ensure the integrity and accuracy of information and avoid data loss or damage during the transmission process.
[0095] S33, the organizational information is stored in the database of the subsystem and the data record is updated.
[0096] Before the subsystem stores the organizational information, after receiving the organizational information from the main system, the subsystem parses and processes it according to actual needs. This includes decoding the data, restoring the data structure, etc. The purpose of this step is to ensure that the subsystem can correctly understand and use the received information.
[0097] The organizational information is stored in the subsystem's database and the data records are updated. This step ensures that the subsystem's data is up to date in order to provide users with accurate information services.
[0098] Step S4, the front-end framework Nginx initiates a login request and calls the login interface of the main system.
[0099] The front-end framework Nginx refers to the front-end framework Angular. Angular adopts a componentized architecture, which greatly improves the maintainability and reusability of the code. At the same time, Angular has built-in powerful data binding and dependency injection mechanisms, which simplify application state management and service management. In addition, its rich instructions and pipeline functions make DOM operations and data processing more convenient. Combined with TypeScript's static type checking, Angular also provides higher code quality and development efficiency.
[0100] In this embodiment, step S4, the front-end framework Nginx initiates a login request, and calling the login interface of the main system may specifically include the following steps:
[0101] S41, design a login form to collect user input data.
[0102] The login form is the entry point for users to interact with the system. It can include input boxes for username, password, and verification code (if necessary). These input boxes use Angular form controls (such as
[0103] `FormGroup` and `FormControl`) to facilitate data collection and processing.
[0104] When the user fills out the form and clicks the login button, Angular collects the data entered by the user. This data includes the username and password, and possibly a verification code. The collected data needs to be initially validated, such as checking whether the username and password are empty and whether they meet the format requirements.
[0105] S42, converts the data input by the user into request parameters, and the front-end framework Nginx initiates a login request and calls the login interface of the main system.
[0106] By constructing an object, the object contains fields such as `username` and `password`. If the system requires a verification code, the verification code field also needs to be included.
[0107] Use Angular's HttpClient module to configure HTTP requests. This includes setting the request method (usually POST), the request URL (the URL of the login interface), and the request headers (such as
[0108] `Content-Type` is set to `application / json`). If the system requires it, you can also set the request body to send the request parameters as a JSON string.
[0109] Use the HttpClient post method to send a login request and subscribe to the returned Observable object. Process the response data in the subscription callback function. The response data is usually a JSON object containing information on whether the login is successful.
[0110] S43, parse the response data and process the login result.
[0111] Use Angular's JSON parsing functions (such as `JSON.parse` or Angular's built-in `HttpClient` parsing function) to convert the response JSON string into a JavaScript object. Then check the status code or message field in the object to determine whether the login was successful.
[0112] Perform different actions based on the login result. If the login is successful, store the returned token on the client (such as LocalStorage or Cookie) for use in subsequent requests. If the login fails, display an error message and may require the user to re-enter their username and password.
[0113] Step S5, after receiving the login request, the master system calls the login service of the slave system of the Nginx proxy, and after the slave system completes the identity authentication, it generates a unique token.
[0114] In this embodiment, in step S5, after receiving the login request, the master system calls the login service of the slave system of the Nginx proxy. After the slave system completes the identity authentication, generating a unique token may further include the following steps:
[0115] S51, the master system receives a login request from the user, the login request includes user identity authentication information, and the master system forwards the user identity authentication information to the slave system through the Nginx proxy.
[0116] This step is the beginning of the login process, ensuring that the information entered by the user can be accurately passed to the slave system that needs to be authenticated. At the same time, the use of Nginx proxy can realize request routing and load balancing, improving the scalability and stability of the system.
[0117] S52, after receiving the login request forwarded by the master system through the Nginx proxy, the slave system performs an identity authentication operation.
[0118] Query user information and query user records in the database based on the user name.
[0119] Password validation, which uses a secure algorithm such as bcrypt to verify that the password entered by the user matches the stored encrypted password.
[0120] Multi-factor authentication (optional): If multi-factor authentication is enabled on the system, additional verification steps are required, such as entering a text message verification code or verifying through a mobile app.
[0121] Authentication is a key step in confirming the identity of a user from the system. By querying user information and verifying passwords, it can ensure that only legitimate users can log into the system. Multi-factor authentication further enhances the security of the system and prevents malicious users from accessing the system by guessing or cracking passwords.
[0122] S52, if the identity authentication is successful, a unique token is generated from the system, and the slave system returns the token to the master system.
[0123] This token is usually generated using JWT (JSON Web Token) or other encryption methods, and contains the user's identity information (such as user ID, role) and the validity period of the token. After the token is generated, it is returned to the master system from the system and finally returned to the user through the Nginx proxy.
[0124] The token generation principle is: Header and Payload encryption, Base64 encryption of Header and Payload information to form ciphertext. Signature generation, link the generated ciphertext with a period, HS256 encryption with the server secret key to generate a signature. Token combination, link the signature after the previous two ciphertexts with a period to form the final token.
[0125] A login token is a string of characters generated by the server in a network service, which is used as a token for the client to make requests. When a user successfully logs in for the first time, the server will generate a token and return it to the client. After that, the client only needs to carry this token when requesting data, without having to enter the username and password again. The main function of the token is to perform user identity authentication and authorization management. It can increase the security of the system and avoid transmitting the user's real password to different pages. At the same time, the token can also realize cross-platform login verification. Users can use the same token to log in on different web pages or applications without having to repeatedly enter login information.
[0126] The generation and return of tokens are the core of the login process. As a credential for user authentication, tokens can be used to verify the identity and permissions of users in subsequent user access. Through encryption and signature technology, the security and uniqueness of tokens can be ensured to prevent them from being forged or tampered with by malicious users.
[0127] Step S6: Both the master system and the slave system store the token in Redis.
[0128] In this embodiment, step S6, the master system and the slave system both store the token in Redis, which may specifically include the following steps:
[0129] S61, install and configure the Redis database in the master system and the slave system respectively.
[0130] Redis is a high-performance key-value storage system that supports multiple data types, such as strings, hashes, lists, and sets, and is very suitable for storing token information. After installing Redis, you need to configure the Redis server, including setting passwords, port numbers, etc., to ensure the security and availability of the Redis service.
[0131] In the master and slave systems, you need to create a connection with the Redis server. This can be achieved through Redis client libraries, such as redis-py (Python), redis-cli (command line), etc. When creating a connection, you need to specify parameters such as the host name, port number, and password of the Redis server. After the connection is successful, the master and slave systems can interact with the Redis server and perform operations such as storage, retrieval, and deletion.
[0132] S62, store the token in the Redis of the master system and the slave system respectively.
[0133] After storage, in order to improve the security of the token, you can set an expiration time for it. Once the token expires, it will no longer be valid and the user will need to log in again or authenticate. Setting the expiration time can be achieved through the Redis EXPIRE command or SETEX command. For example, you can set the expiration time of the token to 1 hour, so that even if the token is leaked, its validity period is limited.
[0134] During specific implementation, an additional field can be added to the login token to store business attribute user information of another system, so that the source system can complete its own functions while completing the business function permission control of the two systems.
[0135] During specific implementation, the main system can also provide effective token compensation. The main system provides a token that traverses all mini-program user logins to maintain the consistency of user information in multiple systems.
[0136] Step S7: After the user information and organization information are synchronized, verify whether the user and organization exist. If both exist, log in based on the token.
[0137] In this embodiment, in step S7, after the user information and the organization information are synchronized to be consistent, it is verified whether both the user and the organization exist. If both exist, logging in according to the token may further include the following steps:
[0138] S71, after confirming that the user information is correctly associated with the organization information, verify again whether the user account exists and is active.
[0139] After confirming that the user is correctly associated with the organization, the system can verify again that the user account exists and is active. This step is an important part of two-factor authentication, ensuring that the user is not only a member of the organization, but also a valid user registered with the system.
[0140] This is done to prevent illegitimate users from bypassing authentication by falsifying organizational information. It also allows for account management to ensure that all login attempts are from valid and active user accounts.
[0141] S72, reconfirm the validity of the organization information to ensure that the organization has not been deleted or the status has not been changed.
[0142] Although preliminary verification has been performed during the organization information matching phase, the validity of the organization information can be reconfirmed after the user existence verification to ensure that the organization has not been deleted or its status has not changed (such as being marked as disabled).
[0143] The purpose of this is to: enhance security, double-confirm the existence of the organization, and prevent security risks caused by changes in the organization's status. Maintain data validity, ensure that the organization information accessed by users is the latest, and avoid access problems caused by changes in the organization's status.
[0144] S72: If both the user and the organization pass the existence verification, a unique token is generated based on the user's identity information and organization information, and the user logs in or makes an access request using the token.
[0145] The purpose of this is: first, to perform stateless authentication, use tokens to achieve stateless authentication, reduce the burden on the server and improve response speed. Second, it is secure, and encrypted tokens ensure the security of data transmission and prevent information leakage.
[0146] Once the token is successfully verified, the system will record the user's login session, including the start time, validity period, and related access logs of the session. At the same time, the system will also send a successful login response to the user, which may include some additional session information (such as session ID).
[0147] This allows session tracking, recording and management of user login sessions, facilitating subsequent session management and auditing. It can also improve user experience by providing session information and optimizing the user login experience, such as automatic renewal functions.
[0148] Through step S72, token sharing can be achieved, and anti-replay and anti-tampering control can be performed.
[0149] Anti-replay control means: adopting a nonce-based request method. Nonce means a random string that is valid only once. It is required that the parameter must be different for each request. The nonce parameter of each request is stored in a set. The token can be stored in a database or cached in JSON format. Each time an HTTP request is processed, it is first determined whether the nonce of the request is in the set. If it is, it is considered an illegal request.
[0150] Anti-tampering control means that the client uses the agreed secret key to encrypt the transmitted parameters to obtain the signature value signature, and also puts the signature value into the request parameters, and sends the request to the server. The server receives the client's request and then uses the agreed secret key to sign the request parameters (except signature) again to obtain the signature value autograph. The server compares the values of signature and autograph. If the comparison is consistent, it is considered a legitimate request. If the comparison is inconsistent, it means that the parameters have been tampered with and it is considered an illegal request.
[0151] Figure 2 This is a flow chart of mini-program login verification using the login authentication method of the present invention. Figure 2 As shown in the figure, the mini program login verification process includes:
[0152] Nginx calls the login URL for system A (the master system) and then the login service of system A calls the login of Nginx proxy system B (the slave system). The two systems store the same token in redis, which can be used for authentication of normal logins.
[0153] After the user and organization are synchronized, you can log in. When logging in, you need to verify whether the user and organization exist. You can only log in if they both exist. Otherwise, you cannot log in.
[0154] After the user and organization are synchronized, you can log in. When logging in, you need to verify whether the user and organization exist. You can only log in if they both exist. Otherwise, you cannot log in.
[0155] Figure 3 is an architectural diagram of the login authentication method of the present invention. Figure 3 As shown, Nginxinx is used as the gateway control, system A adopts the original routing method (system A maintains its original routing configuration and forwarding mechanism without large-scale changes or upgrades), and system B adopts the completed routing method (not only including basic routing forwarding functions, but also covering dynamic routing protocols, routing policy optimization, fault recovery mechanism and other aspects).
[0156] System A has a web terminal and a small program. System B has a web terminal and a small program. System A uses an Nginxinx as a gateway, and system B uses an Nginxinx as a gateway.
[0157] Provide a new Nginxinx user to proxy all API calls of the merged mini-programs. One entry proxy all API requests of the mini-programs, with the focus on login requests. The redis on both sides store the same token to ensure the validity of the access.
[0158] Nginxinx login proxy is the login service of two systems. It completes multi-system login when login request is made. The other APIs do not need to modify the original system functions to realize function reuse.
[0159] Implementing this embodiment has the following beneficial effects:
[0160] The user information and organizational information are managed through the main system, ensuring the centralization and authority of data and facilitating unified maintenance;
[0161] The slave system obtains user information from the master system for identity authentication, thus achieving data sharing and consistency;
[0162] The subsystem receives organizational information from the main system, making the organizational structure transparent and facilitating collaborative work and authority management among subsystems;
[0163] The information synchronization mechanism between the main system and the slave system and subsystem ensures the real-time and accuracy of the data and improves the response speed of the system;
[0164] The front-end framework Nginx initiates a login request and simplifies the interaction logic between the front-end and the back-end by calling the login interface of the main system, thus improving the user experience.
[0165] The master system then calls the slave system's login service for identity authentication. This layered design enhances the system's scalability and flexibility.
[0166] Using Redis to store tokens not only improves data access speed, but also helps to quickly invalidate and update tokens, enhancing system security. After user information and organization information are synchronized, login verification is performed to ensure the rigor and accuracy of the login process.
[0167] One set of front-ends can correspond to multiple back-ends, reducing labor costs and maintenance costs. It can quickly meet the logging requirements in the project, improve development efficiency, and can also be adapted to small programs.
[0168] The present invention can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present invention can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present invention can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0169] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0170] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0171] Embodiment 2
[0172] Further references Figure 4 , as a response to the above Figure 1 The present invention provides an embodiment of a login authentication device, and the device embodiment is similar to Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0173] like Figure 4 As shown, the login authentication device 80 of this embodiment includes: a selection module 81, a user information synchronization module 82, an organization information synchronization module 83, a calling module 84, a generation module 85, a storage module 86 and a login module 87. Among them:
[0174] A selection module 81 is used to select a master system, a slave system and a subsystem, wherein the master system is used to manage user information and organization information, the slave system is used to obtain user information from the master system, and the subsystem is used to receive organization information from the master system;
[0175] A user information synchronization module 82, used for the master system to synchronize the user information with the slave system;
[0176] An organization information synchronization module 83, used for the main system and the subsystem to synchronize the organization information;
[0177] A calling module 84 is used for the front-end framework Nginx to initiate a login request and call the login interface of the main system;
[0178] A generating module 85 is used for the master system to call the login service of the slave system of the Nginx proxy after receiving the login request, and the slave system generates a unique token after completing the identity authentication;
[0179] Storage module 86, used for both the master system and the slave system to store tokens in Redis;
[0180] The login module 87 is used to verify whether the user and organization exist after the user information and the organization information are synchronized and consistent. If both exist, the login is performed according to the token.
[0181] Implementing this embodiment has the following beneficial effects:
[0182] The user information and organizational information are managed through the main system, ensuring the centralization and authority of data and facilitating unified maintenance;
[0183] The slave system obtains user information from the master system for identity authentication, thus achieving data sharing and consistency;
[0184] The subsystem receives organizational information from the main system, making the organizational structure transparent and facilitating collaborative work and authority management among subsystems;
[0185] The information synchronization mechanism between the main system and the slave system and subsystem ensures the real-time and accuracy of the data and improves the response speed of the system;
[0186] The front-end framework Nginx initiates a login request and simplifies the interaction logic between the front-end and the back-end by calling the login interface of the main system, thus improving the user experience.
[0187] The master system then calls the login service of the slave system for identity authentication. This layered design enhances the scalability and flexibility of the system.
[0188] Using Redis to store tokens not only improves data access speed, but also helps to quickly invalidate and update tokens, enhancing system security. After user information and organization information are synchronized, login verification is performed to ensure the rigor and accuracy of the login process.
[0189] One set of front-ends can correspond to multiple back-ends, reducing labor costs and maintenance costs. It can quickly meet the logging requirements in the project, improve development efficiency, and can also be adapted to small programs.
[0190] Embodiment 3
[0191] To solve the above technical problems, the embodiment of the present invention also provides a computer device. Figure 5 , Figure 5 This is a basic structural block diagram of the computer device in this embodiment.
[0192] The computer device 9 includes a memory 91, a processor 92, and a network interface 93 that are interconnected and communicated through a system bus. It should be noted that the figure only shows a computer device 9 having components of a memory 91, a processor 92, and a network interface 93, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to a microprocessor, an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), a digital processor (DSP), an embedded device, etc.
[0193] The computer device may be a desktop computer, a notebook computer, a PDA, a cloud server, etc. The computer device may interact with the user through a keyboard, a mouse, a remote control, a touch pad, or a voice control device.
[0194] The memory 91 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 91 may be an internal storage unit of the computer device 9, such as a hard disk or memory of the computer device 9. In other embodiments, the memory 91 may also be an external storage device of the computer device 9, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. equipped on the computer device 9. Of course, the memory 91 may also include both the internal storage unit of the computer device 9 and its external storage device. In this embodiment, the memory 91 is generally used to store the operating system and various application software installed on the computer device 9, such as computer-readable instructions of the login authentication method, etc. In addition, the memory 91 can also be used to temporarily store various types of data that have been output or are to be output.
[0195] The processor 92 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 92 is generally used to control the overall operation of the computer device 9. In this embodiment, the processor 92 is used to run the computer-readable instructions stored in the memory 91 or process data, such as running the computer-readable instructions of the login authentication method.
[0196] The network interface 93 may include a wireless network interface or a wired network interface. The network interface 93 is generally used to establish a communication connection between the computer device 9 and other electronic devices.
[0197] The beneficial effects of implementing this embodiment are: one set of front-ends can correspond to multiple back-ends, reducing labor costs and maintenance costs, being able to quickly meet the logging requirements in the project, improving development efficiency, and being able to adapt to small programs.
[0198] Embodiment 4
[0199] The present invention also provides another embodiment, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the login authentication method as described above.
[0200] The beneficial effects of implementing this embodiment are: one set of front-ends can correspond to multiple back-ends, reducing labor costs and maintenance costs, being able to quickly meet the logging requirements in the project, improving development efficiency, and being able to adapt to small programs.
[0201] 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 can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially 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 magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the various embodiment methods of the present invention.
[0202] Obviously, the embodiments described above are only some embodiments of the present invention, rather than all embodiments. The preferred embodiments of the present invention are given in the accompanying drawings, but they do not limit the patent scope of the present invention. The present invention can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present invention more thorough and comprehensive. Although the present invention has been described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific embodiments, or to perform equivalent replacements for some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of the present invention, directly or indirectly used in other related technical fields, is also within the scope of patent protection of the present invention.
Claims
1. A login authentication method, characterized in that: The steps include: Select a master system, a slave system and a subsystem, wherein the master system is used to manage user information and organization information, the slave system is used to obtain user information from the master system, and the subsystem is used to receive organization information from the master system; The master system synchronizes the user information with the slave system; The main system synchronizes the organization information with the subsystem; The front-end framework Nginx initiates a login request and calls the login interface of the main system; After receiving the login request, the master system calls the login service of the slave system proxied by Nginx. After the slave system completes the identity authentication, it generates a unique token; The master system and the slave system both store the token in Redis; After the user information and the organization information are synchronized, it is verified whether both the user and the organization exist. If both exist, login is performed based on the token.
2. The login authentication method according to claim 1, characterized in that: The step of synchronizing the user information between the master system and the slave system specifically includes: Establishing a communication connection between the master system and the slave system; The master system compares the user information with the slave system; According to the comparison result, the master system sends the user information that needs to be updated to the slave system; After receiving the user information sent by the master system, the slave system performs data verification, and sends the verification result to the master system, synchronizing the confirmation information; The master system receives synchronization confirmation information from the slave system to confirm that the user information has been successfully synchronized.
3. The login authentication method according to claim 1, characterized in that: The steps of synchronizing the organization information between the main system and the subsystem specifically include: The main system acquires the organization information; The main system transmits the acquired organizational information to the subsystem; The organizational information is stored in the subsystem's database and data records are updated.
4. The login authentication method according to claim 1, characterized in that: The steps of the front-end framework Nginx initiating a login request and calling the login interface of the main system specifically include: Design a login form to collect user input data; The data input by the user is converted into request parameters, and the front-end framework Nginx initiates a login request to call the login interface of the main system; Parse the response data and process the login results.
5. The login authentication method according to claim 1, characterized in that: After receiving the login request, the master system calls the login service of the slave system of the Nginx proxy. After the slave system completes the identity authentication, the steps of generating a unique token specifically include: The master system receives the login request from the user terminal, the login request includes user identity authentication information, and the master system forwards the user identity authentication information to the slave system through the Nginx proxy; After the slave system receives the login request forwarded by the master system through the Nginx proxy, it performs an identity authentication operation; If the identity authentication is successful, the slave system generates a unique token, and the slave system returns the token to the master system.
6. The login authentication method according to claim 1, characterized in that: The steps of storing the token in Redis by both the master system and the slave system specifically include: Install and configure Redis database in the master system and the slave system respectively; The token is stored in the Redis of the master system and the slave system respectively.
7. The login authentication method according to any one of claims 1 to 6, characterized in that: After the user information and the organization information are synchronized, the steps of verifying whether the user and the organization exist, and if both exist, logging in according to the token specifically include: After confirming that the user information is correctly associated with the organization information, verify again whether the user account exists and is active; Reconfirm the validity of the organization information to ensure that the organization has not been deleted or its status has not changed; If both the user and the organization pass the existence verification, a unique token is generated based on the user's identity information and organization information, and the user uses the token to log in or make access requests.
8. A login authentication device, characterized in that: include: A selection module, used to select a master system, a slave system and a subsystem, wherein the master system is used to manage user information and organization information, the slave system is used to obtain user information from the master system, and the subsystem is used to receive organization information from the master system; A user information synchronization module, used for the master system to synchronize the user information with the slave system; An organization information synchronization module, used for the main system and the subsystem to synchronize the organization information; A calling module is used for the front-end framework Nginx to initiate a login request and call the login interface of the main system; A generation module is used for invoking the login service of the slave system of the Nginx proxy after the master system receives the login request, and generating a unique token after the slave system completes the identity authentication; A storage module, used for both the master system and the slave system to store tokens in Redis; The login module is used to verify whether the user and organization exist after the user information and the organization information are synchronized. If both exist, the login is performed according to the token.
9. A computer device, comprising a memory and a processor, wherein the memory stores computer-readable instructions, and the processor implements the steps of the login authentication method according to any one of claims 1 to 7 when executing the computer-readable instructions.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the login authentication method according to any one of claims 1 to 7 are implemented.