Cross-domain request processing method and device, electronic equipment and storage medium

By deploying plug-ins on the browser, automatically adding credential information to cross-domain requests, the efficiency problem caused by manual addition of credential information during cross-domain requests is solved, and automated processing and efficiency improvement is achieved.

CN120179946APending Publication Date: 2025-06-20SF TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311761955.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-19
Publication Date
2025-06-20

AI Technical Summary

Technical Problem

In the front-end separation architecture, credential information needs to be added manually when cross-domain requests, resulting in reduced business processing efficiency.

Method used

By deploying a plug-in on the browser, intercept cross-domain requests and automatically select target credential information from the pre-set credential information set and add it to the cross-domain request.

Benefits of technology

It realizes automatic processing of cross-domain requests, avoids manual operations, improves business processing efficiency, and avoids modification of browser parameters, maintains the integrity of browser functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120179946A_ABST
    Figure CN120179946A_ABST
Patent Text Reader

Abstract

The invention discloses a cross-domain request processing method and device, electronic equipment and a storage medium. By applying the technical scheme provided by the embodiment of the invention, a plug-in can be deployed on the browser in advance, so that after the browser receives the cross-domain request subsequently, the cross-domain request can be intercepted through the plug-in, and the domain credential information required by access of the cross-domain request can be automatically selected from the preset credential information set; therefore, the purpose of automatically adding the domain credential information to the cross-domain request by using the plug-in is achieved. Therefore, on one hand, a mode of processing the cross-domain request by installing the plug-in is realized, and then the problem that browser functions are affected due to modification of browser parameters is avoided. And on the other hand, the problem that the business processing efficiency is affected due to the fact that the voucher information needs to be manually added when the cross-domain request is initiated in the prior art is also avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to data request processing technology, in particular to a method, device, electronic device and storage medium for processing cross-domain requests. Background Art

[0002] In modern front-end development, the architecture of separating the front-end from the back-end has become the mainstream. During the development process, front-end developers need to conduct joint debugging with the back-end to ensure normal communication and interaction between the front and back ends.

[0003] In the related art, cross-domain problems often occur during the communication between the front and back ends. Among them, subject to the security policy of the browser, in order to ensure the security of data transmission, cross-domain requests usually require the requester to carry Cookie credential information that can be accepted by the cross-domain party. Otherwise, the cross-domain request will be prohibited from initiating access.

[0004] However, the above method requires developers to manually add the corresponding Cookie credential information to the request every time a cross-domain request is initiated. Understandably, this complex operation will affect the efficiency of business processing.

[0005] It should be noted that the above statements are only used to provide background technical information related to the present application, and do not necessarily constitute prior art. Summary of the Invention

[0006] The embodiments of the present application provide a method, device, electronic device and storage medium for processing cross-domain requests, thereby alleviating the problem of affecting the efficiency of business processing caused by the need to manually add credential information when initiating cross-domain requests in the related art.

[0007] Among them, according to one aspect of the embodiments of the present application, a method for processing cross-domain requests is provided, including:

[0008] When receiving a cross-domain request for obtaining data resources of a cross-domain object, obtaining a target domain identifier associated with the cross-domain request;

[0009] Selecting target credential information that matches the target domain identifier from a set of credential information, where the set of credential information is pre-associated with credential information of multiple different domain objects;

[0010] Adding the target credential information to the cross-domain request, and sending the cross-domain request with the added target credential information to the cross-domain object.

[0011] Optionally, in another embodiment based on the above method of the present application, the obtaining the target domain identifier associated with the cross-domain request includes:

[0012] Obtain the source address information for initiating the cross - domain request, and based on the pre - recorded configuration information, obtain all domain identifiers associated with the source address information;

[0013] Use all the domain identifiers as the target domain identifiers; or,

[0014] Extract the to - be - accessed domain identifier included in the cross - domain request for characterizing the resource acquisition object of this time, and use the to - be - accessed domain identifier as the target domain identifier.

[0015] Optionally, in another embodiment based on the above - mentioned method of this application, the using the domain identifier as the target domain identifier includes:

[0016] Determine that the domain identifier is included in all the domain identifiers;

[0017] Use the domain identifier as the target domain identifier.

[0018] Optionally, in another embodiment based on the above - mentioned method of this application, the adding the target credential information to the cross - domain request by using the target plugin includes:

[0019] Obtain the source - domain credential information carried in the cross - domain request;

[0020] According to a preset splicing rule, splice the target credential information and the source - domain credential information, and add the spliced credential information to the request header of the cross - domain request.

[0021] Optionally, in another embodiment based on the above - mentioned method of this application, the receiving the cross - domain request for obtaining the data resource of the cross - domain object includes:

[0022] When detecting that there is a to - be - recognized request in the browser, use the target plugin to intercept the to - be - recognized request;

[0023] Analyze the resource acquisition object to be requested by the to - be - recognized request, and determine whether the resource acquisition object is a local - domain object;

[0024] When detecting that the resource acquisition object is not a local - domain object, determine that the cross - domain request is received.

[0025] Optionally, in another embodiment based on the above - mentioned method of this application, the when detecting that there is a to - be - recognized request in the browser, using the target plugin to intercept the to - be - recognized request includes:

[0026] When detecting that there is a to - be - recognized request in the browser, obtain the address information for initiating the to - be - recognized request;

[0027] When it is detected that the address information is located in the pre-recorded interception information set, the target plugin is used to intercept the request to be identified.

[0028] Optionally, in another embodiment based on the above method of the present application, before receiving the cross-domain request for obtaining the data resource of the cross-domain object, it further includes:

[0029] In the target plugin, at least one domain identifier associated with each source address information is configured, and the domain identifier is used to reflect the domain object that can be accessed by the corresponding source address information;

[0030] The first association relationship for characterizing each source address information and the corresponding domain identifier is stored in the configuration information of the target plugin.

[0031] Optionally, in another embodiment based on the above method of the present application, before receiving the cross-domain request for obtaining the data resource of the cross-domain object, it further includes:

[0032] In the target plugin, an interception rule associated with each source address information is configured, and the interception rule is used to indicate whether the target plugin performs interception;

[0033] The second association relationship for characterizing each source address information and the corresponding interception rule is stored in the interception information set of the target plugin.

[0034] Optionally, in another embodiment based on the above method of the present application, the target plugin is a Chrome plugin.

[0035] By applying the technical solution of the embodiment of the present application, a plugin can be deployed on the browser in advance, so that after the browser receives a cross-domain request subsequently, the cross-domain request can be intercepted by the plugin and the domain credential information required for its access can be automatically selected from the pre-set credential information set, so as to achieve the purpose of automatically adding the domain credential information to the cross-domain request by using the plugin. Thus, on the one hand, a method for processing cross-domain requests by installing a plugin is realized, and further, the problem of affecting the browser function caused by modifying the browser parameters is avoided. On the other hand, the problem of affecting the business processing efficiency caused by manually adding credential information when initiating a cross-domain request in the related art is also avoided.

[0036] Among them, according to another aspect of the embodiment of the present application, a cross-domain request processing device is provided, including:

[0037] An acquisition module, configured to acquire a target domain identifier associated with the cross-domain request when receiving a cross-domain request for obtaining the data resource of the cross-domain object;

[0038] A selection module, configured to select target voucher information that matches the target domain identifier from a set of voucher information, where voucher information of multiple different domain objects is pre-associated in the set of voucher information;

[0039] A sending module, configured to add the target voucher information to the cross-domain request and send the cross-domain request with the added target voucher information to the cross-domain object.

[0040] According to another aspect of the embodiments of the present application, an electronic device is provided, including:

[0041] A memory, configured to store executable instructions; and

[0042] A processor, configured to execute the executable instructions with the memory to complete the operations of any of the above methods.

[0043] According to still another aspect of the embodiments of the present application, a computer-readable storage medium is provided, configured to store computer-readable instructions, and when the instructions are executed, the operations of any of the above methods are performed.

[0044] The above description is only an overview of the technical solutions of the present application. In order to be able to understand the technical means of the present application more clearly, it can be implemented according to the content of the specification. And in order to make the above and other effects, features, and advantages of the present application more obvious and understandable, the following specifically illustrates the specific embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] The drawings constituting a part of the specification depict the embodiments of the present application and are used together with the description to explain the principles of the present application.

[0046] Referring to the drawings, the present application can be understood more clearly according to the following detailed description, where:

[0047] Figure 1 A schematic diagram showing a method for processing a cross-domain request provided by an embodiment of the present application;

[0048] Figure 2 A general flow schematic diagram showing a method for processing a cross-domain request provided by an embodiment of the present application;

[0049] Figure 3 A general flow schematic diagram showing a method for processing a cross-domain request provided by an embodiment of the present application;

[0050] Figure 4 A schematic diagram showing the structure of an electronic device provided by an embodiment of the present application;

[0051] Figure 5The figure shows a schematic structural diagram of an electronic device provided by an embodiment of the present application;

[0052] Figure 6 The figure shows a schematic diagram of a storage medium provided by an embodiment of the present application. Detailed implementation manners

[0053] The embodiments of the technical solution of the present application will be described in detail below with reference to the accompanying drawings. The following embodiments are only used to illustrate the technical solution of the present application more clearly, and thus are only examples and cannot be used to limit the protection scope of the present application.

[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field to which this application belongs; the terms used herein are only for the purpose of describing the effects of specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above drawings are intended to cover non-exclusive inclusion.

[0055] In the description of the embodiments of this application, technical terms such as "first" and "second" are only used to distinguish different objects and cannot be understood as indicating or implying relative importance or implicitly indicating the quantity, specific order or primary-secondary relationship of the indicated technical features. In the description of the embodiments of this application, "a plurality of" means more than two unless otherwise specifically defined.

[0056] Referring to "embodiments" herein means that specific features, structures or characteristics described in connection with the embodiments may be included in at least one embodiment of this application. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.

[0057] In the description of the embodiments of this application, the term "and / or" is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this article generally represents an "or" relationship between the associated objects before and after.

[0058] The following Figures 1 - 3 is used to describe a method for processing cross-domain requests according to an exemplary embodiment of the present application. It should be noted that the following application scenarios are only shown for the convenience of understanding the spirit and principle of the embodiments of the present application, and the embodiments of the present application are not limited in this regard. On the contrary, the embodiments of the present application can be applied to any applicable scenario.

[0059] The electronic device disclosed in the embodiments of the present application can be one or more computing devices, or can be a server or a server cluster composed of multiple servers.

[0060] In the related art, due to the security policy of the browser, cross - domain problems are usually encountered during the communication and transmission between different domain objects. It can be understood that cross - domain requests not only limit the data transmission, but also lead to restrictions on credential information and source domain settings.

[0061] In one way, the credential information in the embodiments of the present application can be Cookie data, where Cookie is a text data of information bits created by a web server and sent to a web browser. It is usually used to identify the requester's identity.

[0062] As an example, a Cookie can be a small text data containing letters and numbers, which can remember certain information about a domain object. In one way, the requester initiating a cross - domain request can store this credential information in the user's local browser cache and keep it until the user initiates a cross - domain request.

[0063] In one way, Cookies have a lifecycle. When business personnel set the Cookie value, they can also set the corresponding expiration period. That is, when the Cookie exceeds this expiration period, the Cookie will become invalid.

[0064] In one way, during the development process, developers often need to modify or simulate cross - domain Cookies and the request origin (Origin) to debug or test the code. This process usually requires modifying the parameter settings of the browser. However, due to the short effective time of Cookies, this also causes developers to manually update the cookies continuously every time they initiate a cross - domain request, thus greatly affecting the development efficiency of business processing.

[0065] Therefore, in order to solve the problem of affecting the business processing efficiency caused by the need to manually add credential information when initiating cross - domain requests in the related art as mentioned above. The embodiments of the present application provide a method for processing cross - domain requests. The solution is to deploy a plugin on the browser in advance, so that after the browser receives a cross - domain request subsequently, the plugin can intercept the cross - domain request and automatically select the domain credential information required for its access from a pre - set set of credential information, so as to achieve the purpose of automatically adding the domain credential information to the cross - domain request by using the plugin.

[0066] In one way, the embodiments of the present application also propose a method, device, electronic device and storage medium for processing cross - domain requests.

[0067] Figure 1 A flowchart schematically shows a method for processing cross - domain requests according to an embodiment of the present application. As Figure 1 shown, this method is applied to a browser deployed with a target plugin and includes:

[0068] S101, when receiving a cross - domain request for obtaining data resources of a cross - domain object, obtain a target domain identifier associated with the cross - domain request.

[0069] In one way, the credential information in the embodiment of the present application can be Cookie data, where Cookie is a text data of information bits created by a web server and sent to a web browser. It is usually used to identify the requester.

[0070] In one way, the cross - domain request in the embodiment of the present application refers to that in a browser, when a script of one web page requests to access resources of another web page, if the domain names, protocols, or ports of these two web pages are different, a cross - domain situation occurs.

[0071] For example, when a user in domain A wants to obtain data resources in domain B, he needs to send a cross - domain request to an object in domain B (i.e., a cross - domain object).

[0072] In one way, there are cross - domain problems with cross - domain requests. The cross - domain problem is caused by the browser's Same - Origin Policy. It can be understood that the Same - Origin Policy is a security mechanism that stipulates the restrictions on web page communication and interaction between different origins to prevent malicious websites from obtaining sensitive information of users in other domains through scripts.

[0073] In one way, the target plugin in the embodiment of the present application can be a Chrome plugin. Among them, a Chrome plugin is an extension program that can be installed and used in a browser and can customize functions according to user needs and extend the functions of the browser.

[0074] In one way, the browser in the embodiment of the present application can be Google Chrome browser.

[0075] In one way, the target domain identifier in the embodiment of the present application is the identifier of the cross - domain object that the source - domain object requests this time. Among them, this identifier is used to reflect information such as the name or address of the target domain that can reflect the target domain.

[0076] S102, select target credential information that matches the target domain identifier from the set of credential information, where the set of credential information is pre - associated with credential information of multiple different domain objects.

[0077] In one way, the embodiments of the present application can utilize the interface function of the Chrome plugin to collect the Cookie information of all domain objects in the business environment to which the browser belongs in advance, and uniformly store it in the credential information set.

[0078] In one way, since each Cookie has timeliness. Therefore, the embodiments of the present application can periodically collect the Cookie information of all domain objects in the business environment, and after collecting new Cookie information, update the Cookie information in the credential information set.

[0079] S103, Add the target credential information to the cross-domain request, and send the cross-domain request with the target credential information added to the cross-domain object.

[0080] In one way, as Figure 2 shown, the embodiments of the present application can first utilize the interface function of the Chrome plugin to intercept the cross-domain request sent by the browser. And after intercepting the request of the source domain address, judge the identifiers of at least one target domain associated with the source domain address according to the configuration information (for example, including target domain A corresponding to project A and target domain B corresponding to project B). And use the target domain A and the target domain B as the target domains to be accessed by this cross-domain request.

[0081] In one way, the Chrome plugin of the embodiments of the present application can find and extract the credential information A of the target domain A and the credential information B of the target domain B from the credential information set (that is, cookie Store), and use the credential information A and the credential information B as the target credential information.

[0082] In one way, the Chrome plugin of the embodiments of the present application can splice the credential information C of the source domain with the credential information A and the credential information B, and add the spliced combined credential information to the request header of this cross-domain request. And perform operations such as sending to the backend server subsequently.

[0083] It can be understood that through the above operations, it is possible to automatically carry the real and valid credential information on the cross-domain request, so that through interface authentication, developers can accurately simulate the requests in the real environment for development, improving the business processing efficiency.

[0084] In summary, the technical solution of the embodiments of the present application is to deploy a plugin on the browser in advance, so that after the browser receives a cross-domain request subsequently, the plugin can intercept the cross-domain request and automatically select the domain credential information required for its access from the pre-set credential information set, so as to achieve the purpose of automatically adding the domain credential information to the cross-domain request by using the plugin.

[0085] The descriptions of the various embodiments above tend to emphasize the differences between the various embodiments. For their similarities, reference can be made to each other. For the sake of brevity, they will not be elaborated herein.

[0086] By applying the technical solution of the embodiment of the present application, on the one hand, a method for processing cross - domain requests by installing a plug - in is realized, thereby avoiding the problem of affecting the browser function caused by modifying browser parameters. On the other hand, it also avoids the problem of affecting the business processing efficiency caused by the need to manually add credential information when initiating cross - domain requests in the related art.

[0087] In one way, in the process of determining the target domain identifier for a cross - domain request in the embodiment of the present application, it can be realized through the following two methods:

[0088] The first method:

[0089] Obtain the source address information of the initiated cross - domain request, and based on the pre - recorded configuration information, obtain all domain identifiers associated with the source address information;

[0090] Use all domain identifiers as the target domain identifier.

[0091] In one way, the browser can pre - associate one or more different domain objects with each source address, and use all these domain objects as the target domains for this access.

[0092] In other words, the browser believes that as long as it receives a cross - domain request sent from this source address, it is considered that this request needs to access all domain objects associated with it.

[0093] As an example, the browser can pre - associate 3 domain objects with the source address www.123.com, namely www.a.com, www.b.com, and www.c.com. And store the mapping relationship between their respective domain identifiers a, domain identifier b, domain identifier c and www.123.com into the browser's configuration information.

[0094] In one way, when the browser subsequently receives a cross - domain request sent from www.123.com, it can extract the domain identifiers a, domain identifier b, domain identifier c associated with this source address information by looking up the configuration information. And use these 3 domain identifiers as the target domain identifiers to be accessed this time.

[0095] The second method:

[0096] Extract the to - be - accessed domain identifier included in the cross - domain request, which is used to characterize the object of this resource acquisition;

[0097] Determine that all domain identifiers contain the domain identifier;

[0098] Use the domain identifier as the target domain identifier.

[0099] In one way, after obtaining a cross-domain request, the browser can also extract the domain identifier to be accessed carried in this request, and after determining that the domain identifier to be accessed is a permitted domain identifier (that is, it is within all domain identifiers), use it as the target domain identifier that can be accessed this time.

[0100] As an example, the browser can also pre-associate 3 domain objects with the source address www.123.com, which are www.a.com, www.b.com, and www.c.com respectively. And store the mapping relationships between their respective domain identifiers a, domain identifier b, and domain identifier c and www.123.com into the configuration information of the browser.

[0101] Recorded as, www.123.com - domain identifier a - domain identifier b - domain identifier c.

[0102] In one way, when the browser subsequently receives a cross-domain request sent by www.123.com, it can extract the domain identifier to be accessed (domain identifier b) carried in the request by parsing the cross-domain request, and when determining that domain identifier b is within the scope of all domain identifiers corresponding to the source address information, use the domain identifier b as the target domain identifier to be accessed this time.

[0103] Optionally, in another embodiment based on the above method of the present application, use a target plug-in to add target credential information to the cross-domain request, including:

[0104] Obtain the source domain credential information carried in the cross-domain request;

[0105] According to a preset splicing rule, splice the target credential information with the source domain credential information, and add the spliced credential information to the request header of the cross-domain request.

[0106] In one way, the embodiment of the present application can use the Chrome plug-in of the browser to splice the credential information of the source domain with the target credential information, and add the spliced combined credential information to the request header of the cross-domain request. And subsequently send the cross-domain request to the backend server.

[0107] Optionally, in another embodiment based on the above method of the present application, receive a cross-domain request for obtaining data resources of a cross-domain object, including:

[0108] When detecting that there is a request to be recognized in the browser, use a target plug-in to intercept the request to be recognized;

[0109] Parse the resource acquisition object requested by the request to be recognized, and determine whether the resource acquisition object is a local domain object;

[0110] It is detected that the resource acquisition object is not the object of this domain, and it is determined that a cross-domain request is received.

[0111] In one way, the embodiments of the present application can intercept requests sent by the browser through the API of the Chrome plugin. Among them, the request may be a cross-domain request or a same-domain request.

[0112] It can be understood that the embodiments of the present application first need to identify whether the request is a cross-domain request, that is, it is necessary to determine whether the request needs to obtain additional Cookies.

[0113] In one way, the browser can determine whether the request needs to obtain additional Cookies by parsing whether the resource acquisition object to be requested by the request to be identified is the object of this domain. It can be understood that if so, it means that the current request is a cross-domain request. Otherwise, it is a same-domain request.

[0114] Optionally, in another embodiment based on the above method of the present application, before receiving a cross-domain request for obtaining data resources of a cross-domain object, it further includes:

[0115] In the target plugin, configure an interception rule associated with each source address information, and the interception rule is used to indicate whether the target plugin performs interception;

[0116] Store the second association relationship representing each source address information and the corresponding interception rule into the interception information set of the target plugin.

[0117] Optionally, in another embodiment based on the above method of the present application, when it is detected that the browser has a request to be identified, using the target plugin to intercept the request to be identified includes:

[0118] When it is detected that the browser has a request to be identified, obtain the address information of the request to be identified;

[0119] When it is detected that the address information is located in the pre-recorded interception information set, use the target plugin to intercept the request to be identified.

[0120] In one way, the embodiments of the present application can pre-configure the interception rules of each source address information in the target plugin of the browser and store them in the interception information set.

[0121] In one way, the target plugin only intercepts requests from specific source addresses for processing.

[0122] As an example, the target plugin of the browser can pre-configure the interception rule 1 of "needs to be intercepted" for the source address www.123.com, the interception rule 2 of "does not need to be intercepted" for the source address www.456.com, and the interception rule 3 of "needs to be intercepted" for the source address www.789.com. And store the interception rule 1 and the interception rule 3 into the interception information set.

[0123] It can be understood that subsequently when the browser detects that there is a current request (i.e., the request to be recognized), it can first obtain the address information of the request to be recognized (which is the source address www.123.com). And match this www.123.com with the content recorded in the interception information set. It can be understood that when it is determined that the interception rule for www.123.com is not to be intercepted, it can be intercepted and the step of obtaining the target domain identifier can be executed.

[0124] Optionally, in another embodiment based on the above method of the present application, before receiving the cross-domain request for obtaining the data resource of the cross-domain object, it further includes:

[0125] In the target plugin, configure at least one domain identifier associated with each source address information, and the domain identifier is used to reflect the domain object that can be accessed by the corresponding source address information;

[0126] Store the first association relationship for characterizing each source address information and the corresponding domain identifier into the configuration information of the target plugin.

[0127] In one way, the embodiment of the present application can use the interface function of the Chrome plugin to pre-associate one or more domain objects with each source address. For example, associate www.a.com, www.b.com, and www.c.com with www.123.com. And store the first association relationship between their respective domain identifiers a, domain identifier b, and domain identifier c and www.123.com into the configuration information of the browser. Recorded as, www.123.com - domain identifier a - domain identifier b - domain identifier c.

[0128] In one way, since the cross-domain problem is one of the common problems in front-end development, the above solution of the embodiment of the present application can conveniently set Cookies and Origins, reduce the cumbersome operation of manually modifying the request headers, and improve the efficiency of cross-domain debugging.

[0129] In another way, cross-domain issues may cause delays and obstacles in the development process. By using the above-mentioned solutions of the embodiments of the present application, developers can quickly solve cross-domain problems, reduce the time for waiting for back-end interface adjustment or additional configuration, and improve development efficiency. It can also support the configuration of multiple projects at the same time. The switch can be turned on and off with one key, the configuration is simple, and it is flexible and convenient to use.

[0130] As an example, in combination with Figure 3 A specific description of a method for processing cross-domain requests proposed in the embodiments of the present application is as follows:

[0131] Step 1: When a request to be recognized is detected in the browser, use the target plug-in to intercept the request to be recognized.

[0132] Step 2: Analyze the resource acquisition object that the request to be recognized is to request, and determine whether the resource acquisition object is a local object.

[0133] Step 3: When it is detected that the resource acquisition object is not a local object, it is determined that a cross-domain request is received.

[0134] Step 4: Obtain the target domain identifier associated with the cross-domain request.

[0135] Among them, there are two ways to obtain the target domain identifier, that is, obtain the source address information of the cross-domain request, and based on the pre-recorded configuration information, obtain all the domain identifiers associated with the source address information; use all the domain identifiers as the target domain identifier; or, extract the to-be-accessed domain identifier included in the cross-domain request for characterizing the current resource acquisition object, and use the to-be-accessed domain identifier as the target domain identifier.

[0136] Step 5: Select the target credential information that matches the target domain identifier from the set of credential information, and obtain the source domain credential information carried in the cross-domain request.

[0137] Among them, the set of credential information is pre-associated with the credential information of multiple different domain objects.

[0138] Step 6: Concatenate the target credential information and the source domain credential information according to the preset concatenation rule, and add the concatenated credential information to the request header of the cross-domain request.

[0139] Step 7: Send the cross-domain request with the target credential information added to the cross-domain object.

[0140] By applying the technical solution of the embodiment of the present application, a plugin can be pre-deployed on the browser, so that after the browser receives a cross-domain request subsequently, the cross-domain request can be intercepted by the plugin and the domain credential information required for its access can be automatically selected from the pre-set credential information set, so as to achieve the purpose of automatically adding the domain credential information to the cross-domain request by using the plugin. Thus, on the one hand, a method for processing cross-domain requests by installing a plugin is realized, and further, the problem of affecting the browser function caused by modifying browser parameters is avoided. On the other hand, it also avoids the problem of affecting the business processing efficiency caused by manually adding credential information when initiating a cross-domain request in the related art.

[0141] The descriptions of the above embodiments tend to emphasize the differences between the embodiments, and their similarities or similarities can be referred to each other. For the sake of brevity, they will not be elaborated in this article.

[0142] Optionally, in another embodiment of the present application, as Figure 4 shown, the present application further provides a cross-domain request processing device. It includes:

[0143] An obtaining module 201, configured to obtain a target domain identifier associated with the cross-domain request when receiving a cross-domain request for obtaining data resources of a cross-domain object;

[0144] A selecting module 202, configured to select target credential information that matches the target domain identifier from a credential information set, where multiple pieces of credential information of different domain objects are pre-associated in the credential information set;

[0145] A sending module 203, configured to add the target credential information to the cross-domain request and send the cross-domain request with the added target credential information to the cross-domain object.

[0146] By applying the technical solution of the embodiment of the present application, a plugin can be pre-deployed on the browser, so that after the browser receives a cross-domain request subsequently, the cross-domain request can be intercepted by the plugin and the domain credential information required for its access can be automatically selected from the pre-set credential information set, so as to achieve the purpose of automatically adding the domain credential information to the cross-domain request by using the plugin. Thus, on the one hand, a method for processing cross-domain requests by installing a plugin is realized, and further, the problem of affecting the browser function caused by modifying browser parameters is avoided. On the other hand, it also avoids the problem of affecting the business processing efficiency caused by manually adding credential information when initiating a cross-domain request in the related art.

[0147] In another embodiment of the present application, the selecting module 202 is configured to:

[0148] Obtain the source address information for initiating the cross - domain request, and based on the pre - recorded configuration information, obtain all domain identifiers associated with the source address information;

[0149] Use all the domain identifiers as the target domain identifiers; or,

[0150] Extract the to - be - accessed domain identifier included in the cross - domain request, which is used to characterize the resource acquisition object of this time, and use the to - be - accessed domain identifier as the target domain identifier.

[0151] In another embodiment of the present application, the selection module 202 is configured as:

[0152] Determine that the domain identifier is included in all the domain identifiers;

[0153] Use the domain identifier as the target domain identifier.

[0154] In another embodiment of the present application, the selection module 202 is configured as:

[0155] Obtain the source - domain credential information carried in the cross - domain request;

[0156] According to a preset splicing rule, splice the target credential information with the source - domain credential information, and add the spliced credential information to the request header of the cross - domain request.

[0157] In another embodiment of the present application, the selection module 202 is configured as:

[0158] When it is detected that there is a request to be recognized in the browser, use the target plug - in to intercept the request to be recognized;

[0159] Analyze the resource acquisition object that the request to be recognized is to request, and determine whether the resource acquisition object is a local - domain object;

[0160] When it is detected that the resource acquisition object is not a local - domain object, determine that the cross - domain request has been received.

[0161] In another embodiment of the present application, the selection module 202 is configured as:

[0162] When it is detected that there is a request to be recognized in the browser, obtain the address information for initiating the request to be recognized;

[0163] When it is detected that the address information is located in the pre - recorded interception information set, use the target plug - in to intercept the request to be recognized.

[0164] In another embodiment of the present application, the selection module 202 is configured as:

[0165] In the target plug-in, at least one domain identifier associated with each source address information is configured, and the domain identifier is used to reflect the domain object that can be accessed by the corresponding source address information;

[0166] The first association relationship used to represent each source address information and the corresponding domain identifier is stored in the configuration information of the target plug-in.

[0167] In another implementation manner of the present application, the selection module 202 is configured as:

[0168] In the target plug-in, an interception rule associated with each source address information is configured, and the interception rule is used to indicate whether the target plug-in performs interception;

[0169] The second association relationship used to represent each source address information and the corresponding interception rule is stored in the interception information set of the target plug-in.

[0170] In another implementation manner of the present application, the selection module 202 is configured as:

[0171] The target plug-in is a Chrome plug-in.

[0172] The descriptions of the above embodiments tend to emphasize the differences between the embodiments. Their similarities or similarities can be referred to each other. For the sake of brevity, they will not be repeated herein.

[0173] The embodiments of the present application also provide an electronic device to execute the above cross-domain request processing method. Please refer to Figure 5 , which shows a schematic diagram of an electronic device provided by some embodiments of the present application. As Figure 5 shown, the electronic device 3 includes: a processor 300, a memory 301, a bus 302, and a communication interface 303. The processor 300, the communication interface 303, and the memory 301 are connected through the bus 302; a computer program that can run on the processor 300 is stored in the memory 301, and when the processor 300 runs the computer program, it executes the cross-domain request processing method provided by any one of the foregoing embodiments of the present application.

[0174] Among them, the memory 301 may include a high-speed random access memory (RAM: Random Access Memory), and may also include a non-volatile memory, such as at least one disk memory. Through at least one communication interface 303 (which can be wired or wireless), a communication connection between the device network element and at least one other network element is realized, and the Internet, a wide area network, a local area network, a metropolitan area network, etc. can be used.

[0175] The bus 302 can be an ISA bus, a PCI bus, an EISA bus, or the like. The bus can be divided into an address bus, a data bus, a control bus, and the like. Among them, the memory 301 is used to store a program. After receiving an execution instruction, the processor 300 executes the program. The method for processing the cross-domain request disclosed in any implementation manner of the embodiments of the present application can be applied to or implemented by the processor 300.

[0176] The processor 300 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit in the hardware of the processor 300 or the instructions in the form of software. The above-mentioned processor 300 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application.

[0177] The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of the hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory 301, and the processor 300 reads the information in the memory 301 and combines its hardware to complete the steps of the above method.

[0178] The electronic device provided in the embodiments of the present application and the method for processing cross-domain requests provided in the embodiments of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run, or implemented by them.

[0179] The descriptions of the above embodiments tend to emphasize the differences between the embodiments. Their similarities or similarities can be referred to each other. For the sake of brevity, they will not be repeated herein.

[0180] The embodiments of the present application also provide a computer-readable storage medium corresponding to the method for processing cross-domain requests provided in the foregoing embodiments. Please refer to Figure 6, which shows that the computer-readable storage medium is an optical disc 40, on which a computer program (i.e., program product) is stored. When the computer program is run by a processor, it will execute the cross-domain request processing method provided in any of the foregoing embodiments.

[0181] It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory, or other optical and magnetic storage media, which will not be elaborated here one by one.

[0182] The computer-readable storage medium provided in the above embodiments of the present application and the cross-domain request processing method provided in the embodiments of the present application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run, or implemented by the application programs stored therein.

[0183] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit them. Although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some or all of the technical features. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application, and they should all be covered by the scope of the claims and the description of the present application. In particular, as long as there is no structural conflict, the technical features mentioned in each embodiment can be combined in any way. The present application is not limited to the specific embodiments disclosed in the text, but includes all technical solutions that fall within the scope of the claims.

Claims

1. A method for processing cross - domain requests, characterized in that, Applied to a browser with a target plugin, including: When receiving a cross - domain request for obtaining data resources of a cross - domain object, obtaining a target domain identifier associated with the cross - domain request; Selecting target credential information that matches the target domain identifier from a set of credential information, where the set of credential information is pre - associated with credential information of multiple different domain objects; Adding the target credential information to the cross - domain request and sending the cross - domain request with the added target credential information to the cross - domain object.

2. The method according to claim 1, characterized in that, The obtaining the target domain identifier associated with the cross - domain request includes: Obtaining the source address information for initiating the cross - domain request and, based on pre - recorded configuration information, obtaining all domain identifiers associated with the source address information; Using the all domain identifiers as the target domain identifier; or, Extracting the to - be - accessed domain identifier included in the cross - domain request for characterizing the object of this resource acquisition and using the to - be - accessed domain identifier as the target domain identifier.

3. The method according to claim 2, characterized in that, The using the domain identifier as the target domain identifier includes: Determining that the all domain identifiers contain the domain identifier; Using the domain identifier as the target domain identifier.

4. The method according to claim 1, characterized in that, The adding the target credential information to the cross - domain request by using the target plugin includes: Obtaining the source - domain credential information carried in the cross - domain request; According to a preset splicing rule, splicing the target credential information with the source - domain credential information and adding the spliced credential information to the request header of the cross - domain request.

5. The method according to claim 1, characterized in that, The receiving a cross - domain request for obtaining data resources of a cross - domain object includes: When detecting that there is a request to be recognized in the browser, intercepting the request to be recognized by using the target plugin; Parsing the resource acquisition object requested by the request to be recognized and determining whether the resource acquisition object is a local domain object; When detecting that the resource acquisition object is not a local domain object, determining that the cross - domain request is received.

6. The method according to claim 5, characterized in that, The when detecting that there is a request to be recognized in the browser, intercepting the request to be recognized by using the target plugin includes: When detecting that there is a request to be recognized in the browser, obtaining the address information for initiating the request to be recognized; When detecting that the address information is in a pre - recorded set of interception information, intercepting the request to be recognized by using the target plugin.

7. The method according to claim 1, characterized in that, Before the receiving a cross - domain request for obtaining data resources of a cross - domain object, it further includes: In the target plugin, configuring at least one domain identifier associated with each source address information, where the domain identifier is used to reflect the domain object that can be accessed by the corresponding source address information; Storing the first association relationship for characterizing each source address information and the corresponding domain identifier into the configuration information of the target plugin.

8. The method according to claim 1, characterized in that, Before the receiving a cross - domain request for obtaining data resources of a cross - domain object, it further includes: In the target plugin, configuring an interception rule associated with each source address information, where the interception rule is used to indicate whether the target plugin performs interception; Storing the second association relationship for characterizing each source address information and the corresponding interception rule into the set of interception information of the target plugin.

9. The method according to any one of claims 1 - 8, characterized in that, The target plugin is a Chrome plugin.

10. A device for processing cross - domain requests, characterized in that, Applied to a browser with a target plugin, including: An acquisition module, configured to acquire a target domain identifier associated with the cross-domain request when receiving a cross-domain request for acquiring a data resource of a cross-domain object; A selection module, configured to select target credential information that matches the target domain identifier from a set of credential information, where the set of credential information is pre-associated with credential information of multiple different domain objects; A sending module, configured to add the target credential information to the cross-domain request and send the cross-domain request with the added target credential information to the cross-domain object.

11. An electronic device, characterized in that, Including: A memory for storing executable instructions; And, A processor for executing the executable instructions to complete the operations of any one of claims 1-9.

12. A computer-readable storage medium for storing computer-readable instructions, characterized in that, The instructions are used to execute the operations of any one of claims 1-9.