Authorization information configuration method, device, equipment and storage medium based on API gateway
Through the API gateway-based authorization information configuration method, the newly added and information-changed node microservices in the distributed architecture are automatically configured and updated, which solves the problems of complexity and inefficiency of authorization information configuration in the existing technology, and realizes code-free restart automated authorization management.
Patent Information
- Application Number
- CN202210148602.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-17
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2042-02-17
AI Technical Summary
In distributed, clustered or microservice architectures, the prior art requires frequent modification and restart of microservice applications to update authorization information, resulting in complex configuration and inefficient configurations.
Adopt the authorization information configuration method based on the API gateway, obtain node microservice information and preset configuration information regularly, compare and update authorization information, and use the API gateway configuration policy to automatically configure the authorization information of newly added and information-changed node microservices. Avoid modifying microservice code.
It realizes automated authorization management and initialization of newly added and information-changing node microservices without restarting microservices, simplifying authorization information configuration and improving efficiency and scalability.
Smart Images

Figure CN114518909B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of information security technology, and in particular, to an authorization information configuration method, device, electronic device, storage medium and program product based on an API gateway. Background Art
[0002] With the surge in Internet application transaction volume, traditional single-node application deployment can no longer meet the current demand for ultra-large access volume. As a result, traditional single-node application deployment has gradually advanced to distributed, clustered or microservice deployment architectures. However, at the same time, this distributed, clustered or microservice architecture will make client login authentication, authorization information configuration, resource management and other issues more complicated. In related technologies, the springcloud open source framework is usually used to configure authorization information. When adding new nodes or changing the authorization information of nodes, it is necessary to frequently modify the authorization status information and authorization configuration information in the corresponding microservice code for each microservice application, requiring frequent and large-scale code modifications, restarting the modified microservice application, and re-releasing the software version. Summary of the invention
[0003] In view of the above problems, embodiments of the present disclosure provide an authorization information configuration method, device, electronic device, storage medium and program product based on an API gateway.
[0004] According to a first aspect of the present disclosure, there is provided an authorization information configuration method based on an API gateway, comprising the following steps:
[0005] Get the authorization information list;
[0006] According to a preset first time interval, periodically obtain a node microservice information list, wherein the node microservice information list includes information of n node microservices, where n is a positive integer greater than or equal to 1;
[0007] According to a preset second time interval, regularly obtain a list of preset node microservice configuration information;
[0008] Compare the node microservice information list with the authorization information list to determine whether the information of each node microservice exists in the authorization information list;
[0009] When information of at least one node microservice among the n node microservices does not exist in the authorization information list, determining that the at least one node microservice is a newly added node microservice;
[0010] For each newly added node microservice, extracting the preset node microservice configuration information corresponding to the newly added node microservice from the preset node microservice configuration information list; and
[0011] Based on the configuration strategy of the API gateway, the preset node microservice configuration information of each newly added node microservice is configured to the authorization management module of the API gateway to configure the authorization information of the newly added node microservice.
[0012] According to some embodiments, the method further comprises the following steps:
[0013] When information of the i-th node microservice among the n node microservices exists in the authorization information list, determining that the i-th node microservice is an existing node microservice, where i is a positive integer between 1 and n;
[0014] For the existing node microservice, query the authorization data corresponding to the existing node microservice stored in the API gateway;
[0015] For the existing node microservice, obtain the preset node microservice configuration information corresponding to the existing node microservice from the preset node microservice configuration information list;
[0016] Comparing the authorization data corresponding to the existing node microservice with the preset node microservice configuration information; and
[0017] When the authorization data corresponding to the existing node microservice is inconsistent with the preset node microservice configuration information, the existing node microservice is determined to be an information change node microservice.
[0018] According to some embodiments, the method further comprises the following steps:
[0019] Extracting a portion that is inconsistent with the authorization data from the preset node microservice configuration information corresponding to the information change node microservice, and determining the inconsistent portion as change information; and
[0020] Based on the configuration strategy of the API gateway, the change information is configured to the authorization management module of the API gateway to update the authorization information of the information change node microservice.
[0021] According to some embodiments, the API gateway-based configuration strategy includes: configuring authorization information using an authorization information configuration plug-in in the API gateway, wherein the API gateway allows information configuration using a plug-in, and the authorization information configuration plug-in allows a user to authorize a third-party application to access the user's private resources without requiring the user's username and password.
[0022] According to some embodiments, the information of the n node microservices includes: the IP address and port information of each of the n node microservices.
[0023] According to some embodiments, the preset node microservice configuration information includes: authorization status information of the node microservice, protected routing information of the node microservice, routing information of the node microservice that does not need to be protected, global switch information, token expiration time information, and at least one of token refresh time information.
[0024] According to some embodiments, the method further includes: storing the preset node microservice configuration information of each newly added node microservice in the data storage module of the API gateway; and / or storing the change information in the data storage module of the API gateway.
[0025] According to some embodiments, the preset first time interval is equal to the preset second time interval.
[0026] According to some embodiments, the API gateway includes a Kong gateway, and / or the authorization information configuration plug-in includes an oauth2.0 plug-in.
[0027] According to a second aspect of the present disclosure, there is provided an authorization information configuration device based on an API gateway, comprising:
[0028] An authorization information list acquisition module is used to obtain an authorization information list;
[0029] A node microservice information list acquisition module is used to: regularly acquire a node microservice information list according to a preset first time interval, wherein the node microservice information list includes information of n node microservices, where n is a positive integer greater than or equal to 1;
[0030] A preset node microservice configuration information list acquisition module is used to: regularly acquire a preset node microservice configuration information list according to a preset second time interval;
[0031] A comparison module, used to compare the node microservice information list with the authorization information list to determine whether the information of each node microservice exists in the authorization information list;
[0032] A newly added node microservice determination module is used to: when information of at least one node microservice among the n node microservices does not exist in the authorization information list, determine that the at least one node microservice is a newly added node microservice;
[0033] An extraction module is used to: for each newly added node microservice, extract the preset node microservice configuration information corresponding to the newly added node microservice from the preset node microservice configuration information list; and
[0034] The authorization information configuration module is used to: configure the preset node microservice configuration information of each newly added node microservice to the authorization management module of the API gateway based on the configuration strategy of the API gateway to configure the authorization information of the newly added node microservice.
[0035] According to a third aspect of the present disclosure, an electronic device is provided, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above-mentioned authorization information configuration method based on the API gateway.
[0036] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which executable instructions are stored. When the instructions are executed by a processor, the processor executes the above-mentioned authorization information configuration method based on the API gateway.
[0037] According to a fifth aspect of the present disclosure, a computer program product is provided, including a computer program, which implements the above-mentioned authorization information configuration method based on the API gateway when executed by a processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0039] Figure 1 The application scenario diagram of the authorization information configuration method based on the API gateway according to the embodiment of the present disclosure is schematically shown;
[0040] Figure 2 The flowchart of the authorization information configuration method based on the API gateway according to the embodiment of the present disclosure is schematically shown;
[0041] Figure 3 A block diagram schematically shows an application scenario of the authorization information configuration method based on the API gateway according to an embodiment of the present disclosure;
[0042] Figure 4 A flowchart of an authorization information configuration method based on an API gateway according to other embodiments of the present disclosure is schematically shown;
[0043] Figure 5 is a detailed flow chart of an authorization information configuration method based on an API gateway according to an exemplary embodiment of the present disclosure;
[0044] Figure 6 A structural block diagram of an authorization information configuration device based on an API gateway according to an embodiment of the present disclosure is schematically shown; and
[0045] Figure 7 A block diagram of an electronic device suitable for implementing an authorization information configuration method based on an API gateway according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0046] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0047] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0048] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0049] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0050] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision, disclosure and application of user personal information involved comply with the provisions of relevant laws and regulations, take necessary confidentiality measures, and do not violate public order and good morals.
[0051] Before describing the embodiments of the present disclosure, the terms used herein are explained.
[0052] Gateway: The term "gateway" originates from computer networks. It is also called an internetwork connector or a protocol converter. Gateways are used to connect multiple computer programs or systems. As a portal between computer programs or systems, gateways allow them to share information through protocol communications between different computers.
[0053] API (Application Programming Interface) Gateway: API Gateway is a checkpoint and barrier for APIs to call each other. Through the API Gateway, the client only needs to interact with the API Gateway, and does not need to communicate with the interfaces (such as APIs) of each business party separately. The basic functions of an API Gateway include unified access, protocol adaptation, traffic management and fault tolerance, and security protection.
[0054] Kong Gateway: Kong Gateway is a highly available, scalable API gateway written based on OpenResty (Nginx+Lua module) and open sourced by Mashape. Kong Gateway is built on Nginx and Apache Cassandra or PostgreSQL, and can provide an easy-to-use RESTful API to operate and configure the API management system, so it can horizontally scale multiple Kong servers and evenly distribute requests to each server through the front-end load balancing configuration to cope with large quantities of network requests.
[0055] Node: In telecommunication networks, a node is a connection point, representing a redistribution point or a communication endpoint (e.g. some terminal equipment). The definition of a node depends on the network and protocol layer in question. A physical network node is an active electronic device connected to a network that is capable of sending, receiving or forwarding information over a communication channel. For example, in data communications, a physical network node can be a data circuit-terminating equipment (DCE), such as a modem, hub, bridge or switch; or a data terminal equipment (DTE), such as a mobile phone, printer or host (e.g. a router, workstation or server).
[0056] Microservices: Microservices architecture is an architectural concept that aims to decouple solutions by breaking down functionality into discrete services. Compared to traditional monolithic applications, microservices architecture splits a large monolithic application or service into multiple microservices.
[0057] Node microservice: a microservice deployed in a node. It should be noted that in the embodiments of the present disclosure, unless otherwise specified, multiple microservices can be deployed in a node at the same time, and a microservice can also be redundantly deployed in multiple different nodes. Generally speaking, the granularity of a node microservice is finer than that of a node.
[0058] Eureka: Eureka is a service discovery framework developed by Netflix. It is a REST-based service that is mainly used to locate middle-tier services running in the AWS domain to achieve load balancing and middle-tier service failover. SpringCloud integrates it in its subproject spring-cloud-netflix to implement SpringCloud's service discovery function. Eureka consists of two components: Eureka Server and Eureka Client. Eureka ensures high availability, flexibility, and scalability of the system through mechanisms such as heartbeat checks and client caching.
[0059] OAuth: OAuth (Open Authorization) is an open standard that allows users to authorize third-party mobile applications to access specific private resources of the user in a server without providing usernames and passwords to third-party mobile applications or sharing all their data. OAuth2.0 is a continuation of the OAuth protocol.
[0060] AccessToken: Token is also called a token. In OAuth2.0, AccessToken is a string of characters generated by the server, which is used as a token for the client to make requests. After the first login, the server generates an AccessToken and returns the AccessToken to the client. In the future, the client only needs to bring this AccessToken to request data, without having to bring the username and password again. By using AccessToken, the server can avoid frequently querying the database for usernames and passwords and comparing them, which can reduce the pressure on the server, avoid frequent database queries, and make the server more robust.
[0061] refreshtoken: A token or accesstoken is a credential for obtaining protected resources and has an expiration date. Otherwise, it can be used permanently after logging in once, and the authentication function will lose its meaning. The expiration date of a token or accesstoken cannot be too long. Usually, the validity period of a refreshtoken is longer, and the validity period of an accesstoken is shorter. When an accesstoken expires, a new accesstoken can be obtained using a refreshtoken. If the refreshtoken also expires, the user can only log in again.
[0062] The inventor has found through research that in the related technologies, the springcloud open source framework is usually used to configure the authorization information. When adding a new node or changing the authorization information of a node, it is necessary to frequently modify the authorization status information and authorization configuration information in the corresponding microservice code for each microservice application, and it is necessary to frequently and extensively modify the code, restart the modified microservice application, and re-release the software version. In addition, although some related technologies involve synchronizing the Kong gateway and the nacos registration configuration center service based on the Kong open source framework, the technology is limited to the automated configuration of the Kong service routing, and does not involve the discussion of in-depth authorization-related issues.
[0063] An embodiment of the present disclosure provides an authorization information configuration method based on an API gateway, comprising the following steps: obtaining an authorization information list; obtaining a node microservice information list at regular intervals according to a preset first time interval, wherein the node microservice information list includes information of n node microservices, and n is a positive integer greater than or equal to 1; obtaining a preset node microservice configuration information list at regular intervals according to a preset second time interval; comparing the node microservice information list with the authorization information list to determine whether the information of each node microservice exists in the authorization information list; when the information of at least one node microservice among the n node microservices does not exist in the authorization information list, determining that the at least one node microservice is a newly added node microservice; for each newly added node microservice, extracting the preset node microservice configuration information corresponding to the newly added node microservice from the preset node microservice configuration information list; and configuring the preset node microservice configuration information of each newly added node microservice to the authorization management module of the API gateway based on the configuration policy of the API gateway to configure the authorization information of the newly added node microservice. In an embodiment of the present disclosure, the authorization information of a newly added node microservice can be configured without modifying the code of any microservice node microservice, that is, the newly added node microservice can be automatically managed and initialized for authorization without restarting any microservice.
[0064] Figure 1 The following schematically shows an application scenario diagram of the authorization information configuration method based on the API gateway according to an embodiment of the present disclosure. It should be noted that: Figure 1 It is also a typical application scenario diagram of an API gateway. In the following description, the Kong gateway is used as an example of an API gateway to describe the embodiments of the present disclosure. It should be understood that, in the absence of conflict, the embodiments of the present disclosure are not limited to the Kong gateway, and other types of API gateways can also be used.
[0065] The Kong gateway mainly includes: Kong server, a server based on Nginx; storage modules such as Apache Cassandra / PostgreSQL, which are used to store operation data; UI management tools such as Kong Dashboard.
[0066] Kong Gateway has multiple built-in plug-ins to provide powerful functions and integration capabilities, and can be expanded based on the plug-in mechanism. For example, the multiple plug-ins may include: authorization information configuration plug-in, such as oauth2.0; security control plug-in, such as ACL (access control), CORS (cross-domain resource sharing), dynamic SSL, IP restriction, crawler detection; flow control plug-in; analysis and monitoring plug-in; protocol conversion plug-in; log application plug-in, etc.
[0067] like Figure 1 As shown, the application scenario 100 according to the embodiment of the present disclosure may include clients 101, 102, 103, an API gateway 110, and multiple nodes 120. For example, at least one microservice runs in each node 120.
[0068] like Figure 1 As shown in the figure, when the Kong gateway is running, the client sends a request, and each request to the API will be hit by the Kong gateway first, and then the request will be forwarded to the corresponding API by the gateway. Between the request and the API, the Kong gateway will execute the pre-installed and configured plug-ins, such as authorizing API access operations.
[0069] Users can use clients 101, 102, 103 to interact with multiple nodes 120 through API gateway 110. Various applications can be installed on clients 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0070] Clients 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0071] The multiple nodes 120 may be servers that provide various services, such as a background management server (only an example) that provides support for websites browsed by users using the clients 101, 102, and 103. The background management server may analyze and process received data such as user requests, and feed back processing results (such as web pages, information, or data obtained or generated according to user requests) to the client.
[0072] It should be noted that the authorization information configuration method based on the API gateway provided in the embodiment of the present disclosure can generally be executed by the API gateway 110. Accordingly, the authorization information configuration device based on the API gateway provided in the embodiment of the present disclosure can generally be set in the API gateway 110. The authorization information configuration method based on the API gateway provided in the embodiment of the present disclosure is not limited to being executed on the Kong gateway.
[0073] It should be understood that Figure 1 The number of clients and nodes in the example is only for illustration purposes. Any number of clients and nodes may be provided as required.
[0074] The following will be based on Figure 1 The scene described by Figure 2 to Figure 5 The authorization information configuration method based on API gateway of the disclosed embodiment is described in detail.
[0075] Figure 2 A flowchart of an authorization information configuration method based on an API gateway according to an embodiment of the present disclosure is schematically shown. Figure 3 A block diagram schematically shows an application scenario of the authorization information configuration method based on the API gateway according to an embodiment of the present disclosure.
[0076] like Figure 2 As shown, the authorization information configuration method based on the API gateway includes operations S210 to S270. It should be noted that the numbers of operations S210 to S270 should not be understood as a restriction on the execution order of the authorization information configuration method. In the absence of conflict, at least some of operations S210 to S270 can be executed in parallel, or not in the order of the numbers.
[0077] like Figure 3 As shown, in the application scenario, a data storage module 310, an authorization core service module 320, an authorization management module 330, a parameter configuration module 340, an authorization information storage module 350, and a service registration module 360 may be provided. For example, the data storage module 310, the authorization core service module 320, the authorization management module 330, the parameter configuration module 340, and the authorization information storage module 350 may be included in an API gateway.
[0078] In operation S210, an authorization information list is acquired.
[0079] In some exemplary embodiments, the API gateway includes a Kong gateway. For example, the Kong gateway has an oauth2.0 plug-in.
[0080] For example, the authorization information list may be stored in the authorization information storage module 350, and the authorization management module 330 may read the authorization information storage module 350 to obtain the authorization information list.
[0081] For example, the authorization information list may include at least information of the node microservice and authorization information of the node microservice. The information of the node microservice and the authorization information of the node microservice will be further described below.
[0082] In operation S220, a node microservice information list is periodically obtained according to a preset first time interval, wherein the node microservice information list includes information of n node microservices, where n is a positive integer greater than or equal to 1.
[0083] In some exemplary embodiments, the service registration module 360 may be an eureka service discovery and registration module. As a special application microservice, the authorization management module 330 may periodically pull a node microservice information list from the eureka service discovery and registration module.
[0084] It should be noted that the commonly used eureka node microservice information pulling method in this field can be used to pull the node microservice information list from the eureka service discovery and registration module. For example, the eureka node microservice information can be pulled through the org.springframework.cloud.client.discovery.DiscoveryClient Java class; the eureka node microservice information can also be pulled by sending an http GET request as follows. The specific implementation method will not be repeated here.
[0085] For example, in an embodiment of the present disclosure, an identification name of a node microservice may be configured for each node microservice. For example, the identification name of the first node microservice may be name_serviceNodeInfo(1), the identification name of the second node microservice may be name_serviceNodeInfo(2), and so on. The identification name of the nth node microservice may be name_serviceNodeInfo(n).
[0086] For example, taking the first node microservice name_serviceNodeInfo(1) as an example, the information of the node microservice may include the IP address and port information of the node microservice.
[0087] In operation S230, a preset node microservice configuration information list is periodically obtained according to a preset second time interval.
[0088] For example, the preset node microservice configuration information list may be stored in the parameter configuration module 340 , and the authorization management module 330 may periodically read the parameter configuration module 340 to obtain the preset node microservice configuration information list.
[0089] In some exemplary embodiments of the present disclosure, the preset node microservice configuration information list may include preset node microservice configuration information of multiple node microservices, for example, information and authorization information of the node microservices.
[0090] For example, the information of the node microservice may include the IP address and port information of the node microservice. Thus, in the embodiment of the present disclosure, by comparing the IP address and port information in the two lists, it is possible to quickly determine whether the node microservice is a newly added node microservice.
[0091] For example, the authorization information may include at least one of the authorization status information of the node microservice, the protected routing information of the node microservice, the routing information of the node microservice that does not need to be protected, the global switch information, the token expiration time information, and the token refresh time information. That is, in the embodiments of the present disclosure, multiple authorization information of the node microservice can be configured, or in other words, multiple authorization information can be quickly configured.
[0092] Taking the first node microservice name_serviceNodeInfo(1) as an example, its authorization information may include: authorization status information of the node microservice, for example, need_oauth, when need_oauth=true, it means that the node microservice needs oauth authorization; protected routing information of the node microservice, for example, oauth_path=oauthpath_serviceNodeInfo(1), indicating the protected routing information and resources corresponding to the current node microservice or service; routing information of the node microservice that does not need to be protected, for example, not_oauth_path=not_oauthpath_serviceNodeInfo(1), indicating the routing information and resources that do not need to be protected corresponding to the current node microservice or service; global switch information, for example, need_global_oauth_path=oauthpath_serviceNodeInfo(1). uth, when need_global_oauth=true, it means that the global switch needs to be turned on; token expiration time information, for example, accesstoken_exp_duration, when accesstoken_exp_duration=30min, it means that the accesstoken expiration time interval is 30 minutes; token refresh time information, for example, refreshtoken_exp_duration, when refreshtoken_exp_duration=12day, it means that the refreshtoken expiration time interval is 12 days; token refresh time reuse information, for example, reuse_refresh_token, when reuse_refresh_token=true, it means that refreshtoken can be reused.
[0093] Similarly, similar configuration can be performed for name_serviceNodeInfo(2)~name_serviceNodeInfo(n).
[0094] For example, the routing information of the node microservice that does not need to be protected can be routing information that does not need token protection. Its existence means that for certain requests, logins, or anonymous public queries, interfaces that can be accessed without user login information are accessible without user login. In comparison, the protected routing information of the node microservice is more general. For example, user sensitive data requires confirmation of the current user login status and a login token to successfully request the corresponding interface response message.
[0095] For example, for serviceNodeInfo(1):
[0096] not_oauthpath_serviceNodeInfo(1)=abc, where abc is a route that does not require token protection. For a request to https: / / abc / resource1, the node microservice or API can be accessed without carrying an access token.
[0097] oauthpath_serviceNodeInfo(1)=protected_path, where protected_path is the path that needs token protection. When accessing https: / / protected_path / resource1, an unauthorized error will be reported if the request does not carry accesstoken. Only when accesstoken is carried can the node microservice or API be accessed.
[0098] After each node microservice is configured, the preset node microservice configuration information list is formed, and the preset node microservice configuration information list can be stored in the parameter configuration module 340. The authorization management module 330 can read the parameter configuration module 340 regularly to obtain the preset node microservice configuration information list.
[0099] In an embodiment of the present disclosure, the preset first time interval may be equal to the preset second time interval. In this way, the authorization management module 330 may synchronously obtain the node microservice information list and the preset node microservice configuration information list, which is beneficial to the synchronous control and management of the authorization information.
[0100] In operation S240, the node microservice information list is compared with the authorization information list to determine whether information of each node microservice exists in the authorization information list.
[0101] For example, a list traversal method may be used to compare the node microservice information list with the authorization information list. Specifically, the node microservice information list is traversed, and for the currently traversed k-th node microservice name_serviceNodeInfo(k), it is queried whether the k-th node microservice exists in the authorization information list, where k is a positive integer greater than or equal to 1 and less than n; after the k-th node microservice is queried, the next node microservice in the node microservice information list, i.e., the k+1-th node microservice name_serviceNodeInfo(k+1), is traversed, and for the currently traversed k+1-th node microservice name_serviceNodeInfo(k+1), it is queried whether the k+1-th node microservice exists in the authorization information list. By analogy, the traversal of the entire node microservice information list is completed, thereby completing the comparison between the node microservice information list and the authorization information list.
[0102] In operation S250, when information of at least one node microservice among the n node microservices does not exist in the authorization information list, it is determined that the at least one node microservice is a newly added node microservice.
[0103] For example, in the process of traversing the node microservice information list, when the kth node microservice name_serviceNodeInfo(k) does not exist in the authorization information list, it is determined that the kth node microservice name_serviceNodeInfo(k) is a newly added node microservice.
[0104] In the embodiment of the present disclosure, for the newly added node microservice, its authorization information needs to be fully configured.
[0105] In operation S260, for each newly added node microservice, the preset node microservice configuration information corresponding to the newly added node microservice is extracted from the preset node microservice configuration information list.
[0106] For example, for a newly added node microservice name_serviceNodeInfo(k), the preset node microservice configuration information of the node microservice name_serviceNodeInfo(k) can be extracted from the preset node microservice configuration information list, such as the authorization status information of the node microservice, the protected routing information of the node microservice, the routing information of the node microservice that does not need to be protected, the global switch information, the token expiration time information, and at least one of the token refresh time information.
[0107] In operation S270, based on the configuration policy of the API gateway, the preset node microservice configuration information of each newly added node microservice is configured to the authorization management module of the API gateway to add the authorization information of the newly added node microservice.
[0108] In some embodiments of the present disclosure, the API gateway-based configuration strategy includes: configuring authorization information using an authorization information configuration plug-in in the API gateway, wherein the API gateway allows information configuration using a plug-in, and the authorization information configuration plug-in allows a user to authorize a third-party application to access the user's private resources without the need for the user's username and password.
[0109] For example, the API gateway may include a Kong gateway, and / or the authorization information configuration plug-in may include an oauth2.0 plug-in. Accordingly, the configuration strategy based on the API gateway includes: configuring authorization information using the oauth2.0 plug-in in the Kong gateway.
[0110] In some exemplary embodiments, an operation step_oauth2_conf may be defined to configure the oauth2.0 plug-in of the Kong gateway. Through the operation step_oauth2_conf, the preset node microservice configuration information of each newly added node microservice may be configured into the authorization management module of the API gateway to add the authorization information of the newly added node microservice.
[0111] In the embodiments of the present disclosure, the characteristics of the API gateway and the authorization information configuration plug-in can be used to quickly configure the authorization information of the newly added node microservice and the information change node microservice. For example, the characteristics of the Kong gateway and the oauth2.0 plug-in can be used to quickly configure the authorization information of the newly added node microservice and the information change node microservice.
[0112] In the embodiments of the present disclosure, the authorization information of the newly added node microservice can be configured without modifying the code of any microservice node microservice, that is, the newly added node microservice can be automatically managed and authorized and initialized without restarting any microservice. In this way, in a large-scale commercial network environment, when dealing with complex, dynamic, and unstable network fluctuations and changes in the network environment, it is possible to achieve automated authorization management and authorization initialization of the newly added node microservice without code changes and re-release of software versions.
[0113] It should be noted that the configuration of the oauth2.0 plug-in of the Kong gateway can be implemented by using the method commonly used in the art to configure the oauth2.0 plug-in of the Kong gateway. For example, the path of the oauth2.0 plug-in can be read and the parameters related to the authorization information in the oauth2.0 plug-in can be configured. The specific method will not be repeated here.
[0114] Figure 4 The flowchart of the authorization information configuration method based on the API gateway according to other embodiments of the present disclosure is schematically shown. Figure 4 As shown, the authorization information configuration method based on the API gateway may include operations S410 to S470. It should be noted that the numbers of operations S410 to S470 should not be understood as a restriction on the execution order of the authorization information configuration method. In the absence of conflict, at least some of operations S410 to S470 can be executed in parallel, or not in the order of the numbers. In addition, in the absence of conflict, operations S410 to S470 can be executed in combination with operations S210 to S270.
[0115] In operation S410, when information of an i-th node microservice among n node microservices exists in the authorization information list, it is determined that the i-th node microservice is an existing node microservice, where i is a positive integer between 1 and n.
[0116] For example, in the process of traversing the node microservice information list, when the i-th node microservice name_serviceNodeInfo(i) exists in the authorization information list, it is determined that the i-th node microservice name_serviceNodeInfo(i) is an existing node microservice.
[0117] In the embodiment of the present disclosure, for the existing node microservice, it is necessary to judge its authorization information to determine whether its authorization information needs to be updated or modified.
[0118] In operation S420, for the existing node microservice, the authorization data corresponding to the existing node microservice stored in the API gateway is queried.
[0119] For example, you can use the interface to reversely query the authorization data oauth_info_kong in the Kong component corresponding to the existing node microservice.
[0120] In operation S430, for the existing node microservice, the preset node microservice configuration information corresponding to the existing node microservice is obtained from the preset node microservice configuration information list.
[0121] In the embodiment of the present disclosure, in the above operation S230, the preset node microservice configuration information list has been regularly obtained. In this operation S430, the preset node microservice configuration information corresponding to the existing node microservice is extracted from the preset node microservice configuration information list obtained regularly, that is, the preset node microservice configuration information of the i-th node microservice name_serviceNodeInfo(i) is extracted.
[0122] In operation S440, the authorization data corresponding to the existing node microservice is compared with the preset node microservice configuration information.
[0123] For example, the authorization data oauth_info_kong is compared with the preset node microservice configuration information of the i-th node microservice name_serviceNodeInfo(i).
[0124] In operation S450, when the authorization data corresponding to the existing node microservice is inconsistent with the preset node microservice configuration information, it is determined that the existing node microservice is an information change node microservice.
[0125] For example, when the authorization data oauth_info_kong is inconsistent with the preset node microservice configuration information of the i-th node microservice name_serviceNodeInfo(i), it is determined that the i-th node microservice name_serviceNodeInfo(i) is an information change node microservice. The inconsistency between the authorization data oauth_info_kong and the preset node microservice configuration information of the i-th node microservice name_serviceNodeInfo(i) can be understood as: at least one of the node microservice authorization status information, the node microservice protected routing information, the node microservice routing information that does not need to be protected, the global switch information, the token expiration time information, and the token refresh time information is inconsistent.
[0126] In the embodiment of the present disclosure, for the information change node microservice, its authorization information needs to be changed or modified.
[0127] In operation S460, a portion inconsistent with the authorization data is extracted from the preset node microservice configuration information corresponding to the information change node microservice, and the inconsistent portion is determined as change information.
[0128] In the embodiments of the present disclosure, by comparing the authorization data corresponding to the existing node microservice with the preset node microservice configuration information, the information-changed node microservice can be easily determined, which is conducive to the subsequent change or modification of its authorization information.
[0129] For example, through the comparison of operation S450, it is found that the authorization data oauth_info_kong is inconsistent with the protected routing information of the node microservice in the preset node microservice configuration information of the i-th node microservice name_serviceNodeInfo(i), and the protected routing information in the preset node microservice configuration information of the i-th node microservice name_serviceNodeInfo(i) is extracted as the change information. For another example, through the comparison of operation S450, it is found that the authorization data oauth_info_kong is inconsistent with the token expiration time information of the node microservice in the preset node microservice configuration information of the i-th node microservice name_serviceNodeInfo(i), and the token expiration time information in the preset node microservice configuration information of the i-th node microservice name_serviceNodeInfo(i) is extracted as the change information. That is, the change information includes at least one of the authorization status information of the node microservice in the preset node microservice configuration information corresponding to the information change node microservice, the protected routing information of the node microservice, the routing information of the node microservice that does not need to be protected, the global switch information, the token expiration time information, and the token refresh time information.
[0130] In operation S470, based on the configuration policy of the API gateway, the change information is configured to the authorization management module of the API gateway to update the authorization information of the information change node microservice.
[0131] In some exemplary embodiments of the present disclosure, the preset node microservice configuration information list may include preset node microservice configuration information of multiple node microservices, for example, information and authorization information of the node microservices.
[0132] For example, the information of the node microservice may include the IP address and port information of the node microservice. Thus, in the embodiment of the present disclosure, by comparing the IP address and port information in the two lists, it is possible to quickly determine whether the node microservice is a newly added node microservice.
[0133] For example, the authorization information may include at least one of the authorization status information of the node microservice, the protected routing information of the node microservice, the routing information of the node microservice that does not need to be protected, the global switch information, the token expiration time information, and the token refresh time information. That is, in the embodiments of the present disclosure, multiple authorization information of the node microservice can be configured, or in other words, multiple authorization information can be quickly configured.
[0134] In some embodiments of the present disclosure, the API gateway-based configuration strategy includes: configuring authorization information using an authorization information configuration plug-in in the API gateway, wherein the API gateway allows information configuration using a plug-in, and the authorization information configuration plug-in allows a user to authorize a third-party application to access the user's private resources without the need for the user's username and password.
[0135] For example, the API gateway may include a Kong gateway, and / or the authorization information configuration plug-in may include an oauth2.0 plug-in. Accordingly, the configuration strategy based on the API gateway includes: configuring authorization information using the oauth2.0 plug-in in the Kong gateway.
[0136] In some exemplary embodiments, through the operation step_oauth2_conf, the change information can be configured to the authorization management module of the API gateway to update the authorization information of the information change node microservice.
[0137] In the embodiments of the present disclosure, the authorization information of the node microservice can be changed and modified without modifying the code of any microservice node microservice, that is, when the authorization requirement changes, by simply modifying the preset node microservice configuration information file, the changed authorization information can be automatically configured to the corresponding node microservice in quasi-real time without restarting any microservice component and without modifying any code of the microservice node microservice. In this way, in a large-scale commercial network environment, when dealing with complex, dynamic, and unstable network fluctuations and changes in the network environment, there is no need to change the code and re-release the software version, and the automated authorization management of the information change node microservice can be achieved.
[0138] In an embodiment of the present disclosure, the method may further include: storing the preset node microservice configuration information of each newly added node microservice in the data storage module of the API gateway; and / or storing the change information in the data storage module of the API gateway. That is, for each newly added node microservice, its preset node microservice configuration information can be configured to the authorization management module of the API gateway and stored in the data storage module of the API gateway, which is conducive to the automatic configuration and storage of the authorization information of each newly added node microservice. For each information change node microservice, its change information can be configured to the authorization management module of the API gateway and stored in the data storage module of the API gateway, which is conducive to the automatic update and storage of the authorization information of each information change node microservice.
[0139] It should be noted that this step may be performed simultaneously with operation S270 or operation S470 , but the embodiments of the present disclosure are not limited thereto.
[0140] Figure 5 It is a detailed flow chart of the authorization information configuration method based on API gateway according to an exemplary embodiment of the present disclosure. Figure 5 , taking a specific example as an example, the authorization information configuration method based on API gateway provided in the embodiment of the present disclosure is explained in more detail.
[0141] like Figure 5 As shown, the authorization information configuration method based on the API gateway includes operations S501 to S518. It should be noted that the numbers of operations S501 to S518 should not be understood as a restriction on the execution order of the authorization information configuration method. In the absence of conflict, at least some of operations S501 to S518 can be executed in parallel, or not in the order of the numbers.
[0142] In operation S501, the authorization core service module of the Kong gateway is enabled. For example, the authorization core service module of the Kong gateway may be enabled by an administrator.
[0143] In operation S502, it is determined whether it is an initial startup or whether a preset node microservice configuration information list needs to be changed.
[0144] In operation S503, when it is determined that it is the first startup or the preset node microservice configuration information list needs to be changed, the preset node microservice configuration information list is initialized or changed.
[0145] For example, the administrator can configure the preset node microservice configuration information of each node microservice in the parameter configuration module through the preset interface of the Kong gateway. For example, taking the first node microservice name_serviceNodeInfo(1) as an example, the preset node microservice configuration information can be configured as follows:
[0146] need_oauth = true;
[0147] oauth_path=oauthpath_serviceNodeInfo(1);
[0148] not_oauth_path=not_oauthpath_serviceNodeInfo(1);
[0149] need_global_oauth=true;
[0150] accesstoken_exp_duration=30min;
[0151] refreshtoken_exp_duration=12day;
[0152] reuse_refresh_token = true;
[0153] For example, name_serviceNodeInfo(2)~name_serviceNodeInfo(n) can be configured similarly.
[0154] In operation S504, when it is determined that it is not the first startup or there is no need to change the preset node microservice configuration information list, the authorization management module periodically pulls the eureka node microservice information list, for example, eureka_list.
[0155] In operation S505, the authorization management module reads the authorization information list stored in the authorization information storage module, for example, ouath_info_list.
[0156] In operation S506, the authorization management module periodically pulls the preset node microservice configuration information list stored in the parameter configuration module, for example, para_info_list.
[0157] For example, in operation S504 and operation S506, the data can be pulled and synchronized regularly every T minutes, or the refresh and pull behavior can be triggered on demand through the viewing platform control interface of the Kong gateway. For example, the T minutes can be 0.5 minutes, 1 minute, 2 minutes, 3 minutes, etc.
[0158] In operation S507, the authorization management module traverses the eureka node microservice information list eureka_list.
[0159] For example, for the kth node microservice name_serviceNodeInfo(k) of the currently traversed node microservice, perform the following operations.
[0160] In operation S508, it is queried whether the k-th node microservice name_serviceNodeInfo(k) exists in the authorization information list ouath_info_list.
[0161] In operation S509, when the k-th node microservice name_serviceNodeInfo(k) does not exist in the authorization information list ouath_info_list, it is determined that the k-th node microservice name_serviceNodeInfo(k) is a newly added node microservice.
[0162] In operation S510, the authorization information of the newly added node microservice is fully configured.
[0163] In operation S511, when the k-th node microservice name_serviceNodeInfo(k) exists in the authorization information list ouath_info_list, it is determined that the k-th node microservice name_serviceNodeInfo(k) is an existing node microservice.
[0164] In operation S512, for the existing node microservice, the authorization data corresponding to the existing node microservice stored in the API gateway is queried.
[0165] For example, you can use the interface to reversely query the authorization data oauth_info_kong in the Kong component corresponding to the existing node microservice.
[0166] In operation S513, the authorization data corresponding to the existing node microservice is compared with the preset node microservice configuration information. For example, the authorization data oauth_info_kong is compared with the preset node microservice configuration information of the kth node microservice name_serviceNodeInfo(k).
[0167] In operation S514, when the authorization data corresponding to the existing node microservice is inconsistent with the preset node microservice configuration information, it is determined that the existing node microservice is an information change node microservice.
[0168] For example, when the authorization data oauth_info_kong is inconsistent with the preset node microservice configuration information of the i-th node microservice name_serviceNodeInfo(i), it is determined that the i-th node microservice name_serviceNodeInfo(i) is an information change node microservice. The inconsistency between the authorization data oauth_info_kong and the preset node microservice configuration information of the i-th node microservice name_serviceNodeInfo(i) can be understood as: at least one of the node microservice authorization status information, the node microservice protected routing information, the node microservice routing information that does not need to be protected, the global switch information, the token expiration time information, and the token refresh time information is inconsistent.
[0169] In the embodiment of the present disclosure, for the information change node microservice, its authorization information needs to be changed or modified.
[0170] In operation S515, a portion inconsistent with the authorization data is extracted from the preset node microservice configuration information corresponding to the information change node microservice, and the inconsistent portion is determined as change information.
[0171] In operation S516, the preset node microservice configuration information of each newly added node microservice is configured to the authorization management module of the API gateway and stored in the data storage module to add the authorization information of the newly added node microservice; and / or, the change information is configured to the authorization management module of the API gateway and stored in the data storage module to update the authorization information of the information change node microservice.
[0172] For example, by operating step_oauth2_conf, the preset node microservice configuration information of each newly added node microservice can be configured to the authorization management module of the API gateway and stored in the data storage module to add the authorization information of the newly added node microservice; and / or, the change information can be configured to the authorization management module of the API gateway and stored in the data storage module to update the authorization information of the information change node microservice.
[0173] In operation S517, it is determined whether the traversal of the eureka node microservice information list eureka_list is complete.
[0174] In operation S518, when it is determined that the traversal of the eureka node microservice information list eureka_list is not completed, the next node microservice in the eureka node microservice information list eureka_list is traversed, for example, the i+1th node microservice name_serviceNodeInfo(i+1).
[0175] For the i+1th node microservice name_serviceNodeInfo(i+1), operations S508 to S517 are repeated until the traversal of the eureka node microservice information list eureka_list is completed.
[0176] It should be noted that the embodiments of the present disclosure are mainly aimed at the configuration and management of authorization information based on the API gateway. It should be understood that in the Kong gateway, multiple operations can also be defined, for example, configuring the Kong service component of the microservice, configuring the routing information of the Kong service component, configuring the consumer of the oauth2.0 plug-in, configuring the consumer's client and microservice, etc., which will not be repeated here.
[0177] Based on the above-mentioned authorization information configuration method based on API gateway, the embodiment of the present disclosure also provides an authorization information configuration device based on API gateway. Figure 6The device is described in detail.
[0178] Figure 6 The structural block diagram of the authorization information configuration device based on the API gateway according to an embodiment of the present disclosure is schematically shown.
[0179] like Figure 6 As shown, the API gateway-based authorization information configuration device 600 includes an authorization information list acquisition module 610, a node microservice information list acquisition module 620, a preset node microservice configuration information list acquisition module 630, a comparison module 640, a newly added node microservice determination module 650, an extraction module 660 and an authorization information configuration module 670.
[0180] The authorization information list acquisition module 610 is used to acquire the authorization information list. In one embodiment, the authorization information list acquisition module 610 can be used to perform the operation S210 described above, which will not be repeated here. For example, the authorization information list acquisition module 610 can be a part of the authorization management module of the API gateway.
[0181] The node microservice information list acquisition module 620 is used to regularly acquire the node microservice information list according to a preset first time interval. In one embodiment, the node microservice information list acquisition module 620 can be used to perform the operation S220 described above, which is not repeated here. For example, the node microservice information list acquisition module 620 can be another part of the authorization management module of the API gateway.
[0182] The preset node microservice configuration information list acquisition module 630 is used to periodically acquire the preset node microservice configuration information list according to a preset second time interval. In one embodiment, the preset node microservice configuration information list acquisition module 630 can be used to perform the operation S230 described above, which is not repeated here. For example, the preset node microservice configuration information list acquisition module 630 can be another part of the authorization management module of the API gateway.
[0183] The comparison module 640 is used to compare the node microservice information list with the authorization information list to determine whether the information of each node microservice exists in the authorization information list. In one embodiment, the comparison module 640 can be used to perform the operation S240 described above, which will not be repeated here.
[0184] The newly added node microservice determination module 650 is used to: when the information of at least one node microservice among the n node microservices does not exist in the authorization information list, determine that the at least one node microservice is a newly added node microservice. In one embodiment, the newly added node microservice determination module 650 can be used to perform the operation S250 described above, which is not repeated here.
[0185] The extraction module 660 is used to extract the preset node microservice configuration information corresponding to each newly added node microservice from the preset node microservice configuration information list. In one embodiment, the extraction module 660 can be used to perform the operation S260 described above, which will not be repeated here.
[0186] The authorization information configuration module 670 is used to: configure the preset node microservice configuration information of each newly added node microservice to the authorization management module of the API gateway based on the configuration policy of the API gateway to configure the authorization information of the newly added node microservice. In one embodiment, the authorization information configuration module 670 can be used to perform the operation S270 described above, which will not be repeated here.
[0187] According to an embodiment of the present disclosure, any multiple modules among the authorization information list acquisition module 610, the node microservice information list acquisition module 620, the preset node microservice configuration information list acquisition module 630, the comparison module 640, the newly added node microservice determination module 650, the extraction module 660 and the authorization information configuration module 670 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the authorization information list acquisition module 610, the node microservice information list acquisition module 620, the preset node microservice configuration information list acquisition module 630, the comparison module 640, the newly added node microservice determination module 650, the extraction module 660 and the authorization information configuration module 670 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in an appropriate combination of any of them. Alternatively, at least one of the authorization information list acquisition module 610, the node microservice information list acquisition module 620, the preset node microservice configuration information list acquisition module 630, the comparison module 640, the newly added node microservice determination module 650, the extraction module 660 and the authorization information configuration module 670 can be at least partially implemented as a computer program module, and when the computer program module is executed, the corresponding function can be executed.
[0188] Figure 7 A block diagram of an electronic device suitable for implementing an authorization information configuration method based on an API gateway according to an embodiment of the present disclosure is schematically shown.
[0189] like Figure 7 As shown, the electronic device 700 according to an embodiment of the present disclosure includes a processor 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. The processor 701 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 701 may also include an onboard memory for caching purposes. The processor 701 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0190] In RAM 703, various programs and data required for the operation of electronic device 700 are stored. Processor 701, ROM 702 and RAM 703 are connected to each other via bus 704. Processor 701 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 702 and / or RAM 703. It should be noted that the program can also be stored in one or more memories other than ROM 702 and RAM 703. Processor 701 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0191] According to an embodiment of the present disclosure, the electronic device 700 may further include an input / output (I / O) interface 705, which is also connected to the bus 704. The electronic device 700 may further include one or more of the following components connected to the I / O interface 705: an input portion 706 including a keyboard, a mouse, etc.; an output portion 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 708 including a hard disk, etc.; and a communication portion 709 including a network interface card such as a LAN card, a modem, etc. The communication portion 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage portion 708 as needed.
[0192] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0193] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 702 and / or RAM 703 described above and / or one or more memories other than ROM 702 and RAM 703.
[0194] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the item recommendation method provided by the embodiment of the present disclosure.
[0195] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 701. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0196] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 709, and / or installed from the removable medium 711. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0197] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the processor 701, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0198] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0199] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0200] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0201] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A method for configuring authorization information based on an API gateway, characterized in that: The following steps are involved: Get the authorization information list; According to a preset first time interval, periodically obtain a node microservice information list, wherein the node microservice information list includes information of n node microservices, where n is a positive integer greater than or equal to 1; According to a preset second time interval, regularly obtain a list of preset node microservice configuration information; Compare the node microservice information list with the authorization information list to determine whether the information of each node microservice exists in the authorization information list; When information of at least one node microservice among the n node microservices does not exist in the authorization information list, determining that the at least one node microservice is a newly added node microservice; For each newly added node microservice, extracting the preset node microservice configuration information corresponding to the newly added node microservice from the preset node microservice configuration information list; and Based on the configuration strategy of the API gateway, the preset node microservice configuration information of each newly added node microservice is configured to the authorization management module of the API gateway to configure the authorization information of the newly added node microservice; When information of the i-th node microservice among the n node microservices exists in the authorization information list, determining that the i-th node microservice is an existing node microservice, where i is a positive integer between 1 and n; For the existing node microservice, query the authorization data corresponding to the existing node microservice stored in the API gateway; For the existing node microservice, obtain the preset node microservice configuration information corresponding to the existing node microservice from the preset node microservice configuration information list; Comparing the authorization data corresponding to the existing node microservice with the preset node microservice configuration information; and When the authorization data corresponding to the existing node microservice is inconsistent with the preset node microservice configuration information, determining that the existing node microservice is an information change node microservice; Extracting a portion that is inconsistent with the authorization data from the preset node microservice configuration information corresponding to the information change node microservice, and determining the inconsistent portion as change information; and Based on the configuration strategy of the API gateway, the change information is configured to the authorization management module of the API gateway to update the authorization information of the information change node microservice.
2. The method according to claim 1, characterized in that The configuration strategy based on the API gateway includes: configuring authorization information using an authorization information configuration plug-in in the API gateway, wherein the API gateway allows information configuration using a plug-in, and the authorization information configuration plug-in allows a user to authorize a third-party application to access the user's private resources without requiring the user's username and password.
3. The method according to claim 1, characterized in that: The information of the n node microservices includes: the IP address and port information of each of the n node microservices.
4. The method according to claim 1, characterized in that: The preset node microservice configuration information includes: authorization status information of the node microservice, protected routing information of the node microservice, routing information of the node microservice that does not need to be protected, global switch information, token expiration time information, and at least one of token refresh time information.
5. The method according to claim 1, characterized in that The method further includes: storing the preset node microservice configuration information of each newly added node microservice in the data storage module of the API gateway; and / or storing the change information in the data storage module of the API gateway.
6. The method according to claim 1, characterized in that The preset first time interval is equal to the preset second time interval.
7. The method according to claim 2, characterized in that: The API gateway includes the Kong gateway, and / or the authorization information configuration plug-in includes the oauth2.0 plug-in.
8. An authorization information configuration device based on API gateway, characterized in that: include: An authorization information list acquisition module is used to obtain an authorization information list; A node microservice information list acquisition module is used to: regularly acquire a node microservice information list according to a preset first time interval, wherein the node microservice information list includes information of n node microservices, where n is a positive integer greater than or equal to 1; A preset node microservice configuration information list acquisition module is used to: regularly acquire a preset node microservice configuration information list according to a preset second time interval; A comparison module, used to compare the node microservice information list with the authorization information list to determine whether the information of each node microservice exists in the authorization information list; A newly added node microservice determination module is used to: when information of at least one node microservice among the n node microservices does not exist in the authorization information list, determine that the at least one node microservice is a newly added node microservice; An extraction module is used to: for each newly added node microservice, extract the preset node microservice configuration information corresponding to the newly added node microservice from the preset node microservice configuration information list; and The authorization information configuration module is used to: configure the preset node microservice configuration information of each newly added node microservice to the authorization management module of the API gateway based on the configuration strategy of the API gateway, so as to configure the authorization information of the newly added node microservice; When information of the i-th node microservice among the n node microservices exists in the authorization information list, determining that the i-th node microservice is an existing node microservice, where i is a positive integer between 1 and n; For the existing node microservice, query the authorization data corresponding to the existing node microservice stored in the API gateway; For the existing node microservice, obtain the preset node microservice configuration information corresponding to the existing node microservice from the preset node microservice configuration information list; Comparing the authorization data corresponding to the existing node microservice with the preset node microservice configuration information; and When the authorization data corresponding to the existing node microservice is inconsistent with the preset node microservice configuration information, determining that the existing node microservice is an information change node microservice; Extracting a portion that is inconsistent with the authorization data from the preset node microservice configuration information corresponding to the information change node microservice, and determining the inconsistent portion as change information; and Based on the configuration strategy of the API gateway, the change information is configured to the authorization management module of the API gateway to update the authorization information of the information change node microservice.
9. An electronic device, comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors execute the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
A method for implementing simple authentication authorization using an API gateway
CN109039880A
Micro-service configuration information management system and method, server and storage medium
CN111541561A
Gateway authentication and identity authentication platform and method thereof
CN111865920A
Authority management method, device and equipment for micro-service and storage medium
CN112104617A
Authorization method of network equipment
CN113065119A
