Multi-dimensional security management method and system based on API gateway, and medium

By introducing dynamic signature and adaptive encryption and decryption mechanisms in the API gateway, the problem of difficult balance between API gateway security and performance in existing technologies is solved, efficient and flexible security management is achieved, and the security and stability of the system are improved.

CN120729601APending Publication Date: 2025-09-30ZHIJI AUTOMOTIVE TECH CO LTD

Patent Information

Application Number
CN202510976513.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-16
Publication Date
2025-09-30

AI Technical Summary

Technical Problem

Existing API gateway security protection solutions are unable to cope with complex security challenges, including identity forgery, data theft, man-in-the-middle attacks, and API abuse. Traditional encryption and authentication mechanisms are difficult to adjust dynamically, making it difficult to balance system security and performance. The system is also highly complex, making it difficult to deploy and manage flexibly.

Method used

A dynamic signature mechanism based on URL path, User-Agent, and IP address is adopted, combined with multi-round hashing algorithms to generate signatures, dynamically select encryption and decryption algorithms, perform anomaly detection and dynamic key rotation, and achieve full-process encryption and decryption and flexible configuration management.

Benefits of technology

It significantly improves the security of request verification, reduces the success rate of forged requests and replay attacks, optimizes system performance, enhances system adaptability and stability, reduces the risk of data leakage, and simplifies security policy deployment and operation and maintenance processes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120729601A_ABST
    Figure CN120729601A_ABST
Patent Text Reader

Abstract

The invention relates to a multi-dimensional security management method and system based on an API gateway and a medium, and the method comprises the steps: receiving a request sent by a client, the request comprising a dynamic signature generated based on a URL path, a User-Agent and an IP address; verifying the validity of the dynamic signature, and if the dynamic signature is valid, selecting a proper encryption and decryption algorithm; decrypting the request by using the encryption and decryption algorithm, and forwarding the decrypted request to a back-end service; and receiving a response of the back-end service, encrypting the response and generating a new signature, and returning the encrypted response to the client. A more intelligent and flexible API security management scheme is provided, and the functions of dynamic encryption, multi-dimensional authentication, self-adaptive security policy and the like can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network security technology, and in particular to a multi-dimensional security management method, system and medium based on an API gateway. Background Art

[0002] With the rapid development of internet technology, APIs (Application Programming Interfaces) have become a crucial means for exchanging data and invoking functions between different software systems and services. As a core component of API management, API gateways play a crucial role in microservices architectures, responsible for API routing, authentication, rate limiting, and other functions. However, as API usage continues to expand, the security threats they face are also increasing, including but not limited to identity forgery, data theft, man-in-the-middle attacks, replay attacks, and API abuse.

[0003] Existing technologies such as the API security protection solutions described in CN111291548A and US10855693B2 often use static encryption and authentication mechanisms, which are difficult to cope with increasingly complex security challenges. For example, fixed encryption algorithms (such as a single AES-256 or RSA) and unchanging key usage cycles can be easily cracked by attackers through long-term monitoring and analysis; a single token or password authentication method cannot meet the needs of scenarios with different security levels; there is a lack of the ability to dynamically adjust encryption strength according to the network environment, request characteristics, and system load, resulting in a difficult balance between system security and performance; in addition, existing solutions usually couple security functions with business logic, which increases the complexity of the system and is not conducive to flexible deployment and unified management. When security policies need to be updated, it is often necessary to modify the business code or even restart the service. Summary of the Invention

[0004] In view of the shortcomings of the existing technology mentioned above, the purpose of the present invention is to provide a multi-dimensional security management method, system and medium based on API gateway, providing a more intelligent and flexible API security management solution that can realize functions such as dynamic encryption, multi-dimensional authentication, and adaptive security policies.

[0005] To achieve the above objectives, the present invention adopts the following technical solutions.

[0006] In the first aspect, the present invention provides a multi-dimensional security management method based on an API gateway, which adopts the following technical solutions: Receive a request from a client, the request including a dynamic signature generated based on a URL path, a User-Agent, and an IP address; Verify the validity of the dynamic signature and select an appropriate encryption and decryption algorithm if it is valid; Decrypt the request using the encryption and decryption algorithm, and forward the decrypted request to the backend service; and Receive the response from the backend service, encrypt the response and generate a new signature, and return the encrypted response to the client.

[0007] Furthermore, in the above-mentioned multi-dimensional security management method, the receiving request sent by the client, wherein the request includes a dynamic signature generated based on the URL path, User-Agent and IP address, includes: Receive requests sent by the client; Extracting URL path, User-Agent, and IP address information from the request; A dynamic signature is generated based on the extracted information.

[0008] Furthermore, in the above-mentioned multi-dimensional security management method, the generation of the dynamic signature also includes using multiple rounds of hash algorithms to process the extracted information, including: using the MD5 algorithm to generate a first hash value for the URL path, using the SHA-1 algorithm to generate a second hash value for the User-Agent, and using the SHA-256 algorithm to generate a third hash value for the IP address; connecting the three hash values ​​in a predetermined order and then performing a SHA-512 algorithm process to generate a final dynamic signature; the dynamic signature is also combined with the current timestamp to ensure the timeliness of the signature.

[0009] Furthermore, in the above multi-dimensional security management method, verifying the validity of the dynamic signature and selecting a suitable encryption and decryption algorithm if valid includes: Verify the validity of dynamic signature; If the signature is valid, the encryption and decryption algorithm is dynamically selected based on the request characteristics, time period, or request frequency.

[0010] Furthermore, in the above multi-dimensional security management method, the dynamic selection of encryption algorithms includes: Select the lightweight encryption algorithm ChaCha20-Poly1305 during high-load periods and the AES-GCM algorithm during low-load periods; Use cached encryption results for high-frequency requests and perform real-time encryption for low-frequency requests.

[0011] Furthermore, in the above multi-dimensional security management method, decrypting the request using the encryption and decryption algorithm and forwarding the decrypted request to the backend service includes: Decrypt the request using the selected encryption and decryption algorithm; Only necessary request header information is decrypted, and the request body remains encrypted; Forward the decrypted request to the backend service.

[0012] Furthermore, the above multi-dimensional security management method further includes: Perform anomaly detection to analyze request patterns for unusual behavior.

[0013] Furthermore, in the above multi-dimensional security management method, the execution of anomaly detection, analysis of request patterns, and checking for abnormal behavior further includes: Count the request frequency from the same IP address within a unit time, and mark it as abnormal when the frequency exceeds the preset request frequency threshold; Monitor the request failure rate of the same client within a predetermined time window and mark it as abnormal when the failure rate exceeds the preset failure rate threshold; Analyze the request path change pattern and mark frequent switching between different API paths in a short period of time as an anomaly; If any of the above abnormal behaviors are detected, the encryption algorithm will be switched from AES-GCM to ChaCha20-Poly1305 and the key length will be increased. At the same time, request throttling measures based on the token bucket algorithm will be implemented on the client.

[0014] Furthermore, the above multi-dimensional security management method further includes: Perform dynamic key rotation, which includes setting key expiration periods, generating new keys when keys are about to expire, and supporting both old and new keys during the transition period.

[0015] Furthermore, the above multi-dimensional security management method further includes: Record detailed encryption and decryption operation logs, including performance indicators and monitoring indicators.

[0016] In a second aspect, the present invention provides a multi-dimensional security management system based on an API gateway, which adopts the following technical solutions: The client is used to send a request containing a dynamic signature; API gateway, used to receive and process requests; Dynamic signature module, used to verify the validity of the signature; Adaptive encryption selector, used to select the appropriate encryption algorithm; Layered encryption module, used to encrypt and decrypt requests and responses; An anomaly detection module, used to detect abnormal requests; and The backend service is used to process the decrypted request and return a response.

[0017] Furthermore, the above multi-dimensional safety management system also includes: A key management module that performs dynamic key rotation, including setting key expiration dates, generating new keys when keys are about to expire, and supporting both old and new keys during the transition period. Log monitoring module, which records detailed encryption and decryption operation logs, including performance and monitoring indicators; and The configuration management module is used to implement dynamic configuration updates, allowing partial configuration modifications without restarting the service.

[0018] In a third aspect, the present invention provides a readable storage medium, which adopts the following technical solution: A readable storage medium stores computer instructions, which, when executed by a processor, implement the multi-dimensional security management method as described in any one of the first aspects above.

[0019] In summary, compared with the prior art, the present invention includes at least one of the following beneficial technical effects: (1) Security improvement: The present invention significantly improves the security and uniqueness of request verification by introducing a dynamic signature mechanism generated based on URL path, User-Agent and IP address, avoiding the problem that traditional static signatures are easily replayed and forged. Tests show that compared with traditional single token authentication, this solution can reduce the success rate of forged requests by 99.7% and the success rate of replay attacks by 100%; (2) Performance optimization: Combined with the adaptive encryption and decryption algorithm selection mechanism, it automatically switches to a lightweight algorithm under high load conditions, which can increase the system throughput by 40-60% and reduce the average response time by 30-45%, while maintaining data security; (3) Full-process protection: The present invention realizes the full-process encryption and decryption of requests and responses, effectively preventing man-in-the-middle attacks and data leakage, and improves the confidentiality of data transmission from partial protection of traditional solutions to full protection, reducing the risk of data leakage by more than 85%; (4) Enhanced adaptability: Through anomaly detection and dynamic response mechanisms, the system can adaptively respond to different types of attacks and load changes. Compared with traditional solutions with fixed strategies, the security protection success rate is increased by 45% and the system stability is improved by 60%; (5) Operation and maintenance convenience: Through modular design and configuration hot update, security policy changes do not require service restart, reducing system maintenance costs and downtime, and shortening security policy deployment time from hours to minutes, improving operation and maintenance efficiency by about 90%. Overall, the present invention constructs a dynamic, intelligent, and controllable API security communication system with security protection capabilities and practicality that are significantly superior to existing technologies.

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0021] Figure 1This is a flowchart of a specific embodiment of a multi-dimensional security management method based on an API gateway of the present invention.

[0022] Figure 2 This is an architectural diagram of a specific embodiment of a multi-dimensional security management system based on an API gateway of the present invention.

[0023] Figure 3 This is a process topology diagram of a specific embodiment of a multi-dimensional security management system based on an API gateway of the present invention.

[0024] Figure 4 This is a process topology diagram of another specific embodiment of a multi-dimensional security management system based on an API gateway of the present invention. DETAILED DESCRIPTION

[0025] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of this application. In addition, it should be understood that the specific embodiments described herein are only used to illustrate and explain the present application and are not used to limit the present application.

[0026] It should be noted that the order of description of the following embodiments does not limit the preferred order of the embodiments of the present application. In addition, in the following embodiments, the description of each embodiment has its own focus. For parts not described in detail in one embodiment, please refer to the relevant description of other embodiments.

[0027] The method steps described in the embodiments of the present invention may be executed in the order described in the specific implementation manner, or the execution order of each step may be adjusted according to actual needs, provided that the technical problem can be solved. The execution order of each step will not be listed here one by one.

[0028] Reference Figure 1 The embodiment of the present invention discloses a multi-dimensional security management method based on API gateway, which includes the following steps.

[0029] S1, receiving a request sent by a client, wherein the request includes a dynamic signature generated based on the URL path, User-Agent and IP address.

[0030] Specifically, before sending a request, the client first hashes the above features according to the multi-dimensional feature information of the current request, such as the URL path, User-Agent field value, and client IP address, and combines multiple hash values ​​through multiple rounds of hash algorithms (such as MD5, SHA1, SHA256) to generate a dynamic signature; the dynamic signature is sent to the API gateway together with the request. After receiving the request, the API gateway parses the above feature information and reproduces the signature calculation process to achieve uniqueness verification and anti-counterfeiting verification of the request source, thereby improving the security and anti-replay attack capability of the entire communication process.

[0031] S2, verify the validity of the dynamic signature, and if valid, select a suitable encryption and decryption algorithm.

[0032] Specifically, after receiving a request containing a dynamic signature, the API gateway first calls the signature verification module in the security management plug-in. Based on the URL path, User-Agent, client IP address and other characteristic information in the request, it uses the same multi-round hash algorithm as the client (such as MD5, SHA1, SHA256) to regenerate the signature and compare it with the dynamic signature carried in the request; if the signatures are consistent, the request is determined to be legal and has not been tampered with. After the verification is passed, the adaptive encryption algorithm selection module is called to dynamically select the adaptive encryption and decryption algorithm based on factors such as the supported algorithms declared by the client, the current system load or the request frequency, providing an algorithmic basis for subsequent security processing processes.

[0033] S3: Decrypt the request using the encryption and decryption algorithm, and forward the decrypted request to the backend service.

[0034] Specifically, after completing signature verification and selecting the encryption and decryption algorithm, the API gateway calls the encryption and decryption module to decrypt the request body according to the selected algorithm; during the decryption process, the plug-in first extracts the encryption key identifier from the request, and obtains the corresponding key through the key management module, while using the cache mechanism (such as LRU cache) to improve the key search efficiency; after decryption is completed, only the necessary plaintext request header information is retained for subsequent processing to maintain the security of the request body; then, the decrypted valid request data is forwarded to the back-end service, so that the data is kept confidential and has integrity during transmission.

[0035] S4 receives the response from the backend service, encrypts the response and generates a new signature, and returns the encrypted response to the client.

[0036] Specifically, after receiving the response data returned by the backend service, the API gateway first calls the encryption and decryption module to encrypt the response content according to the encryption and decryption algorithm selected in the previous step; then, it combines the key fields in the response (such as response timestamp, status code, data summary, etc.) and client IP and other information to generate a new dynamic signature to ensure the integrity and source credibility of the response data; finally, the encrypted response data and the new signature are encapsulated and sent back to the client to ensure the confidentiality, tamper-proofing and anti-replay capabilities of the response during transmission, thereby achieving full-process security protection of request-response.

[0037] The multi-dimensional security management method based on the API gateway described in the embodiment of the present invention achieves high-precision verification of the request source by introducing a dynamic signature mechanism generated based on multi-dimensional features (such as URL path, User-Agent and IP address). Combined with the adaptive encryption and decryption algorithm selection and end-to-end encryption and decryption processing flow, it not only effectively prevents the leakage and tampering of data during transmission, but also enhances the system's ability to resist security threats such as replay attacks and man-in-the-middle attacks. At the same time, it ensures the data integrity and confidentiality of the entire request and response process, thereby improving the security, flexibility and stability of the API gateway in the face of complex network environments.

[0038] Furthermore, as an embodiment of the present invention, step S1, receiving a request sent by a client, wherein the request includes a dynamic signature generated based on a URL path, a User-Agent, and an IP address, includes: receiving a request sent by the client; extracting the URL path, the User-Agent, and the IP address information from the request; and generating a dynamic signature based on the extracted information.

[0039] Specifically, the API gateway acts as an intermediary component between the client and the backend service, continuously listening to predefined interface addresses or ports, and supporting common protocols such as HTTP / HTTPS; when the client sends an API request with a dynamic signature through the network, the gateway immediately captures the request and connects it to the plug-in processing flow, ensuring that the request can be received completely, stably and in real time before entering the subsequent signature verification and encryption and decryption processing, thereby providing a reliable entry foundation for subsequent multi-dimensional security management.

[0040] In some implementations, after receiving a client request, the API gateway uses a built-in request parsing module to perform a structured parsing of the request message, extracting the URL path field accessed by the request, the User-Agent field in the request header, and the source IP address carried by the client when connecting. This process is implemented through the request context object provided by the Kong gateway (e.g., ngx.var.request_uri to obtain the URL path, kong.request.get_header("User-Agent") to obtain the User-Agent value, and ngx.var.remote_addr to obtain the IP address). This ensures the accurate extraction of key feature information and provides a complete data foundation for the subsequent generation of dynamic signatures. The system also records the precise timestamp of the current request, accurate to the millisecond level, to enhance the timeliness of the signature.

[0041] In some implementations, the client or API gateway uses the extracted request feature information, such as the URL path, User-Agent, and IP address, to perform the following precise steps to generate a dynamic signature: (1) Use the MD5 algorithm to hash the URL path and generate a 128-bit hash value H1; (2) Use the SHA1 algorithm to hash the User-Agent field to generate a 160-bit hash value H2; (3) Use the SHA256 algorithm to hash the IP address and generate a 256-bit hash value H3; (4) Convert the current timestamp (accurate to milliseconds) into a string and process it using the SHA256 algorithm to generate a 256-bit hash value H4; (5) Concatenate the four hash values ​​in the order of "H1+H2+H3+H4"; (6) The concatenated result is hashed using the SHA512 algorithm to generate a final 512-bit dynamic signature. The signature is highly unique and timely because it combines the request path, client identifier, source address, and time factors, effectively preventing the request from being tampered with or replayed. At the same time, the signature length is secure enough without causing significant transmission overhead, providing a reliable basis for subsequent signature verification.

[0042] Furthermore, as an embodiment of the present invention, the generation of the dynamic signature also includes processing the extracted information using a multi-round hash algorithm.

[0043] Specifically, in some implementations, different hash algorithms (e.g., MD5 for URL path, SHA1 for User-Agent, and SHA256 for IP address) may be used in sequence for the initial round of processing, and then the respective results may be concatenated and combined for a second round of hash processing to generate the final signature.

[0044] In some implementations, the three types of information may be concatenated into a unified string, which is then encrypted layer by layer using multiple rounds of different hash algorithms (such as MD5, SHA1, and SHA256).

[0045] In some implementations, a timestamp, a random number, or a request body digest may be introduced as salt information during the hashing process to improve the timeliness and uniqueness of the signature.

[0046] In addition, multiple rounds of hashing can also be implemented by using the same algorithm to repeatedly encrypt multiple times or using a configurable algorithm chain sequence to enhance the complexity and anti-forgery capabilities of the signature results.

[0047] Furthermore, as an embodiment of the present invention, verifying the validity of the dynamic signature and selecting a suitable encryption and decryption algorithm if valid includes: verifying the validity of the dynamic signature; if the signature is valid, dynamically selecting an encryption and decryption algorithm based on request characteristics, time period or request frequency.

[0048] Specifically, after receiving a request containing a dynamic signature, the API gateway calls the signature verification module to extract characteristic information from the request, such as the URL path, User-Agent, and IP address. It then recalculates this information using the same multi-round hashing algorithm as the client to generate a local signature. This locally calculated result is then compared with the dynamic signature carried in the request. If the two are identical, the signature is deemed valid, indicating that the request has not been tampered with and the source is trustworthy. To enhance security, the verification process also includes timestamp verification (requiring that the timestamp in the signature differ from the current time by no more than 30 seconds), a request sequence number (a unique identifier to prevent replay attacks, ensuring that the sequence number for each request is incremented and non-duplicate), and a signature validity period (default 5 minutes) to defend against attacks such as forgery, tampering, and replay. If the timestamp is expired or the sequence number is duplicated, the request will be rejected and a security incident will be recorded, even if the signature itself has been verified.

[0049] In some embodiments, after the signature verification is passed, the API gateway calls the adaptive encryption algorithm selection module to perform a comprehensive evaluation based on the characteristic information of the current request (such as the request source, interface path, data sensitivity level), the time period when the request occurs (such as peak or off-peak period), and the historical request frequency (such as the number of requests per unit time), and dynamically select the most suitable algorithm from the preset encryption algorithm library.

[0050] Furthermore, as an embodiment of the present invention, the dynamically selected encryption algorithm includes: The lightweight encryption algorithm ChaCha20-Poly1305 is selected during high-load periods, and the AES-GCM algorithm is selected during low-load periods; cached encryption results are used for high-frequency requests, and real-time encryption is performed for low-frequency requests.

[0051] Specifically, the API gateway continuously monitors the system load during operation. When it detects that the current system CPU usage or the number of concurrent requests exceeds the preset threshold, it automatically switches to the ChaCha20-Poly1305 algorithm, which has lower computational overhead and faster encryption and decryption speed, to reduce system pressure. During periods of low system load or higher data security requirements, the AES-GCM algorithm, which has stronger security, is given priority. At the same time, the plug-in maintains an encryption result cache pool with an LRU strategy. For high-frequency requests from the same client with the same structure, it directly reuses historical encryption results to improve response speed. For low-frequency requests or new requests that appear for the first time, the encryption module is called for real-time encryption processing, thereby achieving a dynamic balance between algorithm security, system performance, and response efficiency.

[0052] Furthermore, as an embodiment of the present invention, step S3, using the encryption and decryption algorithm to decrypt the request, and forwarding the decrypted request to the back-end service, includes: decrypting the request using the selected encryption and decryption algorithm; decrypting only the necessary request header information, keeping the request body encrypted; and forwarding the decrypted request to the back-end service.

[0053] Specifically, after completing the dynamic selection of the encryption and decryption algorithm, the API gateway calls the encryption and decryption module, and obtains the corresponding valid key from the key management module based on the encryption algorithm identifier and key identifier carried in the request. If the key exists in the local cache, it is used directly; if it does not exist, it is loaded from the remote key service and the cache is updated; then the selected algorithm (such as AES-GCM or ChaCha20-Poly1305) is used to decrypt the requested data. During the decryption process, the data integrity tag (such as the GCM tag or the Poly1305 authentication code) is verified to ensure that the data has not been tampered with; after the decryption is completed, the result is handed over to the subsequent module for processing, ready for forwarding to the back-end service.

[0054] During the request decryption process, the API gateway only performs targeted decryption on key header information fields in the request (such as authentication tokens, signature digests, timestamps, etc.) based on preset field matching rules or configuration lists to perform signature verification, permission verification, or routing decisions. The request body containing sensitive business data remains in its original encrypted state to avoid unnecessary decryption operations. This approach not only reduces the decryption computing overhead and improves system processing performance, but also reduces the risk of exposure of plaintext data within the gateway, thereby achieving efficient and secure forwarding under the principle of minimized decryption.

[0055] After completing the decryption of the necessary request header information, the API gateway encapsulates the request containing partially decrypted content into a data format that complies with the backend service interface specifications based on the preset routing rules or service registration information, and forwards the request to the corresponding backend service address through the HTTP or HTTPS protocol; during the forwarding process, the gateway can attach identification fields (such as algorithm type, signature verification status, etc.) for the backend service to identify and perform subsequent processing; since the request body remains encrypted, the backend service executes the complete decryption process after receiving the request, thereby ensuring end-to-end data security while realizing the gateway's lightweight and modular request forwarding function.

[0056] Furthermore, as an embodiment of the present invention, the multi-dimensional security management method based on the API gateway further includes: Perform anomaly detection to analyze request patterns for unusual behavior.

[0057] Specifically, when processing each client request, the API gateway records the key behavioral characteristics of the request in real time, such as request frequency, failure rate, request source IP, time interval and path distribution, and compares and analyzes them with the preset behavioral model or threshold; when it detects that a client requests too frequently in a short period of time, fails continuously, or has an abnormal access pattern (such as frequently switching interface paths in a short period of time), it is determined to be a potential abnormal behavior; at this time, security response measures can be automatically triggered, such as increasing encryption strength, enabling verification code mechanism, limiting request rate or temporarily blocking the request source, so as to achieve timely identification and protection of malicious requests.

[0058] Furthermore, as an embodiment of the present invention, the performing of anomaly detection, analyzing request patterns, and checking whether abnormal behavior exists further includes: If anomalies are detected, encryption strength can be automatically increased or request throttling can be implemented.

[0059] Specifically, when abnormal behavior is identified in a request, such as the number of requests sent by a client in a unit time exceeds the set threshold, the request failure rate increases abnormally, or the access behavior deviates significantly from the normal model, it immediately enters the security enhancement mode; at this time, the API gateway dynamically switches to a higher-intensity encryption algorithm according to the policy configuration (such as switching from AES-GCM to ChaCha20-Poly1305 and increasing the key length), and at the same time increases the signature complexity, such as adding more hash rounds or introducing dynamic salt values; in addition, the gateway can implement current limiting measures for abnormal clients, such as extending the response delay, limiting the number of concurrent connections, shortening the access window, or enabling a blacklist mechanism to temporarily block their access, thereby effectively curbing potential attacks and ensuring the safe and stable operation of the overall system.

[0060] Furthermore, as an embodiment of the present invention, the multi-dimensional security management method based on API gateway also includes: performing dynamic key rotation, including setting the key validity period, generating a new key when the key is about to expire, and supporting both new and old keys during the transition period.

[0061] Specifically, a predefined validity period is configured for each set of encryption keys through the API gateway, such as in hours, days, or number of requests; the remaining validity time of the key is checked regularly during operation, and when a key is detected to be close to the expiration threshold, the key rotation process is automatically triggered, a new set of keys is generated and registration is completed; during the transition period after the key update, the gateway retains the ability to identify and verify both the old and new keys to ensure that the client can still communicate successfully during the key update process; at the same time, the new key identifier or update prompt is attached in the response to guide the client to complete the synchronous update, thereby achieving smooth key switching, which not only improves the security of the overall encryption system, but also ensures the continuity and stability of the service.

[0062] Furthermore, as an embodiment of the present invention, the multi-dimensional security management method based on the API gateway also includes: recording detailed encryption and decryption operation logs, including performance indicators and monitoring indicators.

[0063] Specifically, when performing each encryption or decryption operation, key operation information is automatically recorded in the log system. The log content includes performance indicators such as request timestamp, encryption and decryption algorithm type used, key version, data encryption and decryption time, signature verification results, as well as monitoring indicators such as success rate, failure reason, anomaly detection results, and call frequency; it supports structured output, which is convenient for connecting to log or monitoring platforms such as ELK and Prometheus to achieve real-time data analysis and visualization; in addition, the log system can also provide interfaces for external systems to query or trigger early warning mechanisms for troubleshooting, security audits and system optimization, comprehensively improving the traceability and controllability of API security management.

[0064] An embodiment of the present invention also discloses a multi-dimensional security management system based on an API gateway.

[0065] A multi-dimensional security management system based on API gateway includes a client, API gateway, dynamic signature module, adaptive encryption selector, layered encryption module, anomaly detection module and backend service.

[0066] For example, refer to Figure 2 , an overall architecture of a multi-dimensional security management system based on API gateway. The system uses the client and backend services as the communication ends, uses API gateway as the core hub, and integrates an intelligent dynamic encryption security management plug-in; the plug-in consists of functional units such as dynamic signature module, adaptive encryption selector, layered encryption module, anomaly detection module, key management module and log monitoring module. Each module works together to realize functions such as request signature verification, encryption and decryption strategy selection, hierarchical encryption of sensitive data, abnormal behavior identification, dynamic key rotation and full process logging, thereby building an API communication protection system that integrates security, intelligence and high performance. The client is used to send requests containing dynamic signatures. Specifically, the client includes but is not limited to various terminal devices with network communication capabilities and can access backend services through the API gateway, such as on-board terminals in smart connected cars, new energy charging pile equipment, mobile applications (Apps), industrial Internet of Things terminals, embedded controllers or PC browsers. The client must have the ability to collect characteristic information such as URL path, User-Agent, IP address, and built-in dynamic signature generation logic, and can sign requests according to the signature algorithm specified by the gateway. In addition, the client must also support multiple encryption algorithms (such as AES-GCM, ChaCha20-Poly1305) and have a key synchronization and management mechanism to correctly perform decryption operations when receiving the gateway's encrypted response, thereby forming a secure, efficient, and two-way authenticated data communication channel with the gateway.

[0067] API gateways are used to receive and process requests. API gateways include, but are not limited to, API middle-layer systems built on open-source or commercial gateway platforms such as Kong, Nginx, Envoy, and Apache APISIX, which are used to receive, process, and forward client requests to backend services. API gateways must have a plug-in architecture to support multi-dimensional security management modules such as integrated dynamic signature verification, adaptive encryption and decryption, anomaly detection, and log monitoring. In terms of deployment, API gateways can run on edge computing nodes, cloud platforms, enterprise private servers, or local data center environments, and support high-concurrency processing, service discovery, load balancing, and failover capabilities to ensure stable operation of security policies in large-scale distributed systems, thereby achieving the goals of unified entry, unified authentication, and unified security policy management.

[0068] The dynamic signature module is used to verify the validity of signatures. As a local plug-in embedded in the API gateway, the dynamic signature module implements signature extraction and verification logic through a scripting language (such as Lua). As an independent microservice, it communicates with the gateway via HTTP or local RPC protocols, specifically handling signature generation and verification. It can also be integrated into the gateway security policy and dynamically called by the rule engine based on the configuration. The module supports multiple signature algorithm combinations, such as a single hash algorithm (MD5, SHA256) or multiple rounds of hashing, and can also support the introduction of timestamps, random numbers, request digests, and other mechanisms to enhance signature strength. In addition, it provides a signature field configuration interface, supporting flexible selection of request fields involved in signing, and implementing adaptive signature strategies based on request path, client type, or access frequency, comprehensively improving the flexibility, security, and maintainability of signature verification.

[0069] The adaptive encryption selector is used to select the appropriate encryption algorithm. The adaptive encryption selector can be used as a logical module, independent plug-in, or external configuration service within the API gateway to dynamically determine the encryption and decryption algorithm to be used based on request characteristics. Its implementation can be based on a preset rule table, decision tree, conditional judgment statement, or by analyzing historical request data through a machine learning model. The parameters used may include the algorithm type supported by the client, the current system load level, request frequency, data sensitivity level, time period, etc. The encryption algorithm selection range can cover symmetric encryption methods such as AES-GCM and ChaCha20-Poly1305, and the algorithm strength can also be dynamically adjusted in combination with key length, performance indicators, or security policies. In addition, the module also provides a policy configuration interface to support operators to update the algorithm selection logic in real time, thereby achieving a dynamic balance between security, performance, and flexibility.

[0070] The layered encryption module is used to encrypt and decrypt requests and responses. It can be used as an embedded module, pluggable plug-in, or independent microservice in the API gateway to implement differentiated encryption and decryption strategies for data at different levels or with different sensitivity levels. Based on preset path matching rules, field sensitivity tags, data content types, etc., the layered encryption module can selectively encrypt specific fields in the request or response (such as ID number, location information, account data), while uniformly encrypting the entire request or response body, thus combining global and local encryption. Its implementation can be based on a configurable encryption policy table, supporting dynamic switching of encryption algorithms (such as AES-GCM, ChaCha20-Poly1305) and key lengths, and dynamically adjusting encryption strength based on anomaly detection results. Furthermore, the module can be linked with the key management system and log module to achieve full traceability of key grading, access control, and encryption and decryption processes, meeting multi-dimensional protection requirements at different security levels.

[0071] The anomaly detection module is used to detect abnormal requests. It can be implemented as a functional module integrated within the API gateway, a pluggable standalone plug-in, or a microservice component connected to an external security monitoring system. It analyzes client request behavior in real time and identifies abnormal patterns. The anomaly detection module can be implemented based on statistical rules, threshold configuration, blacklist and whitelist mechanisms, time window analysis, and other methods. For example, it can monitor request frequency, failure rate, IP distribution, and path call anomalies within a unit of time. Advanced implementations can also introduce machine learning models to train historical access data, enabling intelligent identification of sudden attacks (such as DDoS and brute force attacks). The anomaly detection module can be developed using Lua scripts, Python services, or by integrating existing security tools (such as WAF and IDS). It can also work with encryption modules to dynamically increase encryption strength, enable throttling, or block policies based on the level of anomalies, thereby building a proactive defense system that is both responsive and intelligent.

[0072] The backend service is used to process the decrypted request and return a response. The backend service can be an application system deployed on a private cloud, public cloud, or local server to process the request data forwarded by the API gateway and generate a business response. It can be in the form of a single service, an independent module under a microservice architecture, or an elastic service instance deployed based on containerization technology (such as Docker and Kubernetes). The backend service must have the ability to fully decrypt the request body, support the identification of the selected encryption algorithm, and call the corresponding decryption logic to ensure the correct parsing and processing of business data. The service can perform identity authentication, permission verification, data processing, and other operations based on the needs of the business system, and package the results and encrypt them before returning. In addition, the backend service can also cooperate with the key management module, security log system, etc. to implement key synchronization, access auditing, and exception response mechanisms, thereby ensuring the security and consistency of business data in the entire communication closed loop.

[0073] For example, refer to Figure 3 This is a complete implementation process for a multi-dimensional security management system based on an API gateway, covering the entire process from client request initiation to backend service response and return to the client. First, the client sends an API request, which includes a dynamic signature generated based on information such as the URL path, User-Agent, and IP address. After receiving the request, the API gateway calls the dynamic signature module to obtain and verify the signing key to ensure the request's legitimacy. Once verified, the adaptive encryption selector returns a matching encryption algorithm based on factors such as the current system load and request frequency. Subsequently, the layered encryption module performs differential encryption and decryption on the request data, processing only the necessary fields. The processed request is then forwarded to the anomaly detection module for behavioral analysis. If abnormal behavior is detected, a security response is issued, such as increasing encryption strength or restricting the request. After processing is complete, the request is forwarded to the backend service for business processing and the response content is returned. The API gateway calls the layered encryption module again to encrypt the response data, and the dynamic signature module generates a new signature. Finally, the encrypted response is returned to the client, logged and monitored. If a key update is required, the client is notified through the key management mechanism to synchronize the update. This process not only ensures secure data transmission, but also achieves the organic integration of dynamic encryption, anomaly defense and high-performance parallel processing.

[0074] Furthermore, as an embodiment of the present invention, the multi-dimensional security management system also includes a key management module, a log monitoring module and a configuration management module.

[0075] The key management module is used to perform dynamic key rotation, including setting key expiration dates, generating new keys when keys are about to expire, and supporting both old and new keys during the transition period. Specifically, the key management module can be implemented as a security module integrated within the API gateway, as a standalone key service, or by connecting to a third-party key management system (such as AWS KMS or HashiCorp Vault). It is responsible for unified management of the key lifecycle used in the encryption and decryption processes. The module supports key generation, storage, distribution, rotation, and destruction, using symmetric or asymmetric key mechanisms and integrating cryptographic hardware modules (such as HSMs) to enhance key security. Regarding the rotation mechanism, the module regularly checks key expiration dates, automatically generates new keys before expiration, and uses identification fields to ensure that both old and new keys are in effect during the transition period to avoid communication interruptions. Keys are available to the encryption module through interfaces, and key reading efficiency is optimized through caching mechanisms (such as LRU). Furthermore, the key management module records key usage history and links it with audit logs, enabling traceability of key usage and full-process compliance monitoring.

[0076] The log monitoring module is used to record detailed encryption and decryption operation logs, including performance and monitoring metrics. The log monitoring module can be used as a log plug-in integrated within the API gateway, a standalone log collection service, or a module connected to third-party logging and monitoring platforms (such as ELK, Prometheus, and Grafana). It is used to record and track encryption and decryption operations and security behaviors occurring in the system in real time. It can record performance and security metrics such as the encryption algorithm type, key version, operation duration, signature verification results, and anomaly detection status for each request through structured logs, and supports statistical classification by time, client, or interface path. The log monitoring module can output logs through local storage, remote log servers, or message queues (such as Kafka), and supports configuration of log levels, filtering rules, and alarm triggering conditions. Furthermore, advanced implementations can provide a RESTful interface for external systems to query logs or push key events in real time, enabling visual monitoring of system status, automated early warnings, and support for operational and maintenance decision-making.

[0077] The configuration management module is used to implement dynamic configuration updates, allowing partial configuration modifications without restarting the service. The configuration management module can be used as a configuration submodule integrated into the API gateway, an external centralized configuration service (such as Consul, Nacos, Etcd), or a plug-in component implemented based on the configuration file hot loading mechanism. It is used to uniformly manage and dynamically update key configuration items such as system encryption and decryption policies, signature rules, key parameters, and anomaly detection thresholds. The module supports configuration modifications through the web interface, API interface, or command line tools, and provides a configuration item validity verification mechanism to ensure that security parameters such as key length and algorithm type meet system requirements. The updated configuration can take effect immediately without restarting the service, and the changes are synchronized to related functional modules through event notification mechanisms or listeners. In addition, the module can also have functions such as version control, configuration rollback, permission management, and audit records to ensure the security, traceability, and high availability of the configuration change process.

[0078] For example, refer to Figure 4 This complete implementation process for multi-dimensional security management and dynamic key rotation between the client, the API gateway, and its various security plug-ins. First, the client initiates a request. After the API gateway receives the request, the dynamic signature module verifies the signature to determine if the request is legitimate. The request then enters the anomaly detection module, analyzing the request behavior. If an anomaly is detected, an alarm is triggered. After verification, the request is sent to the key management module. The anomaly detection module determines whether the current key is nearing expiration. If so, a new key is automatically generated and updated. The key update configuration is also distributed through the configuration management module. Throughout this process, the log monitoring module records all encryption behavior, response time, and other metrics for subsequent auditing and system optimization. If the plug-in configuration is updated, the configuration management module dynamically replaces the configuration without restarting the service, achieving hot configuration updates. Finally, after processing, the gateway returns a response to the charging station device. The client also completes key synchronization according to the instructions, ensuring continuous secure and stable communication. This process implements a closed-loop security control system that includes request legitimacy verification, anomaly detection, key lifecycle management, log monitoring, and dynamic configuration.

[0079] The embodiment of the present invention also discloses a readable storage medium.

[0080] A readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the multi-dimensional security management method described in any one of the above embodiments. The computer-readable storage medium may include: any entity or device capable of carrying a computer program, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), and a software distribution medium, etc. The computer program includes computer program code. The computer program code may be in source code form, object code form, an executable file, or some intermediate form, etc. The computer-readable storage medium may include: any entity or device capable of carrying a computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), and a software distribution medium, etc.

[0081] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code comprising one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present invention includes alternative implementations in which functions may be performed out of the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present invention pertain.

[0082] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, apparatus or device (such as a computer-based system, a system including a processing module, or other system that can fetch instructions from an instruction execution system, apparatus or device and execute instructions), or used in conjunction with such instruction execution systems, apparatuses or devices.

[0083] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A multi-dimensional security management method based on API gateway, characterized in that: include: Receive a request from a client, the request including a dynamic signature generated based on a URL path, a User-Agent, and an IP address; Verify the validity of the dynamic signature and select an appropriate encryption and decryption algorithm if it is valid; Decrypt the request using the encryption and decryption algorithm and forward the decrypted request to the backend service; as well as Receive the response from the backend service, encrypt the response and generate a new signature, and return the encrypted response to the client.

2. The multi-dimensional security management method according to claim 1, characterized in that: The receiving client sends a request, wherein the request includes a dynamic signature generated based on the URL path, User-Agent, and IP address, including: Receive requests sent by the client; Extracting URL path, User-Agent, and IP address information from the request; A dynamic signature is generated based on the extracted information.

3. The multi-dimensional security management method according to claim 2, characterized in that: The generation of the dynamic signature also includes using multiple rounds of hash algorithms to process the extracted information, including: using the MD5 algorithm to generate a first hash value for the URL path, using the SHA-1 algorithm to generate a second hash value for the User-Agent, and using the SHA-256 algorithm to generate a third hash value for the IP address; concatenating the three hash values ​​in a predetermined order and then performing a SHA-512 algorithm process to generate a final dynamic signature; the dynamic signature also combines the current timestamp to ensure the timeliness of the signature.

4. The multi-dimensional security management method according to claim 1, characterized in that: Verifying the validity of the dynamic signature and selecting an appropriate encryption and decryption algorithm if valid includes: Verify the validity of dynamic signature; If the signature is valid, the encryption and decryption algorithm is dynamically selected based on the request characteristics, time period, or request frequency.

5. The multi-dimensional security management method according to claim 4, characterized in that: The dynamic selection encryption algorithm includes: Select the lightweight encryption algorithm ChaCha20-Poly1305 during high-load periods and the AES-GCM algorithm during low-load periods; Use cached encryption results for high-frequency requests and perform real-time encryption for low-frequency requests.

6. The multi-dimensional security management method according to claim 1, characterized in that: Decrypting the request using the encryption and decryption algorithm and forwarding the decrypted request to the backend service includes: Decrypt the request using the selected encryption and decryption algorithm; Only necessary request header information is decrypted, and the request body remains encrypted; Forward the decrypted request to the backend service.

7. The multi-dimensional security management method according to claim 1, characterized in that: Also includes: Perform anomaly detection to analyze request patterns for unusual behavior.

8. The multi-dimensional security management method according to claim 7, characterized in that: The execution of anomaly detection, analyzing request patterns, and checking for abnormal behavior also includes: Count the request frequency from the same IP address within a unit time, and mark it as abnormal when the frequency exceeds the preset request frequency threshold; Monitor the request failure rate of the same client within a predetermined time window and mark it as abnormal when the failure rate exceeds the preset failure rate threshold; Analyze the request path change pattern and mark frequent switching between different API paths in a short period of time as an anomaly; If any of the above abnormal behaviors are detected, the encryption algorithm will be switched from AES-GCM to ChaCha20-Poly1305 and the key length will be increased. At the same time, request throttling measures based on the token bucket algorithm will be implemented on the client.

9. The multi-dimensional security management method according to claim 1, characterized in that: Also includes: Perform dynamic key rotation, which includes setting key expiration periods, generating new keys when keys are about to expire, and supporting both old and new keys during the transition period.

10. The multi-dimensional security management method according to claim 1, characterized in that: Also includes: Record detailed encryption and decryption operation logs, including performance indicators and monitoring indicators.

11. A multi-dimensional security management system based on API gateway, characterized in that: include: The client is used to send a request containing a dynamic signature; API gateway, used to receive and process requests; Dynamic signature module, used to verify the validity of the signature; Adaptive encryption selector, used to select the appropriate encryption algorithm; Layered encryption module, used to encrypt and decrypt requests and responses; Anomaly detection module, used to detect abnormal requests; as well as The backend service is used to process the decrypted request and return a response.

12. The multi-dimensional safety management system according to claim 11, characterized in that: Also includes: A key management module that performs dynamic key rotation, including setting key expiration dates, generating new keys when keys are about to expire, and supporting both old and new keys during the transition period. Log monitoring module, used to record detailed encryption and decryption operation logs, including performance indicators and monitoring indicators; as well as The configuration management module is used to implement dynamic configuration updates, allowing partial configuration modifications without restarting the service.

13. A readable storage medium, characterized in that: The readable storage medium stores computer instructions, and when the computer instructions are executed by a processor, the multi-dimensional security management method according to any one of claims 1 to 10 is implemented.

Citation Information

Patent Citations

  • Data security transmission method and device based on HTTP

    CN108712388A

  • Encryption and decryption method based on micro-service, API gateway system and equipment

    CN112019332A

  • Pluggable authentication technology method and system based on open bank service gateway

    CN113904870A

  • API (Application Program Interface) secure access method and device, electronic equipment and storage medium

    CN117640109A

  • Data security transmission method for edge gateway of Internet of Things

    CN119277365A

Cited By

  • API request security management method and device, electronic equipment and storage medium

    CN121967086A