[go: up one dir, main page]

CN112015383B - A login method and device - Google Patents

A login method and device Download PDF

Info

Publication number
CN112015383B
CN112015383B CN201910452009.9A CN201910452009A CN112015383B CN 112015383 B CN112015383 B CN 112015383B CN 201910452009 A CN201910452009 A CN 201910452009A CN 112015383 B CN112015383 B CN 112015383B
Authority
CN
China
Prior art keywords
login
request
address information
response message
request message
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910452009.9A
Other languages
Chinese (zh)
Other versions
CN112015383A (en
Inventor
马喜鹏
何小锋
刘海锋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201910452009.9A priority Critical patent/CN112015383B/en
Publication of CN112015383A publication Critical patent/CN112015383A/en
Application granted granted Critical
Publication of CN112015383B publication Critical patent/CN112015383B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • G06F16/972Access to data in other repository systems, e.g. legacy data or dynamic Web page generation

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a login method and a login device, and relates to the technical field of computers. The method comprises the steps of intercepting a request message and a response message corresponding to the request message, judging whether a user logs in according to a predefined login judgment rule and a state code in the response message, wherein the login judgment rule is provided with the state code and meaning represented by the state code, and acquiring login address information from the response message under the condition that the user does not log in so as to log in based on the login address information. In the method, after intercepting the request message and the corresponding response message, the client acquires login address information from the response message when judging that the user is not logged on based on the set login judgment rule and the response message, and further completes login. The method realizes a flexible login mode, and the client only needs to perform good login interception and does not need to care which address to use for login.

Description

Login method and device
Technical Field
The present invention relates to the field of computers, and in particular, to a login method and device.
Background
Most of the current application programs are developed in a way of separating a client from a server, the client uses technologies such as Vue and practice, and the server provides an interface. In application programs, user login is the most basic function, and in the prior art, login processing is generally performed only from a server (also referred to as a back-end) or a client. The realization principle of login processing from the server side is that the server side is provided with an interceptor for intercepting all page requests, judging whether login identification exists in the page requests, if not, automatically jumping to a login page, and if so, continuing to complete the page requests. The realization principle of the login processing from the client side is that the client side judges whether a cookie exists in the page opened for the first time, if so, the client side does not process, and if not, the client side jumps to the login page.
In the process of implementing the present invention, the inventor finds that at least the following problems exist in the prior art:
(1) The method for login processing from the server is only suitable for rendering of the server or the situation that the client and the server are not separated, and in the large environment that the client and the server are separated, the method can not jump to a login page due to blocking of the client service or the reason of the client ajax.
(2) In addition, the login configuration of the method has poor flexibility, the login configuration needs to be frequently modified in a test environment and an offline environment, and if the login configuration is modified by mistake, the online failure is caused.
Disclosure of Invention
In view of the above, the embodiments of the present invention provide a login method and device, after a client intercepts a request message and a corresponding response message, based on a set login judgment rule and the response message, when it is determined that a user is not logged in, login address information is obtained from the response message, so as to complete login. The embodiment of the invention realizes a flexible login mode, and the client only needs to log in and intercept, and does not need to care which address to log in.
To achieve the above object, according to an aspect of an embodiment of the present invention, there is provided a login method.
The login method comprises the steps of intercepting a request message and a response message corresponding to the request message, judging whether a user logs in or not according to a predefined login judgment rule and a state code in the response message, wherein the login judgment rule is provided with the state code and meaning represented by the state code, and acquiring login address information from the response message under the condition that the user does not log in so as to log in based on the login address information.
Optionally, the method further comprises the steps of packaging the request message into a public request class, respectively defining a method corresponding to the server interface, packaging the address information of the server interface into the method according to the request type of the server interface, transmitting a packaging result to the public request class, and outputting the method name of the method.
Optionally, the method for encapsulating the request message into a common request class comprises the steps of creating an instance object, outputting the instance object, intercepting the request message by using a request interceptor, adding common header information in the request message, intercepting a response message corresponding to the request message by using a response interceptor, and processing the response message.
Optionally, the login based on the login address information comprises the steps of splicing the login address information and the current address information corresponding to the request information, and performing skip login according to the spliced address information.
Optionally, the obtaining the login address information from the response message includes obtaining the login address information from header information of the response message, where the header information includes the login address information provided by a server.
To achieve the above object, according to another aspect of the embodiments of the present invention, there is provided a login device.
The login device comprises an interception module, a judgment module and a login module, wherein the interception module is used for intercepting a request message and a response message corresponding to the request message, the judgment module is used for judging whether a user logs in or not according to a predefined login judgment rule and a state code in the response message, the state code and meaning represented by the state code are arranged in the login judgment rule, and the login module is used for acquiring login address information from the response message under the condition that the user does not log in so as to log in based on the login address information.
Optionally, the device further comprises an encapsulation module, a method name and a method module, wherein the encapsulation module is used for encapsulating the request message into a public request class, respectively defining a method corresponding to a server interface, encapsulating the address information of the server interface into the method according to the request type of the server interface, transmitting an encapsulation result to the public request class, and outputting the method name of the method.
Optionally, the encapsulation module is further configured to create an instance object, output the instance object, intercept the request message with a request interceptor, add common header information to the request message, intercept a response message corresponding to the request message with a response interceptor, and process the response message.
Optionally, the login module is further configured to splice the login address information with current address information corresponding to the request information, and perform skip login according to the spliced address information.
Optionally, the judging module is further configured to obtain login address information from header information of the response message, where the header information includes the login address information provided by the server.
To achieve the above object, according to still another aspect of the embodiments of the present invention, there is provided an electronic device.
The electronic equipment comprises one or more processors and a storage device, wherein the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors are enabled to realize a login method of the embodiment of the invention.
To achieve the above object, according to still another aspect of the embodiments of the present invention, there is provided a computer-readable medium.
A computer readable medium of an embodiment of the present invention has stored thereon a computer program which, when executed by a processor, implements a login method of an embodiment of the present invention.
The embodiment of the invention has the advantages that after the client intercepts the request message and the corresponding response message, the client acquires login address information from the response message to finish login when judging that the user is not logged in based on the set login judgment rule and the response message, so that a flexible login mode is realized, the client only needs to carry out login interception without concern about which address is used for login, the client carries out login judgment by combining a unified login judgment rule and a state code without judging whether cookies exist, the problems of cookie counterfeiting and the like are prevented, the flexibility of the client is further improved, the request message is uniformly packaged into a public request class by a secondary packaging mode, the service interface is uniformly packaged into a client API, the unified processing of the request message and the response message is realized, the workload of repeated codes is reduced, and the login interception is easily realized.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a login method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of the main principle of a login method according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a main flow of a login method according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the major modules of a login device according to an embodiment of the present invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
Fig. 6 is a schematic structural diagram of a computer device suitable for use in an electronic apparatus to implement an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
The terms involved in the embodiments of the present invention are explained below.
The front end, the webpage or interface which is directly interacted with the user, is one of the clients.
A client-side, a party that may initiate a request to a server, such as a section APP (Application).
Back-end or server-end, a party capable of responding to a client request, such as a cloud server.
Vue is a set of progressive frameworks used to build user interfaces. Unlike other large frameworks, vue is designed to be applied layer by layer from bottom up.
React is a JavaScript library derived from Facebook for building user interfaces.
JavaScript is an transliteration scripting language, abbreviated as JS, is a dynamic type, weak type, prototype-based language, and is internally provided with a support type.
Cookie-refers to data that some web sites store on the user's local terminal for purposes of identifying the user's identity, performing session tracking.
Ajax, asynchronous Javascript And XML (asynchronous JavaScript and XML), refers to a web page development technique that creates interactive web page applications.
XML, extensible Markup Language (extensible markup language), is a markup language used to mark electronic files to make them structured.
Axios is a promise (promise) based http client which can be used in a browser and nodes (a Javascript running environment) and can finish ajax asynchronous request.
Url, uniform Resource Locator (uniform resource locator), is the address of a standard resource on the internet.
Fig. 1 is a schematic diagram of main steps of a login method according to an embodiment of the present invention. As shown in fig. 1, the login method in the embodiment of the present invention mainly includes the following steps:
And step S101, intercepting a request message and a response message corresponding to the request message. The method comprises the steps of encapsulating request messages into public request classes in advance, specifically creating instance objects in the public request classes, intercepting at least one request message sent by a client by using a request interceptor, uniformly processing the request message, intercepting response messages corresponding to the request message returned by a server by using a response interceptor, and uniformly processing the response messages. The subsequent client can intercept the request message by calling the request interceptor and intercept the response message by the response interceptor.
Step S102, judging whether the user logs in or not according to a predefined login judgment rule and a state code in the response message. The client and the server uniformly register a judgment rule, and the rule is provided with state codes and meanings corresponding to the state codes, such as a definition state code 401, which represents that the user does not register. The client can judge whether the user logs in according to the login judgment rule and the state code in the response message after intercepting the response message.
And step S103, acquiring login address information from the response message to log in based on the login address information when the user is not logged in. The method comprises the steps of firstly encapsulating interfaces requested by a server, specifically defining methods corresponding to the interfaces of the server respectively, encapsulating address information of the interfaces of the server into the methods according to request types of the interfaces of the server, transmitting encapsulation results to a public request class, and outputting method names of the methods. And if the client judges that the user is not logged in and the login address information is acquired, the client can call a corresponding method through a method name so as to splice the login address information and the address information of the address bar currently accessed by the user, and then perform jump login according to the spliced address information.
Fig. 2 is a schematic diagram of the principle of a login method according to an embodiment of the present invention. As shown in fig. 2, in order to achieve the object of the present invention, the client (front end in the embodiment) performs a multi-layer process, including a page view (view) layer, a common processing layer, and an application program interface layer.
And the page view layer comprises all the request messages, and is used for sending the request messages of the pages and rendering the pages.
The public processing layer contains a self-defined request, which is requestJS in the embodiment, and is used for intercepting the request information by using a request interceptor, summarizing and uniformly processing all the request information of the page, and outputting the request information to the application program interface layer, and intercepting the response information from the application program interface layer by using a response interceptor, summarizing and uniformly processing all the response information. In the embodiment, a secondary packaging mode is adopted to realize unified processing of all messages.
And the application program interface layer is used for packaging all the server interfaces and exposing a method name to the page view layer. The method has the advantages that all interfaces of the server can be managed in a unified way, if url of the interfaces of the server changes, only the file attribute corresponding to the layer is required to be changed, a large-area page changing request message is not needed, and repeated requests and repeated codes of the client are reduced. The application program interface layer is also used for sending the request message to the server which is currently connected with the client by the http through the corresponding interface after receiving the request message, and the interface is used for sending the response message for the request message from the server to the response interceptor after receiving the response message for the request message.
Fig. 3 is a schematic flow chart of a login method according to an embodiment of the present invention. As shown in fig. 3, the login method in the embodiment of the present invention mainly includes the following steps:
In step S301, the common processing layer encapsulates all request messages for server data from the target page into a common request class. In the embodiment, taking a single page of a Vue project as an example, all information interaction of a client and a server are axios request messages, and packaging the axios request messages into a specific implementation of a common request class (requestJS) is implemented by (1) creating a axios instance object with a name of axiosService and outputting (export) the instance object, (2) intercepting all axios request messages by using an intersystem. Request. Use method (i.e. a request interceptor) and processing the intercepted axios request messages, wherein the processing can be adding common header information such as token, timestamp and the like, and (3) intercepting response messages corresponding to axios request messages returned by the server by using the interscept. Response method (i.e. a response interceptor) and uniformly processing the response messages.
In an embodiment, the unified processing of the response message mainly includes:
(1) The value corresponding to applicationprofile attribute data in the header information (headers) of the response message is stored in the client cache.
(2) Data of content-type (content type) with value of application/properties in headers of the response message is specially processed, i.e. returned directly to the page invoker, where a promise object is returned.
(3) For other data, judging whether the state code (code) is equal to 200, if so, returning the data value in the data to the page calling program, and if not, returning the message in the data to the page calling program, wherein the object is returned to promise.
(4) Processing of error data attempts to acquire a skip path in the location field in the header (the path is login address information, which may be a url of a login page or a login window) if the code is equal to 401, and skips to an error page if the code is equal to 404.
In step S302, the application program interface layer defines methods corresponding to at least one server interface respectively, and encapsulates address information of the server interface into the methods according to the request type of the server interface. Only one standard for interface input and output is defined here. In the embodiment, the standard input to the interface only concerns the name of the called method, does not need to concern what the url of the request is, if the url of the interface of the server is changed once, only the url in the method needs to be changed, and the axios request message of each page does not need to be changed, so that the code repetition amount is greatly reduced. The criteria for interface input may be unified output of one promise object.
The following illustrates how to define the method corresponding to the server interface:
For example, the server interface is v1/application/appId
The interface of the client package is:
export function getApp(appId){
return request({
url:baseUrl+'v1/application/'+appId,
method:'get'
})
}
As another example, the server interface is v1/applications/search
The interface of the client package is:
export function searchApps(params){
let url=baseUrl+'v1/applications/search?'
for(let key in params){
url+=key+"="+params[key]+"&"
}
url=url.substring(0,url.length-1);
return request({
url:url,
method:'get'
})
}
The following illustrates how to package address information of a server interface into a method according to a request type of the server interface:
For example, for get type requests, concatenate the corresponding url and concatenate the incoming parameters after the url. Assuming that the incoming parameters are the objects { a:1, b:2}, the incoming parameters and url of the server are processed into the following format by http:// xxx.jd.com/v1/xx/ge ta= 1&b =2 during encapsulation.
For another example, for post, delete, put types of requests, the incoming parameters are placed in the data (data), so that only the corresponding url needs to be spliced, and no special processing is performed on the incoming parameters. For example delete: http:// xxx. Jd.com/v1/xx/delete/: id, id being the parameter entered.
Step S303, the application program interface layer transmits the encapsulation result to the public request class and outputs the method name of the method. The application program interface layer only exposes one method name for the Vue page, for example getApp, searchApps, when the Vue page is called, promise objects can be output only by inputting parameters according to requirements. In an embodiment, the application program interface layer transmits requestJS processed url, parameters, other header information to be processed, and the like, and outputs (export) the method names to provide the method names to the page view layer, so that the page view layer can directly call the methods.
Step S304, the page view layer calls the method name of the application program interface layer to intercept all the request messages from the target page through the public processing layer and the response messages corresponding to the request messages returned by the server side. After receiving the request message sent by the client, the server returns a corresponding response message. The public processing layer intercepts all request messages from a target page through a request interceptor, and intercepts response messages corresponding to the request messages returned by a server through a response interceptor. In an embodiment, after intercepting the request message, the common processing layer obtains a response message matched with the request message based on a pre-established http connection.
Step S305, the public processing layer judges whether the user logs in the target page according to the predefined login judging rule and the state code in the response message, if the user logs in the target page, the step S306 is executed, and if the user does not log in the target page, the step S307 is executed. Because the page is rendered by Vue instead of the server, a cookie mode is adopted in the prior art when judging whether the user logs in the target page, but the mode is easy to cause malicious cookie counterfeiting attack. In this embodiment, whether the user logs in the target page is determined by the cooperation of the client and the server, that is, by means of a unified login determination rule, where a corresponding status code indicating that the user does not log in the target page is specified in the rule. If the user does not log in the target page, the server returns the specific status code and url of the corresponding login page or login window, and the client can avoid the problem of which page the user logs in. For example, the client and the server pre-define that the user does not log in when the status code is 401, and the header information of the response message necessarily includes a location field, where the location field is used to store url (defined and stored by the server to replace different environments and systems at any time) of a login page or a login window, and the status code is other value, and accordingly indicates other meaning.
And step S306, the page view layer performs page rendering on the target page to display page content.
Step S307, the public processing layer acquires login address information from the response message, and splices the login address information and the address information of the target page so as to jump to the login page or the login window according to the spliced address information. If the status code is 401, it indicates that the user does not log in to the target page, and the client needs to jump to the login page or login window. Because the server has three sets of systems, namely testing, developing and online, the web addresses of the login pages or login windows of the systems are different, the client needs to acquire from the header given by the server, and thus the flexibility of the client can be greatly improved. In an embodiment, the common processing layer obtains url of the login page or login window from a location field included in the header of the response message. The address information of the target page is url of the address bar of the page currently accessed by the user. In an embodiment, the process of concatenating two address information may be const returnUrl =error response.headers = "? the information of the location field, namely url of the login page, is, for example, http:// xxx.jd.com, nowUrl is url of a page address field currently accessed by a user and obtained through JS, for example, http:// abc.jd.com, and url obtained after the splicing is completed is http:// xxx.jd.com return Url=http:// abc.jd.com. And finally, according to the spliced address, utilizing a location.href method of the client to finish the jump from the target page currently accessed by the user to the login page or the login window.
According to the login method, after the client intercepts the request message and the corresponding response message, when the user is judged to be not logged in based on the set login judgment rule and the response message, login address information is acquired from the response message, login is further completed, a flexible login mode is achieved, the client only needs to log in and intercept, no care is required to be taken about which address to use for login, login judgment is carried out through the unified login judgment rule and the combination of the state code, whether cookies exist or not is not required to be judged, the problems of cookie counterfeiting and the like are prevented, the flexibility of the client is further improved, the request message is uniformly packaged into a public request class through a secondary packaging mode, the service interface is uniformly packaged into a client API, the unified processing of the request message and the response message is achieved, the repeated code workload is reduced, and login interception is easily achieved.
Fig. 4 is a schematic diagram of the main modules of a login device according to an embodiment of the present invention. As shown in fig. 4, the login device 400 according to the embodiment of the present invention mainly includes:
The interception module 401 is configured to intercept a request message and a response message corresponding to the request message. The method comprises the steps of encapsulating request messages into public request classes in advance, specifically creating instance objects in the public request classes, intercepting at least one request message sent by a client by using a request interceptor, uniformly processing the request message, intercepting response messages corresponding to the request message returned by a server by using a response interceptor, and uniformly processing the response messages. The subsequent client can intercept the request message by calling the request interceptor and intercept the response message by the response interceptor.
And the judging module 402 is configured to judge whether the user logs in according to a predefined login judging rule and a status code in the response message. The client and the server uniformly register a judgment rule, and the rule is provided with state codes and meanings corresponding to the state codes, such as a definition state code 401, which represents that the user does not register. The client can judge whether the user logs in according to the login judgment rule and the state code in the response message after intercepting the response message.
And a login module 403, configured to obtain login address information from the response message when the user is not logged in, so as to perform login based on the login address information. The method comprises the steps of firstly encapsulating interfaces requested by a server, specifically defining methods corresponding to the interfaces of the server respectively, encapsulating address information of the interfaces of the server into the methods according to request types of the interfaces of the server, transmitting encapsulation results to a public request class, and outputting method names of the methods. And if the client judges that the user is not logged in and the login address information is acquired, the client can call a corresponding method through a method name so as to splice the login address information and the address information of the address bar currently accessed by the user, and then perform jump login according to the spliced address information.
In addition, the login device 400 according to the embodiment of the present invention may further include a packaging module (not shown in fig. 4) configured to package the request message into a common request class, define methods corresponding to the server interfaces respectively, package address information of the server interfaces into the methods according to request types of the server interfaces, and transmit a package result to the common request class and output a method name of the methods.
It can be seen from the above description that after the client intercepts the request message and the corresponding response message, when the user is judged to be not logged on based on the set login judgment rule and the response message, login address information is obtained from the response message, so that login is completed, a flexible login mode is realized, the client only needs to log on and intercept with which address is not required to be used, login judgment is carried out by combining a unified login judgment rule and a status code, whether cookies exist or not is not required to be judged, the problems of cookie counterfeiting and the like are further improved, the request message is uniformly packaged into a public request class by a secondary packaging mode, the service interface is uniformly packaged into a client API, the unified processing of the request message and the response message is realized, the repeated code workload is reduced, and the login interception is easily realized.
Fig. 5 illustrates an exemplary system architecture 500 in which a login method or login device of an embodiment of the present invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 is used as a medium to provide communication links between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 505 via the network 504 using the terminal devices 501, 502, 503 to receive or send messages or the like. Various communication client applications, such as shopping class applications, web browser applications, search class applications, instant messaging tools, mailbox clients, social platform software, etc., may be installed on the terminal devices 501, 502, 503.
The terminal devices 501, 502, 503 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 505 may be a server providing various services, such as a background management server providing a response to a request message transmitted by a user using the terminal devices 501, 502, 503. The background management server may perform analysis and other processing on the received request information, and feed back a processing result (for example, response information) to the terminal device.
It should be noted that, the login method provided by the embodiment of the present application is generally performed by the front end on the terminal device 501, 502, 503, and accordingly, the login device is generally disposed in the front end on the terminal device 501, 502, 503.
It should be understood that the number of terminal devices, networks and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
According to an embodiment of the invention, the invention further provides an electronic device and a computer readable medium.
The electronic device comprises one or more processors and a storage device, wherein the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors are enabled to realize a login method of the embodiment of the invention.
The computer readable medium of the present invention has stored thereon a computer program which, when executed by a processor, implements a login method of an embodiment of the present invention.
Referring now to FIG. 6, there is illustrated a schematic diagram of a computer system 600 suitable for use in implementing an electronic device of an embodiment of the present invention. The electronic device shown in fig. 6 is only an example and should not be construed as limiting the functionality and scope of use of the embodiments of the invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the computer system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
Connected to the I/O interface 605 are an input section 606 including a keyboard, a mouse, and the like, an output section 607 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like, a storage section 608 including a hard disk, and the like, and a communication section 609 including a network interface card such as a LAN card, a modem, and the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to the I/O interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on drive 610 so that a computer program read therefrom is installed as needed into storage section 608.
In particular, the processes described above in the main step diagrams may be implemented as computer software programs according to the disclosed embodiments of the invention. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the main step diagrams. In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611. The above-described functions defined in the system of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 601.
The computer readable medium shown in the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of a computer-readable storage medium may include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, a processor may be described as comprising an interception module, a determination module and a login module. The names of these modules do not constitute a limitation on the module itself in some cases, and for example, the interception module may also be described as "a module that intercepts a request message and a response message corresponding to the request message".
As a further aspect, the invention also provides a computer readable medium which may be comprised in the device described in the above embodiments or may be present alone without being fitted into the device. The computer readable medium carries one or more programs, which when executed by the device, cause the device to include intercepting a request message and a response message corresponding to the request message, determining whether a user is logged in according to a predefined login determination rule and a status code in the response message, wherein the login determination rule is provided with the status code and a meaning represented by the status code, and acquiring login address information from the response message to perform login based on the login address information when the user is not logged in.
It can be seen from the above description that after the client intercepts the request message and the corresponding response message, when the user is judged to be not logged on based on the set login judgment rule and the response message, login address information is obtained from the response message, so that login is completed, a flexible login mode is realized, the client only needs to log on and intercept, and does not need to care about which address to use for login, login judgment is performed by combining the unified login judgment rule and the state code, whether a cookie exists or not is not judged, the problems of cookie counterfeiting and the like are prevented, and the flexibility of the client is further improved.
The product can execute the method provided by the embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method. Technical details not described in detail in this embodiment may be found in the methods provided in the embodiments of the present invention.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. A login method, comprising:
intercepting a request message and a response message corresponding to the request message;
Judging whether a user logs in or not according to a predefined login judging rule and a status code in the response message, wherein the login judging rule is provided with the status code and the meaning represented by the status code;
When the user does not log in, obtaining login address information from the response message to log in based on the login address information, and further comprising:
encapsulating the request message into a common request class;
Respectively defining methods corresponding to the server interfaces, and encapsulating address information of the server interfaces into the methods according to the request types of the server interfaces;
and transmitting the encapsulation result to the public request class and outputting the method name of the method.
2. The method of claim 1, wherein said encapsulating the request message into a common request class comprises:
creating an instance object and outputting the instance object;
Intercepting the request message by using a request interceptor, and adding common header information in the request message;
and intercepting a response message corresponding to the request message by using a response interceptor, and processing the response message.
3. The method of claim 1, wherein the logging based on the logging address information comprises:
Splicing the login address information and the current address information corresponding to the request message, and performing skip login according to the spliced address information.
4. The method of claim 1, wherein the obtaining the login address information from the response message comprises obtaining the login address information from header information of the response message, wherein the header information comprises the login address information provided by a server.
5. A login device, comprising:
The interception module is used for intercepting a request message and a response message corresponding to the request message;
The judging module is used for judging whether the user logs in or not according to a predefined login judging rule and the state code in the response message, wherein the login judging rule is provided with the state code and the meaning represented by the state code;
The login module is used for acquiring login address information from the response message under the condition that the user does not login so as to login based on the login address information;
The system comprises a request module, a packaging module, a method name and a method name, wherein the request module is used for packaging the request message into a public request class, respectively defining a method corresponding to a server interface, packaging the address information of the server interface into the method according to the request type of the server interface, transmitting the packaging result to the public request class, and outputting the method name of the method.
6. The apparatus of claim 5, wherein the encapsulation module is further configured to:
creating an instance object and outputting the instance object;
Intercepting the request message by using a request interceptor, and adding common header information in the request message;
and intercepting a response message corresponding to the request message by using a response interceptor, and processing the response message.
7. The apparatus of claim 5, wherein the login module is further configured to splice the login address information and current address information corresponding to the request message, and perform skip login according to the spliced address information.
8. The apparatus of claim 5, wherein the determining module is further configured to obtain login address information from header information of the response message, and wherein the header information includes the login address information provided by a server.
9. An electronic device, comprising:
One or more processors;
Storage means for storing one or more programs,
When executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-4.
10. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-4.
CN201910452009.9A 2019-05-28 2019-05-28 A login method and device Active CN112015383B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910452009.9A CN112015383B (en) 2019-05-28 2019-05-28 A login method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910452009.9A CN112015383B (en) 2019-05-28 2019-05-28 A login method and device

Publications (2)

Publication Number Publication Date
CN112015383A CN112015383A (en) 2020-12-01
CN112015383B true CN112015383B (en) 2025-01-14

Family

ID=73501602

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910452009.9A Active CN112015383B (en) 2019-05-28 2019-05-28 A login method and device

Country Status (1)

Country Link
CN (1) CN112015383B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112905160A (en) * 2021-02-08 2021-06-04 中国工商银行股份有限公司 Axios-based package registration global interception method and device
CN114172896A (en) * 2021-12-08 2022-03-11 深圳前海环融联易信息科技服务有限公司 Processing method for front end receiving back end file stream
CN116112558A (en) * 2022-11-21 2023-05-12 上海浦东发展银行股份有限公司 Interface interception method and system based on axios

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105099678A (en) * 2014-04-29 2015-11-25 北京奇虎科技有限公司 Cloud disk login method based on external equipment and device and system thereof
CN104394133B (en) * 2014-11-14 2017-12-22 百度在线网络技术(北京)有限公司 Login method and login system
CN104468592B (en) * 2014-12-12 2017-10-31 北京百度网讯科技有限公司 Login method and login system
JP2017134695A (en) * 2016-01-29 2017-08-03 独立行政法人国立高等専門学校機構 Response confirmation system, program, and server computer
CN107395614B (en) * 2017-08-09 2021-06-22 深圳国泰安教育技术有限公司 Single sign-on method and system

Also Published As

Publication number Publication date
CN112015383A (en) 2020-12-01

Similar Documents

Publication Publication Date Title
US11575735B2 (en) Cloud application-agnostic data loss prevention (DLP)
US10592399B2 (en) Testing web applications using clusters
CN110120917A (en) Method for routing and device based on content
CN112015383B (en) A login method and device
CN109284466B (en) Method, apparatus and storage medium for enabling web page access in blockchain
CN113076294B (en) Information sharing method and device
US11811884B1 (en) Topic subscription provisioning for communication protocol
CN110704200A (en) Methods and devices for converting invocation interfaces
CN113468041A (en) Interface comparison test method and device
CN113076153B (en) Interface calling method and device
CN112131095A (en) Pressure testing method and device
US9948694B2 (en) Addressing application program interface format modifications to ensure client compatibility
CN111953718B (en) Page debugging method and device
US9398041B2 (en) Identifying stored vulnerabilities in a web service
US20210281629A1 (en) Processing of web-based applications
CN116561013B (en) Test methods, devices, electronic equipment and media based on the target service framework
AU2018390863B2 (en) Computer system and method for extracting dynamic content from websites
CN109660573B (en) Data transmission method and device
CN117194068A (en) Cross-process data transmission method, system, equipment and storage medium
CN113704080B (en) Automatic test method and device
CN112929453A (en) Method and device for sharing session data
CN110909269B (en) Log reporting method and device
CN115344330A (en) Data transmission method and device, application processing method and device, and electronic device
US8738049B1 (en) Converged dialog in hybrid mobile applications
CN113051090A (en) Interface processing method and device, interface calling method and device, system and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant