A dynamic authentication method for microservice components based on development platform

By generating authorization files on the development platform and using the authentication component to verify the identity token and number of instances of the service component, the problem of inflexible authorization control of the microservice component is solved, and refined authorization and instance management of the service component are realized to avoid Functional exceptions are eliminated and suitable for large-scale deployment.

CN118378237BActive Publication Date: 2024-10-18BEIJING JINGHANG COMPUTING & COMM RES INST
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410513392.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-26
Publication Date
2024-10-18
Estimated Expiration
2044-04-26

AI Technical Summary

Technical Problem

The authorization control of existing microservice components is inflexible and not highly granular. It is impossible to carry out fine-grained control over the specific version of the service component and the number of started service instances.

Method used

Adopt a dynamic authentication method for microservice components based on the development platform, and achieve refined authorization and verification of service components by generating authorization files and authentication components, verifying the identity token and number of instances of the service component, including using the RSA asymmetric algorithm Encryption and AES encryption algorithms, combined with the service registration center for instance management.

Benefits of technology

It achieves refined control over service component permissions and versions, avoids functional abnormalities caused by version errors, realizes dynamic authorization management of components and fine-grained control of the number of service instances, and is suitable for large-scale deployment scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118378237B_ABST
    Figure CN118378237B_ABST
Patent Text Reader

Abstract

The present invention relates to a dynamic authentication method for microservice components based on a development platform, belongs to the field of microservice technology, and solves the problem that the authorization control of existing microservice components is inflexible and not very precise. The method comprises: when applying for a project based on a development platform, generating a project project and an authorization file according to project information and selected components; the selected components include an authentication component; when the project project is deployed and run, the authentication component loads the authorization file and verifies whether it has basic authorization. If it does, other running components send the generated identity token and the service name registered in the service registration center as component information to be verified to the authentication component; the authentication component obtains the service instance information of the service registration center, verifies the component information to be verified, and forcibly offlines the service instances of unauthorized running components and service instances exceeding the number of instance authorizations. Dynamic authorization and refined control of microservice components are realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of microservice technology, and in particular to a microservice component dynamic authentication method based on a development platform. Background Art

[0002] With the popularization and application of microservice technology, in order to ensure the stability and maintainability of the application environment, the development of various platforms is deployed and constructed based on the microservice architecture.

[0003] Among the service components provided by the development platform, there is a certain interactive relationship between the versions of the service components and the basic / core components of the platform. Using incorrect versions will cause abnormalities in system functions / interfaces, etc. At the same time, there are differences in the requirements for the number of service instances in the development stage and the deployment stage of the production environment.

[0004] The traditional authorization verification mode verifies a core component in a separate application system or microservice component. Although some solutions can perform authorization management on multiple service components, they can only simply control whether the service is accessible, and cannot perform fine-grained control over the specific version of the service component or the number of service instances started. Summary of the invention

[0005] In view of the above analysis, an embodiment of the present invention aims to provide a dynamic authentication method for microservice components based on a development platform, so as to solve the problem that the authorization control of existing microservice components is inflexible and has low precision.

[0006] The embodiment of the present invention provides a method for dynamic authentication of microservice components based on a development platform, comprising the following steps:

[0007] When applying for a project based on the development platform, the corresponding project engineering and authorization files are generated according to the project information and the selected components; the selected components include the authentication component;

[0008] When the project is deployed and run, the authentication component loads the authorization file and verifies whether it has basic authorization. If it does, other running components will send the generated identity token together with the service name registered in the service registration center as the component information to be verified to the authentication component; the authentication component obtains the service instance information of the service registration center, and verifies the component information to be verified based on the authorization file and service instance information, and forcibly takes offline the service instances of unauthorized running components and the service instances that exceed the authorized number of instances.

[0009] Based on the further improvement of the above method, the authorization file is an encrypted file formed by using the private key and public key generated by the Java Keytool tool according to the project information and writing them into the key store file, and the authorization information is encrypted using the RSA asymmetric algorithm with the private key.

[0010] Based on the further improvement of the above method, the corresponding project engineering is generated, including: adding basic project information, project dependency information, build configuration information and Manifest declarations of each selected component in the POM file of the project engineering, and writing the path and password of the keystore file in the configuration file of the project engineering.

[0011] Based on further improvement of the above method, the authorization information in the authorization file includes basic authorization information and component authorization information; the basic authorization information includes the authorization time range, server IP address and MAC address; the component authorization information includes the identity token and instance authorization number of each selected component.

[0012] Based on the further improvement of the above method, the identity token of each component in the component authorization information is obtained by concatenating the identifier of each selected component and the corresponding version number and then encrypting it with MD5.

[0013] Based on the further improvement of the above method, the authentication component loads the authorization file and verifies whether it has basic authorization, including:

[0014] The authentication component obtains the authorization file from the preset directory, reads the key library file according to the configuration file of the project, extracts the public key, and then uses the RSA asymmetric algorithm to decrypt the authorization file, and obtains the basic authorization information from the decrypted authorization file;

[0015] The authentication component obtains the time, IP and MAC address of the server on which it runs and compares them with the decrypted basic authorization information. If they all match, the authentication component has basic authorization; otherwise, the authentication component does not have basic authorization.

[0016] Based on the further improvement of the above method, when the project is deployed and run, the identity token of the running component is dynamically generated by reading the MANIFEST.MF file to obtain the identifier of the running component and the corresponding version number, and then encrypting it with MD5.

[0017] Based on the further improvement of the above method, the component information to be verified is encrypted by using the AES encryption algorithm and then sent to the authentication component by calling the authentication interface of the authentication component.

[0018] Based on the further improvement of the above method, the component information to be verified is verified according to the authorization file and the service instance information, including:

[0019] After decrypting the component information to be verified, the identity token of the running component is obtained, and it is identified whether the identity token of the running component exists in the component authorization information in the decrypted authorization file. If it does not exist, or it exists but the instance authorization number is 0, the running component is not authorized; otherwise, the actual number of instances of the running component is obtained from the service instance information, and it is identified whether it is greater than the instance authorization number of the component in the component authorization information. If it is greater, the number of service instances of the running component exceeds the instance authorization number.

[0020] Based on the further improvement of the above method, the service instances that exceed the authorized number of instances are forced to go offline by sorting the service instances from small to large according to the registration time, retaining the service instances according to the authorized number of instances, and setting the status of the excess service instances to OUT_OF_SERVICE.

[0021] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:

[0022] 1. Through a unified authorization file, the permissions, version control and number of service instances of the managed service components are finely authorized and verified, which is helpful for the operation control of the platform and avoids functional abnormalities caused by using the wrong component version. At the same time, the authorization file is automatically generated when the component is selected in the development platform, and is dynamically updated online through the development platform, realizing dynamic authorization management of the component.

[0023] 2. During the permission verification process, the service component automatically obtains and submits its identity token after the service is started. The information is irreversible, avoiding the risk of data tampering. In addition, it is combined with the service registration center to achieve more fine-grained control of the number of service instances, which is suitable for unified development control and large-scale deployment of service components.

[0024] In the present invention, the above-mentioned technical solutions can also be combined with each other to achieve more preferred combination solutions. Other features and advantages of the present invention will be described in the subsequent description, and some advantages can become obvious from the description, or can be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained through the contents particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The accompanying drawings are only used for the purpose of illustrating specific embodiments and are not to be considered as limiting the present invention. In the entire drawings, the same reference symbols represent the same components;

[0026] Figure 1 This is a flow chart of a dynamic authentication method for microservice components based on a development platform in an embodiment of the present invention;

[0027] Figure 2This is a flowchart of authorization and verification centered on the authentication component in an embodiment of the present invention. DETAILED DESCRIPTION

[0028] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.

[0029] A specific embodiment of the present invention discloses a dynamic authentication method for microservice components based on a development platform, such as Figure 1 As shown, the following steps are included:

[0030] S1. When applying for a project based on the development platform, generate corresponding project engineering and authorization files according to the project information and the selected components; the selected components include the authentication component;

[0031] S2. When the project is deployed and run, the authentication component loads the authorization file and verifies whether it has basic authorization. If it does, other running components will send the generated identity token together with the service name registered in the service registration center as the component information to be verified to the authentication component; the authentication component obtains the service instance information of the service registration center, and verifies the component information to be verified based on the authorization file and service instance information, and forcibly shuts down the service instances of unauthorized running components and service instances that exceed the authorized number of instances.

[0032] It should be noted that the authorization and verification flow chart of this embodiment is as follows Figure 2 As shown, step S1 is to automatically generate an authorization file, and step S2 is to use the authentication component as the authorization verification center, connect to the service registration center, compare and verify the information of the real-time running component obtained with the loaded authorization file, and take offline the service instances that are unauthorized or exceed the authorization scope according to the verification results.

[0033] Specifically, in step S1, the development platform manages different versions of the basic platform and its service components in the project basic framework, such as: user center component, audit center component, process center component, portal component and authentication component. Each project team applies for the required versions of the components of the project through the online selection function. The development platform automatically generates the project engineering online according to the project information and the selected components, which facilitates the unified management of various projects and avoids functional abnormalities caused by component version errors.

[0034] Furthermore, the project adopts a microservice architecture. Basic project information, project dependency information, build configuration information and Manifest declarations of each selected component are added to the project's POM file (i.e., pom.xml file, the project object model file in the Maven project), and the path and password of the keystore file are written into the project's configuration file.

[0035] It should be noted that the Manifest declaration of each component includes the component's unique identifier artifactId and version number version. The keystore file is a keystore file in a specified path after private and public keys are generated using the javaKeytool tool based on project information.

[0036] Furthermore, the authorization file is an encrypted file formed by encrypting the authorization information using the RSA asymmetric algorithm and a private key. Exemplarily, the encrypted authorization information is written into a file with a suffix of .lic in a preset directory as the authorization file.

[0037] It should be noted that the authorization information in the authorization file is constructed in JSON format, including basic authorization information and component authorization information; among them, the basic authorization information includes the authorization time range, server IP address and MAC address, as well as the CPU serial number and motherboard serial number; the component authorization information includes the identity token and instance authorization number of each selected component.

[0038] Specifically, the identity token of each component in the component authorization information in the basic authorization information is obtained by concatenating the identifiers and corresponding version numbers of the selected components and encrypting them through MD5; if the instance authorization number corresponding to the component is 0, it means that the component is not authorized; if the instance authorization number is greater than 0, it indicates the number of service instances authorized for the component.

[0039] It is worth noting that the authorization file is automatically generated when applying for a project. If you want to change the authorization time or increase the number of service instances later, upload a new authorization file through the authorization file management function of the basic platform, and encrypt the authorization information in the authorization file using the same encryption method. For multiple authorization files, you can select the corresponding authorization file to activate it according to the actual situation, and only allow one authorization file to be in the activated state. Other authorization files will be automatically disabled. At the same time, the content of the activated authorization file is copied to the authorization file with a specific suffix in the preset directory, and the authentication component loads the authorization file for component permission verification.

[0040] Compared with traditional authorization management methods, step S1 dynamically generates a unified authorization file to perform refined authorization on the version, permissions and number of service instances of the selected service components, which helps the operation control of the platform and can be dynamically updated online to achieve dynamic authorization management of components.

[0041] In step S2, when the project is deployed and run, the authentication component automatically verifies whether it has basic authorization upon startup, including:

[0042] The authentication component obtains the authorization file from the preset directory, reads the key library file according to the configuration file of the project, extracts the public key, and then uses the RSA asymmetric algorithm to decrypt the authorization file, and obtains the basic authorization information from the decrypted authorization file;

[0043] The authentication component obtains the time, IP and MAC address of the server on which it runs and compares them with the decrypted basic authorization information. If they all match, the authentication component has basic authorization; otherwise, the authentication component does not have basic authorization.

[0044] It should be noted that the authentication component does not have basic authorization, including failure to obtain authorization, such as inconsistency between IP and MAC addresses, and is no longer within the authorization range, such as the current server time exceeds the authorized time range. At this time, the authentication component service is stopped, and an information reminder is given in the service console and recorded in the log.

[0045] After the authentication component has basic authorization, it can obtain the decrypted component authorization information to verify the permissions of other running components. Preferably, the identity token and instance authorization number in the decrypted component authorization information are stored in the memory in the form of key-value pairs to improve verification efficiency.

[0046] Running components refer to components that are actually running in a project. When Maven commands are used to compile and package components in a project, the identifiers and version numbers of each component in the Manifest declaration of the POM file are automatically written into the MANIFEST.MF file.

[0047] Therefore, each component managed by the development platform has added a method for obtaining an identity token. This method is automatically executed when the component is started. The identifier and corresponding version number of the running component are obtained by reading the MANIFEST.MF file. After splicing, the identity token of the running component is dynamically generated through MD5 encryption. The information is irreversible, avoiding the risk of data tampering. At the same time, each component automatically registers the service with the service registration center when it is started. For example, the service registration center uses Eureka. In the SpringCloud framework, the registered service name, service running port, and Eureka server address are set in the application.properties or application.yml configuration file.

[0048] Furthermore, the identity token automatically generated by each component and the registered service name are used together as the component information to be verified, encrypted using the AES encryption algorithm, and sent to the authentication component by calling the authentication interface of the authentication component.

[0049] The authentication component connects to the service registration center and obtains service instance information by calling the service registration center's interface, including service name, service instance ID, service instance registration time, service instance status, server IP, etc. The number of service instances can be obtained based on the service name of the running component.

[0050] Verify the component information to be verified based on the authorization file and service instance information, including:

[0051] After decrypting the component information to be verified, the identity token of the running component is obtained, and it is identified whether the identity token of the running component exists in the component authorization information in the decrypted authorization file. If it does not exist, or it exists but the instance authorization number is 0, the running component is not authorized; otherwise, the actual number of instances of the running component is obtained from the service instance information, and it is identified whether it is greater than the instance authorization number of the component in the component authorization information. If it is greater, the number of service instances of the running component exceeds the instance authorization number.

[0052] It should be noted that the status of the running service instances is UP, and the status of the service instances of the unauthorized running components is set to OUT_OF_SERVICE, and they are forced to go offline; for service instances that exceed the authorized number of instances, the service instances are sorted from small to large according to the registration time, and then the service instances are retained according to the authorized number of instances, and the status of the excess service instances is set to OUT_OF_SERVICE.

[0053] For example, if the authorized number of instances is 2 and the actual number of instances is 3, after sorting the services by registration time from small to large, the first two service instances are retained and the third service instance is forced offline.

[0054] Preferably, after the authentication is completed, the verification result is output in the console log of the server, exemplarily outputting "authorization verification successful, service name, number of instances, authorization time", or "authorization verification failed, service name, unauthorized / instance exceeds the authorization range". At the same time, the verification result is transmitted to the message center for authorized users to view.

[0055] It should be noted that when the authentication component detects that the authorization file in the preset directory has changed, step S2 is re-executed, and the authentication component re-verifies whether it has basic authorization. If it does, it triggers each running component to send the component information to be verified to the authentication component again for verification and control.

[0056] Compared with the prior art, the present embodiment provides a method for dynamic authentication of microservice components based on a development platform, which uses a unified authorization file to perform refined authorization and verification on the permissions, version control and number of service instances of the service components under management, which is helpful for the operation control of the platform and avoids functional abnormalities caused by using the wrong component version; at the same time, the authorization file is automatically generated when the component is selected in the development platform, and is dynamically updated online through the development platform, thereby realizing dynamic authorization management of the component; during the permission verification process, the service component automatically obtains and submits its identity token after the service is started, and the information is irreversible, thereby avoiding the risk of data tampering; in addition, in combination with the service registration center, more fine-grained control of the number of service instances is realized, which is suitable for application scenarios of unified development control and large-scale deployment of service components.

[0057] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.

[0058] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.

Claims

1. A dynamic authentication method for microservice components based on a development platform. It is characterized in that The following steps are involved: When applying for a project based on the development platform, a corresponding project project and authorization files are generated according to the project information and the selected components; the selected components include an authentication component; When the project is deployed and run, the authentication component loads the authorization file and verifies whether it has basic authorization. If it does, other running components send the generated identity token together with the service name registered in the service registration center as the component information to be verified to the authentication component; the authentication component obtains the service instance information of the service registration center, and verifies the component information to be verified based on the authorization file and service instance information, and forces the service instances of unauthorized running components and service instances that exceed the instance authorization number to go offline.

2. According to the dynamic authentication method of microservice components based on the development platform of claim 1, It is characterized in that The authorization file is an encrypted file formed by using the private key and public key generated by the Java Keytool tool according to the project information and writing them into the key library file, and encrypting the authorization information using the RSA asymmetric algorithm using the private key.

3. According to claim 2, the dynamic authentication method for microservice components based on the development platform, It is characterized in that The generating of the corresponding project includes: adding basic project information, project dependency information, build configuration information and Manifest declarations of each selected component in the POM file of the project, and writing the path and password of the key store file in the configuration file of the project.

4. According to claim 3, the dynamic authentication method for microservice components based on the development platform, It is characterized in that The authorization information in the authorization file includes basic authorization information and component authorization information; the basic authorization information includes the authorization time range, server IP address and MAC address; the component authorization information includes the identity token and instance authorization number of each selected component.

5. According to claim 4, the dynamic authentication method for microservice components based on the development platform, It is characterized in that The identity token of each component in the component authorization information is obtained by concatenating the identifier of each selected component and the corresponding version number and then encrypting it with MD5.

6. According to claim 4, the dynamic authentication method for microservice components based on the development platform, It is characterized in that The authentication component loads the authorization file and verifies whether it has basic authorization, including: The authentication component obtains the authorization file from the preset directory, reads the key library file according to the configuration file of the project, extracts the public key, and then uses the RSA asymmetric algorithm to decrypt the authorization file, and obtains the basic authorization information from the decrypted authorization file; The authentication component obtains the time, IP and MAC address of the server running itself and compares them with the decrypted basic authorization information. If they all match, the authentication component has basic authorization, otherwise, the authentication component does not have basic authorization.

7. According to claim 6, the dynamic authentication method for microservice components based on the development platform, It is characterized in that When the project is deployed and run, the identity token of the running component is dynamically generated by reading the MANIFEST.MF file to obtain the identifier of the running component and the corresponding version number, and then encrypting it with MD5.

8. According to claim 7, the dynamic authentication method for microservice components based on the development platform, It is characterized in that The component information to be verified is encrypted using the AES encryption algorithm and sent to the authentication component by calling the authentication interface of the authentication component.

9. According to claim 8, the dynamic authentication method for microservice components based on the development platform, It is characterized in that The verifying the component information to be verified according to the authorization file and the service instance information includes: After decrypting the component information to be verified, the identity token of the running component is obtained, and it is identified whether the identity token of the running component exists in the component authorization information in the decrypted authorization file. If it does not exist, or if it exists but the instance authorization number is 0, the running component is not authorized; otherwise, the actual number of instances of the running component is obtained from the service instance information, and it is identified whether it is greater than the instance authorization number of the component in the component authorization information. If it is greater, the number of service instances of the running component exceeds the instance authorization number.

10. According to claim 9, the dynamic authentication method for microservice components based on the development platform, It is characterized in that The service instances exceeding the authorized number of instances are forced offline by sorting the service instances from small to large according to the registration time, retaining the service instances according to the authorized number of instances, and setting the status of the redundant service instances to OUT_OF_SERVICE.

Citation Information

Patent Citations

  • Self-managed micro-service architecture and service method thereof

    CN105933448A

  • Code encryption method, device and apparatus under Spring framework and storage medium

    CN110210188A