Interface packaging system and method based on cloud platform
By designing a cloud platform-based interface packaging system, using databases, Redis clusters and local caches, unified management and authentication of third-party interfaces of different types of clouds is achieved, and the problem of lack of unified management steps in the existing technology is solved. Improves the efficiency and maintainability of the system.
Patent Information
- Application Number
- CN202411584430.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-07
- Publication Date
- 2025-02-14
AI Technical Summary
The lack of unified management steps in the existing technology makes it difficult to achieve unified authentication, flow control and statistics functions when integrating third-party interfaces of different types of clouds.
A cloud platform-based interface packaging system is designed, using database, Redis cluster and local cache to realize unified management and authentication of interface definitions, and through RSA2 asymmetric encryption algorithm and token mechanism, the security and reliability of the interface are ensured.
It realizes unified management and authentication of different types of interfaces, reduces the number of interface database queries, provides a unified call format, simplifies interface testing and management, and improves system efficiency and maintainability.
Smart Images

Figure CN119441334A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of interface packaging technology, for example, to a cloud platform-based interface packaging system and method. Background Art
[0002] In the process of implementing the embodiments of the present disclosure, it is found that there are at least the following problems in the related art:
[0003] Currently, the upper-layer unified interface platform is widely used, and most of them are transferred and integrated through direct transfer, lacking a unified management step.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present application, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention
[0005] In order to provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. The summary is not an extensive review, nor is it intended to identify key / critical components or delineate the scope of protection of these embodiments, but rather serves as a prelude to the detailed description that follows.
[0006] The disclosed embodiments provide a cloud platform-based interface encapsulation system and method, which aims to integrate third-party interfaces of different types of clouds, provide the same calling method to the outside world, and realize unified authentication, flow control, statistics, etc. of different types of interfaces.
[0007] In some embodiments, the system comprises:
[0008] The database is used to store interface definitions and interface parameters of different sources, different components, and different types of interfaces. The interface definition includes basic interface information, interface generation RSA2 key pair, and interface identifier. The interface information is encrypted using RSA2 asymmetric encryption, and a key pair is generated as the interface generation RSA2 key pair, and a token is generated as the interface identifier.
[0009] Redis cluster, including multiple Redis, each Redis is used to cache the interface information in a database, and the Redis cluster is queried first each time the interface is called;
[0010] Local cache, used to cache Redis data, and different assembly methods are called according to different types of interfaces;
[0011] The return message processing module performs unified processing according to different types of return message modes, realizing a unified output parameter format of the interface.
[0012] Furthermore, the interface identifier and expiration time in the database are written to Redis for use in interface verification.
[0013] Furthermore, the local cache includes a token authentication module, an interface relationship verification module, and an assembly call encoding module. When a call is initiated using a token, the token authentication module queries Redis based on the token. If the corresponding token exists in Redis, the interface identifier is obtained for verification. If the verification passes, the authentication is completed; the interface relationship verification module configures the interface verification call chain, and uses a sorted call method to perform different types of interface verification information; after the verification passes, the local cache is queried based on the interface identifier to obtain the server call method, URL, and message of the interface, and the assembly call encoding module calls different assembly methods based on different types of interface calls.
[0014] Furthermore, the local cache is provided with two MAPs. When a query is called, MAP2 is used to cache updated data first, and then the data in MAP2 is assigned to MAP1, and the data in MAP1 is used for the query.
[0015] Furthermore, when the interface changes or a new interface is added, the database is updated first, Redis is notified to re-read the database, the Redis content is updated, and finally the local cache updates the local cache content from Redis.
[0016] Furthermore, an interface document is formed by combing the platform management interface. The interface document includes the calling URL, calling method, input parameters, output parameters, description, and interface document. The interface document is maintained and managed consistently with the database.
[0017] Furthermore, this system implements unified interface testing. By traversing redis, an automated test script is written to traverse the interface and parameters and automatically initiate polling calls.
[0018] In some embodiments, the method comprises:
[0019] S01. Organize the platform management interface to form interface documents;
[0020] S02, configure the interface content to the database, configure the interface definition table and the interface parameter table;
[0021] S03. Develop engineering code for generating tokens, implement APIs, and use public keys for RSA2 encryption to generate tokens for interface call identification, write the identification and expiration time into Redis for use in interface verification;
[0022] S04. Use the token to initiate a call, query Redis based on the token, if the corresponding token exists in Redis, obtain the interface identifier for verification, and if the verification passes, the authentication is completed;
[0023] S05. Configure the interface verification call chain and use the sorting call method to perform different types of interface verification information;
[0024] S06. Query the local secondary cache according to the interface identifier, obtain the server calling method, URL and message of the interface, call different assembly methods according to different types of interfaces, and implement third-party interface calling;
[0025] S07, return message processing, unified processing according to different types of return message methods, to achieve a unified output parameter format of the interface.
[0026] Furthermore, when the platform starts, the database data is loaded and written to Redis and the local cache. When the interface information changes, the redRedis data is updated, and the local cache is updated by monitoring the changes in Redis data locally.
[0027] Furthermore, the interface document includes the calling URL, calling method, input parameters, output parameters, description, and interface document.
[0028] The cloud platform-based interface packaging system and method provided by the embodiments of the present disclosure can achieve the following technical effects:
[0029] This patent realizes unified management of interfaces from different sources through intrusive encapsulation interfaces:
[0030] 1. Use database-redis-local secondary cache to reduce the number of interface database queries.
[0031] 2. Provide a unified authentication method to manage permissions for interfaces from different sources.
[0032] 3. Transcode calls through a unified calling format to achieve unified management of all management interface calling formats.
[0033] 4. Comply with unified management rules, and the automated script directly traverses the database data for interface testing.
[0034] 5. Realize unified calling of interfaces of different source components and different calling methods.
[0035] 6. Use redis first-level cache and local second-level cache to reduce database network pressure and quickly parse interface information.
[0036] 7. Use redis+RSA2 asymmetric encryption algorithm to implement unified interface authentication.
[0037] The above general description and the following description are exemplary and explanatory only and are not intended to limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] One or more embodiments are exemplarily described by corresponding drawings, which do not limit the embodiments. Elements with the same reference numerals in the drawings are shown as similar elements, and the drawings do not constitute a scale limitation, and wherein:
[0039] Figure 1 is a functional block diagram of the system described in Example 1;
[0040] Figure 2 It is a flow chart of the method described in Example 2. DETAILED DESCRIPTION
[0041] In order to be able to understand the features and technical contents of the embodiments of the present disclosure in more detail, the implementation of the embodiments of the present disclosure is described in detail below in conjunction with the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present disclosure. In the following technical description, for the convenience of explanation, a full understanding of the disclosed embodiments is provided through multiple details. However, one or more embodiments can still be implemented without these details. In other cases, to simplify the drawings, well-known structures and devices can be simplified for display.
[0042] The terms "first", "second", etc. in the specification and claims of the embodiments of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged where appropriate, so as to describe the embodiments of the embodiments of the present disclosure described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions.
[0043] Unless otherwise stated, the term "plurality" means two or more.
[0044] In the embodiment of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B indicates: A or B.
[0045] The term "and / or" is a description of the association relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or, A and B.
[0046] The term "correspondence" may refer to an association relationship or a binding relationship. The correspondence between A and B means that there is an association relationship or a binding relationship between A and B.
[0047] Example 1
[0048] This embodiment discloses an interface encapsulation system based on a cloud platform. This system aims to integrate third-party interfaces of different types of clouds, provide the same calling method to the outside world, and realize unified authentication, flow control, statistics, etc. of different types of interfaces. Cloud platforms usually provide templates and rules for interface definitions, which can ensure the maintainability and later expansion capabilities of interfaces. At the same time, unified interface document management can also avoid the tedious process of developers looking for interface information in multiple platform documents. Detailed interface calling configuration realizes the interface automation testing process and solves the problem of interface differences from different sources.
[0049] like Figure 1 As shown, the system includes a database for storing interface definitions and interface parameters of different sources, different components, and different types of interfaces. The interface definition includes basic interface information, an RSA2 key pair generated by the interface, and an interface identifier. The interface information is encrypted using an RSA2 asymmetric encryption method, a key pair is generated as an RSA2 key pair generated by the interface, and a token is generated as an interface identifier.
[0050] Redis cluster includes multiple Redis, each Redis is used to cache the interface information in a database, and the Redis cluster is queried first each time the interface is called. Redis has the characteristics of fast reading and writing, which prevents the database from being queried each time the interface is called, thus reducing the pressure on the database.
[0051] The local cache is used to cache Redis data, and different assembly methods are called according to different types of interfaces. In this embodiment, the local cache uses the local MAP to cache redis data, and uses the AB angle method to prevent conflicts between calls and data updates. The local cache is not suitable for network data, and reading and writing are faster. Specifically, the local cache is equipped with two MAPs. When calling for query, MAP2 is used to cache the updated data first, and then the data in MAP2 is assigned to MAP1. The data in MAP1 is used for calling for query.
[0052] The return message processing module performs unified processing according to different types of return message modes, realizing a unified output parameter format of the interface.
[0053] In this embodiment, the interface identifier and expiration time in the database are written to Redis for use in interface verification. The local cache includes a token authentication module, an interface relationship verification module, and an assembly call coding module. When a call is initiated using a token, the token authentication module queries Redis based on the token. If the corresponding token exists in Redis, the interface identifier is obtained for verification. If the verification passes, the authentication is completed; the interface relationship verification module configures the interface verification call chain and uses a sorted call method to perform different types of interface verification information; after the verification passes, the local cache is queried based on the interface identifier to obtain the server-side call method, URL, and message of the interface. The assembly call coding module calls different assembly methods according to different types of interface calls.
[0054] This embodiment uses RSA2 asymmetric encryption to encrypt interface information, generate a key string, and verify the token expiration time through the expiration time set by redis. The results of asymmetric encryption are different, which can ensure the reliability and security of authentication.
[0055] To ensure data consistency, when an interface changes or a new interface is added, the database is updated first, Redis is notified to re-read the database, the Redis content is updated, and finally the local cache updates the local cache content from Redis.
[0056] This embodiment forms an interface document by combing the platform management interfaces. The interface document includes the calling URL, calling method, input parameters, output parameters, description, and interface document. The consistency of the interface document and the database is maintained and managed. Users can intuitively query the basic information, version information, description information, etc. of different interfaces.
[0057] This system can realize unified interface testing and unified platform interface calling methods. By traversing redis, it is possible to write automated test scripts, traverse interfaces and parameters, and automatically initiate polling calls.
[0058] Example 2
[0059] This embodiment discloses a cloud platform-based interface encapsulation method, which performs unified management based on interfaces of different sources, different components, and different types, differentiates calls based on protocol types, customizes assembly call methods, and performs third-party server interface calls. The proxy end provides a unified authentication method and a unified call format to the outside world, and standardizes the server interface call parameters. As shown in the figure, this method includes the following steps:
[0060] S01. Organize the platform management interface to form an interface document, including the calling URL, calling method, input parameters, output parameters, description, and interface document;
[0061] S02, configure the interface content to the database, configure the interface definition table and the interface parameter table;
[0062] S03. Develop engineering code for generating tokens, implement RSA2 encryption of API+public key, generate tokens for interface call identification, write the identification and expiration time into Redis, and use them for interface verification;
[0063] S04. Use the token to initiate a call, query Redis based on the token, if the corresponding token exists in Redis, obtain the interface identifier for verification, and if the verification passes, the authentication is completed;
[0064] S05. Configure the interface verification call chain, use the sorting call method to verify different types of interface information, and support extension;
[0065] S06, query the local secondary cache according to the interface identifier, obtain the server calling method, URL, message and other information of the interface, call different assembly methods according to different types of interfaces, and implement third-party interface calling;
[0066] S07, return message processing, unified processing according to different types of return message methods, to achieve a unified output parameter format of the interface.
[0067] S08. When the platform starts, the database data is loaded and written into Redis and the local cache. When the interface information changes, the redRedis data is updated, and the local cache is updated by monitoring the changes in Redis data.
[0068] The above description and the accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent only possible changes. Unless explicitly required, separate components and functions are optional, and the order of operation may vary. The parts and features of some embodiments may be included in or replace the parts and features of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and are not used to limit the claims. As used in the description of the embodiments and the claims, unless the context clearly indicates, the singular forms of "a", "an" and "the" are intended to include plural forms as well. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of listings containing one or more associated ones. In addition, when used in the present application, the term "comprise" and its variants "comprises" and / or comprising refer to the presence of stated features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the presence of other identical elements in the process, method or device comprising the elements. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the embodiments may refer to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.
[0069] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. The technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. The technicians may clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.
Claims
1. An interface packaging system based on a cloud platform, characterized in that: include: The database is used to store interface definitions and interface parameters of different sources, different components, and different types of interfaces. The interface definition includes basic interface information, interface generation RSA2 key pair, and interface identifier. The interface information is encrypted using RSA2 asymmetric encryption, and a key pair is generated as the interface generation RSA2 key pair, and a token is generated as the interface identifier. Redis cluster, including multiple Redis, each Redis is used to cache the interface information in a database, and query the Redis cluster first each time the interface is called; Local cache, used to cache Redis data, and different assembly methods are called according to different types of interfaces; The return message processing module performs unified processing according to different types of return message modes, realizing a unified output parameter format of the interface.
2. The cloud platform-based interface packaging system according to claim 1, characterized in that: The interface identifier and expiration time in the database are written to Redis for use in interface verification.
3. The cloud platform-based interface packaging system according to claim 2, characterized in that: The local cache includes a token authentication module, an interface relationship verification module, and an assembly call encoding module. When a call is initiated using a token, the token authentication module queries Redis based on the token. If the corresponding token exists in Redis, the interface identifier is obtained for verification. If the verification passes, the authentication is completed; the interface relationship verification module configures the interface verification call chain and uses a sorted call method to perform different types of interface verification information; after the verification passes, the local cache is queried based on the interface identifier to obtain the server call method, URL, and message of the interface. The assembly call encoding module calls different assembly methods based on different types of interface calls.
4. The cloud platform-based interface packaging system according to claim 1, characterized in that: The local cache has two MAPs. When calling for query, MAP2 is used to cache the updated data first, and then the data in MAP2 is assigned to MAP1. The data in MAP1 is used for calling for query.
5. The cloud platform-based interface packaging system according to claim 1, characterized in that: When the interface changes or a new interface is added, the database is updated first, Redis is notified to re-read the database, the Redis content is updated, and finally the local cache updates the local cache content from Redis.
6. The cloud platform-based interface packaging system according to claim 1, characterized in that: The interface documents are formed by combing the platform management interfaces. The interface documents include the calling URL, calling method, input parameters, output parameters, description, and interface documents. The consistency of the interface documents and the database is maintained and managed.
7. The cloud platform-based interface packaging system according to claim 1, characterized in that: This system implements unified interface testing. By traversing redis, an automated test script is written to traverse the interface and parameters and automatically initiate polling calls.
8. An interface encapsulation method based on a cloud platform, characterized in that: include: S01. Organize the platform management interface to form interface documents; S02, configure the interface content to the database, configure the interface definition table and the interface parameter table; S03. Develop engineering code for generating tokens, implement APIs, and use public keys for RSA2 encryption to generate tokens for interface call identification, write the identification and expiration time into Redis for use in interface verification; S04. Use the token to initiate a call, query Redis based on the token, if the corresponding token exists in Redis, obtain the interface identifier for verification, and if the verification passes, the authentication is completed; S05. Configure the interface verification call chain and use the sorting call method to perform different types of interface verification information; S06. Query the local secondary cache according to the interface identifier, obtain the server-side calling method, URL and message of the interface, call different assembly methods according to different types of interfaces, and implement third-party interface calling; S07, return message processing, unified processing according to different types of return message methods, to achieve a unified output parameter format of the interface.
9. The cloud platform-based interface encapsulation method according to claim 8, characterized in that: When the platform starts, the database data is loaded and written to Redis and the local cache. When the interface information changes, the redRedis data is updated, and the local cache is updated by monitoring the Redis data changes locally.
10. The cloud platform-based interface encapsulation method according to claim 8, characterized in that: The interface document includes the calling URL, calling method, input parameters, output parameters, description, and interface document.
Citation Information
Cited By
System and method for realizing http interface configuration scheduling based on Redis
CN120498986A