Angular-based dynamic configuration management method and system

By using Angular-based dynamic configuration management, configuration files are remotely loaded and signatures are verified using the HMAC-SHA256 algorithm. This solves the problem of traditional front-end architectures being unable to dynamically update configurations in multi-environment deployments, enabling flexible deployment and low-cost maintenance.

CN120994236APending Publication Date: 2025-11-21SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511055279.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-30
Publication Date
2025-11-21

AI Technical Summary

Technical Problem

Traditional front-end architectures cannot dynamically update configurations in multi-environment deployments, resulting in poor deployment flexibility, high maintenance costs, and lack of support for hot updates.

Method used

It adopts a dynamic configuration management method based on Angular, loads configuration files remotely, verifies signatures using the HMAC-SHA256 algorithm, and broadcasts configuration updates on demand at runtime, supporting real-time synchronization between single and multiple clients.

Benefits of technology

It enables dynamic loading and updating of configurations without redeployment, reducing maintenance costs, supporting independent management in multi-tenant scenarios, and preventing configuration tampering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120994236A_ABST
    Figure CN120994236A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of front-end development frameworks, in particular to an Angle-based dynamic configuration management method and system, and the method comprises the following steps: requesting to load a remote configuration file in an application starting stage; recursively executing key sequence normalization on the configuration object to generate a standardized JSON character string; wherein the key sequence standardization comprises: identifying an object / array / basic data type; the object key names are subjected to recursive sorting according to the lexicographical order during deep traversal; the null value keeps the original serialization position; the method has the advantages that dynamic loading and updating of configuration are supported, and application redeployment is not needed; configuration tampering is prevented through an HMAC signature mechanism; in combination with Angular CLI multi-environment configuration, the configuration is automatically switched according to environment variables; global configuration is managed in a unified mode, and the coupling degree between modules is reduced; a multi-tenant scene does not need to be repeatedly constructed, and configuration is independently managed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of front-end development framework technology, specifically to a dynamic configuration management method and system based on Angular. Background Technology

[0002] Traditional front-end architectures suffer from the following technical pain points:

[0003] In modern enterprise web applications, projects typically need to be deployed to multiple environments (such as dev, test, and prod), each with different API addresses, client IDs, authorization methods, and other configuration information. The traditional approach is to use static configuration in Angular's environment.ts file, but this method has the following problems:

[0004] 1) Static configuration cannot be changed: It can only be configured before building and cannot be changed after running;

[0005] 2) Poor deployment flexibility: Different customers or tenants may require different configurations, making it difficult to package them uniformly;

[0006] 3) Lack of centralized management mechanism: Configuration is scattered across multiple services, resulting in high maintenance costs;

[0007] 4) Hot updates are not supported: Modifying the configuration requires rebuilding and redeploying the application.

[0008] Therefore, there is an urgent need for a configuration system that can be dynamically loaded at runtime, updated on demand, and centrally managed. Summary of the Invention

[0009] The purpose of this invention is to provide a dynamic configuration management method and system based on Angular to solve the problems mentioned in the background art.

[0010] To achieve the above objectives, the present invention provides the following technical solution: a dynamic configuration management method based on Angular, comprising the following steps:

[0011] During application startup, a request is made to load a remote configuration file.

[0012] Key order normalization is recursively performed on the configuration object to generate a standardized JSON string. Key order normalization includes: identifying object / array / basic data types; recursively sorting object keys in lexicographical order during depth traversal; and preserving the original serialization position for null values.

[0013] The HMAC-SHA256 algorithm is used to verify the configuration file signature. The signature verification process uses the HMAC-SHA256 algorithm to generate the signature, calculates the hash using the normalized configuration data, and implements a secure comparison mechanism to prevent time-series attacks.

[0014] If verification is successful and the enabled flag is true, the local default configuration will be overridden;

[0015] The runtime responds to configuration update commands and broadcasts change events according to the selected mode. The broadcast modes include: Angular EventEmitter for single-client scenarios; WebSocket long connection push for multi-client real-time synchronization; and HTTP short polling for compatibility scenarios.

[0016] Preferably, the specific steps for key order normalization are as follows: identify objects, arrays, and basic data types in the configuration object; during deep traversal of the configuration object, recursively sort the object key names according to lexicographical order; for null values ​​in the configuration object, retain their original position during serialization.

[0017] Preferably, the signature verification module is implemented as follows: the signature of the configuration file is generated using the HMAC-SHA256 algorithm; the hash value is calculated using the configuration data after key order normalization; and a secure comparison mechanism to prevent time-series attacks is implemented to ensure the security of the signature verification process.

[0018] Preferably, the broadcast mode for responding to configuration update commands and broadcasting change events at runtime includes: in a single-client scenario, using Angular EventEmitter to broadcast configuration update events; in a multi-client real-time synchronization scenario, using WebSocket long connections to push configuration update information; and in a compatibility scenario, using HTTP short polling to broadcast configuration updates.

[0019] A system for dynamic configuration management based on Angular, comprising:

[0020] Configuration loading module: During the application startup phase, it is responsible for sending a request to the remote server to load the configuration file;

[0021] Key order normalization module: Recursively performs key order normalization operation on the loaded configuration object. Specifically, it identifies objects, arrays, and basic data types, recursively sorts the object key names in lexicographical order during depth traversal, and preserves the original serialization position of null values, and finally generates a standardized JSON string.

[0022] Signature verification module: The HMAC-SHA256 algorithm is used to verify the signature of the configuration file. First, the signature is generated using the HMAC-SHA256 algorithm, and then the hash is calculated using the normalized configuration data. A secure comparison mechanism to prevent time-series attacks is also implemented.

[0023] Configuration overriding module: If the signature verification is successful and the enable flag in the configuration is true, the remote configuration will override the local default configuration;

[0024] Configuration update broadcast module: Responds to configuration update commands at runtime and broadcasts change events according to different scenarios and selected modes. Broadcast modes include Angular EventEmitter for single-client scenarios, WebSocket long connection push for multi-client real-time synchronization, and HTTP short polling for compatibility scenarios.

[0025] Preferably, the specific processing flow of the key order normalization module is as follows:

[0026] Data type identification: Iterate through the configuration object to identify the objects, arrays, and basic data types it contains;

[0027] Key name sorting: When performing a depth-first traversal of the configuration object, for elements of the object type, their key names are recursively sorted in lexicographical order;

[0028] Null value handling: For null values ​​in the configuration object, their original positions are preserved during serialization to ensure that the generated standardized JSON string is consistent with the original configuration structure.

[0029] Preferably, the signature verification module is implemented as follows:

[0030] Signature generation: The signature is generated using the HMAC-SHA256 algorithm, combined with a preset key and configuration file content;

[0031] Hash calculation: Calculate the hash value using standardized configuration data processed by the key order normalization module;

[0032] Security Comparison: Implements a security comparison mechanism to prevent time-series attacks by comparing the calculated hash value with the received signature to determine the integrity and authenticity of the configuration file.

[0033] Preferably, the broadcast modes and applicable scenarios supported by the configuration update broadcast module are as follows:

[0034] Single-client scenario: When only one client needs to receive configuration updates, the AngularEventEmitter mechanism is used to pass configuration update events between components through Angular's event emitter;

[0035] Real-time synchronization with multiple clients: When multiple clients need to synchronize configuration updates in real time, the WebSocket long connection push method is used. The server actively pushes the configuration change information to all connected clients through the WebSocket connection.

[0036] Compatibility scenarios: Considering compatibility issues with different browsers or devices, in scenarios where advanced WebSocket technologies cannot be used, the HTTP short polling method is adopted, where the client periodically sends requests to the server to obtain the latest configuration information.

[0037] Compared with the prior art, the beneficial effects of the present invention are:

[0038] The dynamic configuration management method and system based on Angular proposed in this invention supports dynamic loading and updating of configurations without redeploying the application; prevents configuration tampering through the HMAC signature mechanism; integrates with Angular CLI multi-environment configuration to automatically switch configurations based on environment variables; provides unified global configuration management to reduce coupling between modules; and eliminates the need for repeated builds in multi-tenant scenarios, allowing for independent configuration management. Attached Figure Description

[0039] Figure 1 This is a flowchart of the method of the present invention;

[0040] Figure 2 This is a logic diagram for signature verification in this invention. Detailed Implementation

[0041] To make the objectives, technical solutions, and advantages of the present invention clear and complete, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only some, not all, embodiments of the present invention, and are merely illustrative of the embodiments of the present invention. They are not intended to limit the embodiments of the present invention. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0042] Example 1, please refer to Figures 1 to 2 This invention provides a technical solution: a dynamic configuration management method based on Angular, comprising the following steps:

[0043] During application startup, a request is made to load a remote configuration file.

[0044] Key order normalization is recursively performed on the configuration object to generate a standardized JSON string. Key order normalization includes: identifying object / array / basic data types; recursively sorting object keys in lexicographical order during depth-first traversal; and preserving the original serialization position for null values. The specific steps of key order normalization are: identifying objects, arrays, and basic data types in the configuration object; recursively sorting object keys in lexicographical order during depth-first traversal of the configuration object; and preserving the original serialization position for null values ​​in the configuration object.

[0045] The signature verification module uses the HMAC-SHA256 algorithm to verify the configuration file signature. The signature verification process generates the signature using the HMAC-SHA256 algorithm, calculates the hash using the normalized configuration data, and implements a secure comparison mechanism to prevent time-series attacks. Specifically, the signature verification module generates the configuration file signature using the HMAC-SHA256 algorithm, calculates the hash value using the configuration data after key-sequence normalization, and implements a secure comparison mechanism to prevent time-series attacks, thus ensuring the security of the signature verification process.

[0046] If verification is successful and the enabled flag is true, the local default configuration will be overridden;

[0047] The runtime responds to configuration update commands and broadcasts change events according to the selected mode. Broadcast modes include: Angular EventEmitter for single-client scenarios; WebSocket long-connection push for multi-client real-time synchronization; and HTTP short polling for compatibility scenarios. Specifically, the broadcast modes for runtime response to configuration update commands and broadcasting change events include: using Angular EventEmitter to broadcast configuration update events in single-client scenarios; using WebSocket long-connection push for configuration update information in multi-client real-time synchronization scenarios; and using HTTP short polling to broadcast configuration updates in compatibility scenarios.

[0048] Example 2, based on Example 1, proposes a system for dynamic configuration management based on Angular, including:

[0049] 1) Configure loading module

[0050] Before the application starts, the client loads the configuration file remotely via HTTP / WebSocket to initialize the global configuration.

[0051] (1) Use Angular's APP_INITIALIZER in app.module.ts to execute the configuration loading method configLoad() before the application starts, and wait for the configuration to be loaded before continuing to boot the application;

[0052] (2) Implementation of configLoad(): Load the configuration file through a request. After the request is successful, verify the file signature to confirm the integrity of the file. If the enable flag of the dynamic configuration is true after the verification is successful, the loaded configuration will be used. Otherwise, if the file loading fails, the signature verification fails, or the enable flag is not true, the configuration used when the application is built will be used.

[0053] (3) The configuration file format is as follows:

[0054] {

[0055] "config":{

[0056] "enabled":true, / / Dynamically configure the enabled flag

[0057] "basicApi":"https: / / api.example.com", / / The base path for the call request

[0058] "redirectUrl":"https: / / api.example.com / portal", ...

[0060] },

[0061] "signature":"xxx" / / Signature generated based on config

[0062] }

[0063] Add settings to the properties in the config file according to your needs.

[0064] 2) Signature verification module

[0065] (1) First, normalize the key order of the configuration object config, sort all key names and deeply nested objects in lexicographical order, and generate a standardized JSON string.

[0066] (2) Use the HMAC-SHA256 algorithm to generate a signature for the string in the previous step and assign it to the signature.

[0067] (3) After obtaining the configuration file, use the same algorithm and key to process the config object to generate a signature, and compare it with the signature in the obtained configuration file. If they match, it means that the verification is successful.

[0068] 3) Dynamic update module

[0069] (1) Provide a configuration update entry point for administrators to update and edit configurations.

[0070] (2) Based on the edited configuration information, generate a signature according to the signature generation method mentioned above, and generate a signed configuration on the server and store it persistently.

[0071] (3) After the configuration file is updated, the latest configuration will be broadcast to all subscribers. Depending on the scenario, the following different methods can be used:

[0072] For single-user applications or scenarios that do not require real-time cross-client synchronization: events can be broadcast directly through Angular services (such as EventEmitter or Subject);

[0073] For distributed systems that require real-time synchronization of configuration changes across multiple clients: If high immediacy is required, WebSocket can be used to enable the server to proactively push updates to clients; if the requirements are not high, HTTP polling can be used to periodically retrieve the latest configuration.

[0074] 4) Multi-environment integration

[0075] (1) It integrates with the Angular CLI build process and automatically switches the environment configuration file according to the build command.

[0076] (2) Runtime configuration priority override mechanism, which determines whether to override the default configuration based on the enable flag in the requested configuration.

[0077] 5) Enhanced safety design

[0078] (1) Key separation management: The signing key is not stored on the front end, but is dynamically obtained from the security server through OAuth 2.0 client credentials.

[0079] (2) Preventing time-series attacks: Use a constant-time string comparison algorithm (secureCompare(), see Appendix) to verify the signature.

[0080] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A dynamic configuration management method based on Angular, characterized in that: Includes the following steps: During application startup, a request is made to load a remote configuration file. Key order normalization is recursively performed on the configuration object to generate a standardized JSON string. Key order normalization includes: identifying object / array / basic data types; recursively sorting object keys in lexicographical order during depth traversal; and preserving the original serialization position for null values. The HMAC-SHA256 algorithm is used to verify the configuration file signature. The signature verification process uses the HMAC-SHA256 algorithm to generate the signature, calculates the hash using the normalized configuration data, and implements a secure comparison mechanism to prevent time-series attacks. If verification is successful and the enabled flag is true, the local default configuration will be overridden; The runtime responds to configuration update commands and broadcasts change events according to the selected mode. The broadcast modes include: Angular EventEmitter for single-client scenarios; WebSocket long connection push for multi-client real-time synchronization; and HTTP short polling for compatibility scenarios.

2. The dynamic configuration management method based on Angular according to claim 1, characterized in that: The specific steps for key order normalization are as follows: identify objects, arrays, and basic data types in the configuration object; during deep traversal of the configuration object, recursively sort the object keys in lexicographical order; and for null values ​​in the configuration object, retain their original position during serialization.

3. The dynamic configuration management method based on Angular according to claim 2, characterized in that: The signature verification module is implemented as follows: the HMAC-SHA256 algorithm is used to generate the signature of the configuration file; the hash value is calculated using the configuration data after key order normalization; and a secure comparison mechanism to prevent time-series attacks is implemented to ensure the security of the signature verification process.

4. The dynamic configuration management method based on Angular according to claim 3, characterized in that: The specific broadcast modes for responding to configuration update commands and broadcasting change events at runtime include: in a single-client scenario, using AngularEventEmitter to broadcast configuration update events; in a multi-client real-time synchronization scenario, using WebSocket long connections to push configuration update information; and in a compatibility scenario, using HTTP short polling to broadcast configuration updates.

5. A system for the dynamic configuration management method based on Angular according to claim 4, characterized in that: include: Configuration loading module: During the application startup phase, it is responsible for sending a request to the remote server to load the configuration file; Key order normalization module: Recursively performs key order normalization operation on the loaded configuration object. Specifically, it identifies objects, arrays, and basic data types, recursively sorts the object key names in lexicographical order during depth traversal, and preserves the original serialization position of null values, and finally generates a standardized JSON string. Signature verification module: The HMAC-SHA256 algorithm is used to verify the signature of the configuration file. First, the signature is generated using the HMAC-SHA256 algorithm, and then the hash is calculated using the normalized configuration data. A secure comparison mechanism to prevent time-series attacks is also implemented. Configuration overriding module: If the signature verification is successful and the enable flag in the configuration is true, the remote configuration will override the local default configuration; Configuration update broadcast module: Responds to configuration update commands at runtime and broadcasts change events according to different scenarios and selected modes. Broadcast modes include Angular EventEmitter for single-client scenarios, WebSocket long connection push for multi-client real-time synchronization, and HTTP short polling for compatibility scenarios.

6. The system according to claim 5, characterized in that: The specific processing flow of the key order normalization module is as follows: Data type identification: Iterate through the configuration object to identify the objects, arrays, and basic data types it contains; Key name sorting: When performing a depth-first traversal of the configuration object, for elements of the object type, their key names are recursively sorted in lexicographical order; Null value handling: For null values ​​in the configuration object, their original positions are preserved during serialization to ensure that the generated standardized JSON string is consistent with the original configuration structure.

7. The system according to claim 6, characterized in that: The specific implementation method of the signature verification module is as follows: Signature generation: The signature is generated using the HMAC-SHA256 algorithm, combined with a preset key and configuration file content; Hash calculation: Calculate the hash value using standardized configuration data processed by the key order normalization module; Security Comparison: Implements a security comparison mechanism to prevent time-series attacks by comparing the calculated hash value with the received signature to determine the integrity and authenticity of the configuration file.

8. The system according to claim 7, characterized in that: The broadcast modes and applicable scenarios supported by the configuration update broadcast module are as follows: Single-client scenario: When only one client needs to receive configuration updates, the Angular EventEmitter mechanism is used to pass configuration update events between components through Angular's event emitter; Real-time synchronization with multiple clients: When multiple clients need to synchronize configuration updates in real time, the WebSocket long connection push method is used. The server actively pushes the configuration change information to all connected clients through the WebSocket connection. Compatibility scenarios: Considering compatibility issues with different browsers or devices, in scenarios where advanced WebSocket technologies cannot be used, the HTTP short polling method is adopted, where the client periodically sends requests to the server to obtain the latest configuration information.