Interface request parameter constraint method, system and equipment based on Kong gateway and medium

Through the Kong gateway plug-in and constraint determination service, the parameter constraint rules are read from the database based on user identity information, and the request parameters are judged, which solves the problem that native plug-in is difficult to set different user rules, and realizes personalized constraints and security for interface requests. Sex improvement.

CN119031038APending Publication Date: 2024-11-26BEIJING HUANENG XINRUI CONTROL TECH +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411043506.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

When the interface usage of Kong gateway increases, it is difficult to effectively set different request parameter constraint restrictions for different users.

Method used

The Kong gateway plug-in extracts the user's request parameters and identity information, and sends it to the constraint determination service. According to the user's identity information, the parameter constraint rules are read from the database, and the request parameters are judged, and whether to pass the request to realize personalized requests for different users are realized through the request. Parameter constraints.

Benefits of technology

It realizes setting different request parameter constraint restrictions for different users, improving the security and flexibility of interface requests, and ensuring that the request parameters only pass when they meet preset conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119031038A_ABST
    Figure CN119031038A_ABST
Patent Text Reader

Abstract

The invention discloses an interface request parameter constraint method, system and device based on a Kong gateway and a medium. The method comprises the following steps: obtaining a request parameter of a user request interface and user identity information; extracting request parameters and user identity information of the user through a Kong gateway plug-in, and sending the request parameters and the user identity information of the user to a constraint judgment service; extracting a parameter constraint rule according to the user identity information through a constraint judgment service, and judging the request parameter of the user according to the parameter constraint rule to obtain a constraint judgment result; according to the constraint judgment result, whether the request of the user is passed or not is judged, and when the constraint judgment result is qualified, the request of the user is passed; and when the judgment result is unqualified, the current request of the user is not passed, and the method, the system, the equipment and the medium can set different request parameter constraint restriction rules for different users.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of gateway applications, and relates to a method, system, device and medium for constraining interface request parameters based on Kong gateway. Background Art

[0002] Kong Gateway is an open source, scalable, microservice API gateway that has been widely used in organizations of all sizes around the world. The design principle of Kong Gateway is to handle service-to-service communication and achieve comprehensive management of API interfaces by providing a feature-rich platform.

[0003] One of the core advantages of Kong Gateway is its high scalability and plug-in ecology. Due to its plug-in-based architecture, users can customize and expand the functions of Kong Gateway to meet specific business needs. The request-transformer plug-in can implement related operations on interface request parameters, thereby implementing constraints on interface access. The interface access based on this plug-in has the following processes, such as Figure 1 As shown:

[0004] Different users access the business interface through the Kong gateway;

[0005] The Kong gateway obtains the request parameters of each user and passes the parameters to the request-transformer plug-in;

[0006] The request-transformer plug-in processes the request parameters into standard parameters that meet the requirements;

[0007] Access the business interface.

[0008] However, the request-transformer plug-in can only perform unified addition, deletion, and replacement operations on request parameters of different users, and play the role of request parameter constraint restriction. However, when the usage of the interface increases and different request parameter constraint restriction rules need to be set for different users, the native plug-in cannot implement this function well. Summary of the invention

[0009] The purpose of the present invention is to overcome the shortcomings of the above-mentioned prior art and provide an interface request parameter constraint method, system, device and medium based on Kong gateway. The method, system, device and medium can set different request parameter constraint restriction rules for different users.

[0010] In order to achieve the above object, the present invention adopts the following technical scheme:

[0011] In one aspect of the present invention, the interface request parameter constraint method based on Kong gateway of the present invention comprises:

[0012] Obtain the request parameters and user identity information of the user request interface;

[0013] Extract the user's request parameters and user identity information through the Kong gateway plug-in, and send the user's request parameters and user identity information to the constraint determination service;

[0014] Extracting parameter constraint rules according to user identity information through constraint determination service, determining the user's request parameters according to the parameter constraint rules, and obtaining constraint determination results;

[0015] According to the constraint determination result, it is determined whether to approve the user's request. If the constraint determination result is qualified, the user's request is approved; if the determination result is unqualified, the user's request is not approved.

[0016] The interface request parameter constraint method based on Kong gateway described in the present invention is further improved in that:

[0017] Furthermore, the request parameters include a request header, a request body and a request address.

[0018] Furthermore, the request body uses the JSON data format.

[0019] Furthermore, the process of extracting parameter constraint rules according to user identity information through the constraint determination service is as follows:

[0020] The constraint determination service periodically reads parameter constraint rules from the database based on user identity information.

[0021] Furthermore, the process of determining the user's request parameters according to the parameter constraint rules to obtain the constraint determination result is as follows:

[0022] Determine whether the user's request body contains the parameters in the parameter constraint rules. When the request body does not contain the parameters in the parameter constraint rules, the result is determined to be unqualified; when the request body contains the parameters in the parameter constraint rules, determine whether the rule field in the user's request body has an empty value passed in. When the rule field in the user's request body has an empty value passed in, the result is determined to be unqualified. When the rule field in the user's request body does not have an empty value passed in, determine whether the rule field in the user's request body meets the constraint conditions. When the rule field in the user's request body does not meet the constraint conditions, the result is determined to be unqualified. When the rule field in the user's request body meets the constraint conditions, the result is determined to be qualified.

[0023] Furthermore, when the judgment result is unqualified, an error prompt is returned.

[0024] Furthermore, it also includes:

[0025] Parameter constraint rules are set one-to-one for each user and each interface, and the parameter constraint rules are stored in a database.

[0026] In a second aspect of the present invention, the interface request parameter constraint system based on Kong gateway of the present invention comprises:

[0027] The acquisition module is used to obtain the request parameters and user identity information of the user request interface;

[0028] An extraction module, used to extract the user's request parameters and user identity information through the Kong gateway plug-in, and send the user's request parameters and user identity information to the constraint determination service;

[0029] A determination module, used to extract parameter constraint rules according to user identity information through a constraint determination service, determine the user's request parameters according to the parameter constraint rules, and obtain a constraint determination result;

[0030] The feedback module is used to determine whether to approve the user's request based on the constraint judgment result, wherein when the constraint judgment result is qualified, the user's request is approved; when the judgment result is unqualified, the user's request is not approved.

[0031] In a third aspect of the present invention, the computer device described in the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the interface request parameter constraint method based on the Kong gateway when executing the computer program.

[0032] In a fourth aspect of the present invention, the computer-readable storage medium of the present invention stores a computer program, and when the computer program is executed by a processor, the steps of the interface request parameter constraint method based on the Kong gateway are implemented.

[0033] The present invention has the following beneficial effects:

[0034] The Kong gateway-based interface request parameter constraint method, system, device and medium described in the present invention, during specific operation, extracts the user's request parameters and user identity information through the Kong gateway plug-in, extracts parameter constraint rules according to the user identity information through the constraint judgment service, judges the user's request parameters according to the parameter constraint rules, and obtains the constraint judgment result. When the constraint judgment result is qualified, the user's request is approved, thereby setting different request parameter constraint restriction rules for different users. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings:

[0036] Figure 1 This is a flowchart for the interface access of the request-transformer plug-in;

[0037] Figure 2 is a flow chart of the method of the present invention;

[0038] Figure 3 Flowchart for constraint determination service. DETAILED DESCRIPTION

[0039] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiment of the present invention. Obviously, the described embodiment is only an embodiment of a part of the present invention, not all embodiments, and is not intended to limit the scope of the present invention. In addition, in the following description, the description of well-known structures and technologies is omitted to avoid unnecessary confusion of the concepts disclosed in the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work should fall within the scope of protection of the present invention.

[0040] The accompanying drawings show schematic diagrams of structures according to embodiments disclosed in the present invention. These figures are not drawn to scale, and some details are magnified and some details may be omitted for the purpose of clear expression. The shapes of various regions and layers shown in the figures and the relative sizes and positional relationships therebetween are only exemplary, and may deviate in practice due to manufacturing tolerances or technical limitations, and those skilled in the art may additionally design regions / layers with different shapes, sizes, and relative positions according to actual needs.

[0041] Embodiment 1

[0042] refer to Figure 2 The interface request parameter constraint method based on Kong gateway of the present invention comprises the following steps:

[0043] 1) User request interface, request parameters include request header, request body and request address, wherein the request body uses JSON data format;

[0044] 2) Extract the user's request parameters and user identity information through the Kong gateway plug-in, and send the user's request parameters and user identity information to the constraint determination service;

[0045] 3) determining the request parameters of the user according to the user identity information through the constraint determination service to obtain a determination result;

[0046] 4) Based on the constraint determination result, determine whether to approve the user's request. When the determination result is qualified, the constraint determination service does not return an error prompt and approves the user's request. When the determination result is unqualified, the constraint determination service returns an error prompt and returns the error prompt to the user, and the user's request is rejected.

[0047] refer to Figure 3 , the process of step 3) is:

[0048] 31) The constraint determination service reads parameter constraint rules from the database regularly according to the user identity information;

[0049] 32) Determine whether the user's request body contains the parameters in the parameter constraint rules. When the request body does not contain the parameters in the constraint rules, an error prompt is returned. When the request body contains the parameters in the constraint rules, go to step 33);

[0050] 33) Determine whether a null value is passed into the rule field in the user's request body. If a null value is passed into the rule field in the user's request body, an error prompt is returned. If a null value is not passed into the rule field in the user's request body, go to step 34);

[0051] 34) Determine whether the rule field in the user's request body meets the constraints. When the rule field in the user's request body does not meet the constraints, an error prompt is returned. When the rule field in the user's request body meets the constraints, the result is determined to be qualified, no error prompt is returned, and the user's request is approved.

[0052] It should be noted that the reference Figure 2 The present invention uses the Kong gateway plug-in to obtain the user identity information of the request interface and the parameters in the request body, and then develops a constraint determination service. The constraint determination service is used to determine whether the request parameters meet the requirements, thereby realizing the constraint restrictions on the request parameters of different users.

[0053] Specifically, the Kong gateway plug-in is used to obtain the identity information of the interface requesting user, the requested interface information, and the request body information, which mainly includes the user's consumerId, the interface's serviceId, and the request body information. With this information, specific parameter constraint rules can be set one-to-one for each user and each interface, and the parameter constraint rules are stored in the database, which solves the problem that the Kong gateway request-transformer native plug-in can only set constraint rules for interfaces.

[0054] In addition, in combination with the Kong gateway plug-in, a constraint determination service is designed. The constraint determination service periodically reads the constraint rules stored in the database. When a user requests an interface, the interface request parameters of the user are compared to see if they meet the stored constraint rules. When the interface request parameters meet the constraint rules, the user can access the interface normally; otherwise, a prompt indicating that the parameters do not meet the rules will be returned, thereby realizing the interface request parameter constraint determination function for different users. The interface constraint determination service flow chart is shown in the figure below. Figure 3 shown.

[0055] Embodiment 2

[0056] The interface request parameter constraint system based on Kong gateway of the present invention includes:

[0057] The acquisition module is used to obtain the request parameters and user identity information of the user request interface;

[0058] An extraction module, used to extract the user's request parameters and user identity information through the Kong gateway plug-in, and send the user's request parameters and user identity information to the constraint determination service;

[0059] A determination module, used to extract parameter constraint rules according to user identity information through a constraint determination service, determine the user's request parameters according to the parameter constraint rules, and obtain a constraint determination result;

[0060] The feedback module is used to determine whether to approve the user's request based on the constraint judgment result, wherein when the constraint judgment result is qualified, the user's request is approved; when the judgment result is unqualified, the user's request is not approved.

[0061] As an implementation manner of the present invention, the request parameters include a request header, a request body and a request address.

[0062] As an implementation manner of the present invention, the request body uses the JSON data format.

[0063] As an implementation mode of the present invention, the process of extracting parameter constraint rules according to user identity information through constraint determination service is as follows:

[0064] The constraint determination service periodically reads parameter constraint rules from the database based on user identity information.

[0065] As an implementation mode of the present invention, the process of determining the user's request parameters according to the parameter constraint rule to obtain the constraint determination result is:

[0066] Determine whether the user's request body contains the parameters in the parameter constraint rules. When the request body does not contain the parameters in the parameter constraint rules, the result is determined to be unqualified; when the request body contains the parameters in the parameter constraint rules, determine whether the rule field in the user's request body has an empty value passed in. When the rule field in the user's request body has an empty value passed in, the result is determined to be unqualified. When the rule field in the user's request body does not have an empty value passed in, determine whether the rule field in the user's request body meets the constraint conditions. When the rule field in the user's request body does not meet the constraint conditions, the result is determined to be unqualified. When the rule field in the user's request body meets the constraint conditions, the result is determined to be qualified.

[0067] As an implementation mode of the present invention, when the judgment result is unqualified, an error prompt is returned.

[0068] As an embodiment of the present invention, it also includes:

[0069] Parameter constraint rules are set one-to-one for each user and each interface, and the parameter constraint rules are stored in a database.

[0070] The division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional module in each embodiment of the present application may be integrated into a processor, or may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.

[0071] Embodiment 3

[0072] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the interface request parameter constraint method based on the Kong gateway are implemented, for example, including: obtaining the request parameters and user identity information of the user request interface; extracting the user's request parameters and user identity information through the Kong gateway plug-in, and sending the user's request parameters and user identity information to the constraint judgment service; extracting parameter constraint rules according to the user identity information through the constraint judgment service, judging the user's request parameters according to the parameter constraint rules, and obtaining the constraint judgment result; judging whether to pass the user's request according to the constraint judgment result, wherein when the constraint judgment result is qualified, the user's request is passed; when the judgment result is unqualified, the user's request is not passed. Wherein, the memory may include a memory, such as a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk memory, etc.; the processor, the network interface, and the memory are connected to each other through an internal bus, and the internal bus can be an industrial standard architecture bus, a peripheral component interconnection standard bus, an extended industrial standard architecture bus, etc., and the bus can be divided into an address bus, a data bus, a control bus, etc. The memory is used to store programs, specifically, the programs may include program codes, and the program codes include computer operation instructions. The memory may include internal memory and non-volatile memory, and provide instructions and data to the processor.

[0073] Embodiment 4

[0074] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the interface request parameter constraint method based on the Kong gateway are implemented, for example, including: obtaining the request parameters and user identity information of the user request interface; extracting the user's request parameters and user identity information through the Kong gateway plug-in, and sending the user's request parameters and user identity information to the constraint judgment service; extracting parameter constraint rules according to the user identity information through the constraint judgment service, judging the user's request parameters according to the parameter constraint rules, and obtaining the constraint judgment result; judging whether to pass the user's request according to the constraint judgment result, wherein when the constraint judgment result is qualified, the user's request is passed; when the judgment result is unqualified, the user's request is not passed. Specifically, the computer-readable storage medium includes, but is not limited to, for example, volatile memory and / or non-volatile memory. The volatile memory may include random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include read-only memory (ROM), hard disk, flash memory, optical disk, magnetic disk, etc.

[0075] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0076] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0077] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0078] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0079] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A method for constraining interface request parameters based on Kong gateway, characterized in that: include: Obtain the request parameters and user identity information of the user request interface; Extract the user's request parameters and user identity information through the Kong gateway plug-in, and send the user's request parameters and user identity information to the constraint determination service; Extracting parameter constraint rules according to user identity information through constraint determination service, determining the user's request parameters according to the parameter constraint rules, and obtaining constraint determination results; According to the constraint determination result, it is determined whether to approve the user's request. If the constraint determination result is qualified, the user's request is approved; if the determination result is unqualified, the user's request is not approved.

2. According to the Kong gateway-based interface request parameter constraint method according to claim 1, it is characterized in that: The request parameters include a request header, a request body and a request address.

3. According to claim 1, the interface request parameter constraint method based on Kong gateway is characterized in that: The request body uses the JSON data format.

4. According to claim 1, the interface request parameter constraint method based on Kong gateway is characterized in that: The process of extracting parameter constraint rules according to user identity information through constraint determination service is as follows: The constraint determination service periodically reads parameter constraint rules from the database based on user identity information.

5. According to claim 4, the interface request parameter constraint method based on Kong gateway is characterized in that: The process of determining the user's request parameters according to the parameter constraint rules to obtain the constraint determination result is as follows: Determine whether the user's request body contains the parameters in the parameter constraint rules. When the request body does not contain the parameters in the parameter constraint rules, the result is determined to be unqualified; when the request body contains the parameters in the parameter constraint rules, determine whether the rule field in the user's request body has an empty value passed in. When the rule field in the user's request body has an empty value passed in, the result is determined to be unqualified. When the rule field in the user's request body does not have an empty value passed in, determine whether the rule field in the user's request body meets the constraint conditions. When the rule field in the user's request body does not meet the constraint conditions, the result is determined to be unqualified. When the rule field in the user's request body meets the constraint conditions, the result is determined to be qualified.

6. The interface request parameter constraint method based on Kong gateway according to claim 5 is characterized in that: When the judgment result is unqualified, an error prompt is returned.

7. The method for constraining interface request parameters based on Kong gateway according to claim 5, characterized in that: Also includes: Parameter constraint rules are set one-to-one for each user and each interface, and the parameter constraint rules are stored in a database.

8. An interface request parameter constraint system based on Kong gateway, characterized in that: include: The acquisition module is used to obtain the request parameters and user identity information of the user request interface; An extraction module, used to extract the user's request parameters and user identity information through the Kong gateway plug-in, and send the user's request parameters and user identity information to the constraint determination service; A determination module, used to extract parameter constraint rules according to user identity information through a constraint determination service, determine the user's request parameters according to the parameter constraint rules, and obtain a constraint determination result; The feedback module is used to determine whether to approve the user's request based on the constraint judgment result, wherein when the constraint judgment result is qualified, the user's request is approved; when the judgment result is unqualified, the user's request is not approved.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the interface request parameter constraint method based on the Kong gateway are implemented as described in any one of claims 1-7.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the interface request parameter constraint method based on Kong gateway are implemented as described in any one of claims 1 to 7.