A method and system for separating the front and back ends of Gotty
By embedding the Gotty front-end into the Angular project and performing token verification and parameter checking on the back-end, the problem of inflexible page display in the Gotty system is solved, user experience and operational security are improved, and terminal operation convenience and system security are achieved. Scalability.
Patent Information
- Application Number
- CN202011464832.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-14
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2040-12-14
AI Technical Summary
When the existing Gotty system is operated on the terminal, the page display is not flexible enough, the user experience is poor, and the database operation is complex in the cloud environment, causing user inconvenience.
By embedding the Gotty front-end into the Angular project, token information transmission and custom parameters are added, token verification and parameter checking are performed on the back-end, and the front-end and back-end processing modules are separated to improve display freedom and security.
It realizes the display of terminal output on the Web browser, improves the convenience and security of user operations, reduces the difficulty of users' complex data operations, and improves the user experience and system scalability.
Smart Images

Figure CN112579076B
Abstract
Description
Technical Field
[0001] The invention discloses a method and system for separating the front-end and back-end of gotty, and relates to the technical field of database setting. Background Art
[0002] With the rapid development of Internet technology, the Internet is becoming more and more important in people's daily lives. In the current context of cloud computing and big data, the data of modern enterprises and governments is developing towards large capacity. With the development of emerging technologies of big data platforms, people have more and more ways to obtain information. When database operations are complex and page operations are not supported, people tend to operate the most direct data, that is, log in to the database through the terminal (TTY) and perform direct operations through command line tools; when the commands required to operate the database instance in the cloud environment are complex, the processing done to facilitate user operations will become more complicated;
[0003] Angular is a powerful front-end framework, and its strength lies in its ability to bind static pages with dynamic data. Its features include two-way data binding, modular code, the ability to encapsulate tags, attributes and comments, and powerful dependency injection. NG-ZORRO is a front-end UI component library built by developers from different departments such as Alibaba Computing Platform Division and Alibaba Cloud based on the original business components. There are many reasons for using NG-ZORRO, such as its rich component types, the ability to combine the ecosystem with ant-design, Alibaba's experience in its own projects, fast version updates, and a more beautiful interface.
[0004] Currently, Gotty is a simple command line tool based on Go language, which can share the terminal (TTY) as a web program; it converts the command line tool into a web program; it uses the terminal emulator (xterm) of Chrome OS to execute the terminal based on JavaScript on the web browser; the existing page display is all subject to the Gotty backend configuration, which is weak in flexibility, and the front-end page display style, format and characteristic settings cannot be freely configured. The user's experience of using the page and reading complex data are subject to the current display method, and it is impossible to obtain more convenient, fast and considerate services, resulting in poor experience and complex system use. Therefore, a method and system for separating the front-end and back-end of Gotty are invented to solve the above problems. Summary of the invention
[0005] The present invention aims at the problems of the prior art and provides a method and system for separating the front and back ends of gotty. The technical scheme adopted is: a method for separating the front and back ends of gotty, wherein the specific steps of the method include:
[0006] S1 embeds the front-end part of the gotty application into the front-end of the Angular project;
[0007] S2 creates a new front-end page on the front end of the Angular project, adding token information transmission and custom parameters;
[0008] S3 adds token verification, product name judgment, and parameter checking to the backend of the Gotty application;
[0009] S4 returns corresponding information according to the verification and checking results.
[0010] The specific steps of S2 creating a new front-end page on the front-end of the Angular project and adding the transmission of token information and custom parameters include:
[0011] S201 creates a new HTML file and adds a div element named terminal;
[0012] S202 adds a sidebar, including a connection button and a new window open button;
[0013] S203 adds help description.
[0014] The specific steps of adding token verification to the backend of the Gotty application, determining the product name, and checking the parameters include:
[0015] S301 integrates iam and adds token verification through KeycloakClient.ValidateToken. For tokens that do not meet the verification requirements, the message "the current user has no operation permission" is returned;
[0016] S302 uses the processWSConn method to add checking and verification of the product name;
[0017] S303 writes the Dockerfile file, builds the backend image, and deploys it.
[0018] The specific steps of the processWSConn method in S302 include:
[0019] S3021 reads the connection information and returns websocket connection failure when an error occurs;
[0020] S3022 compares the message types and returns an illegal message type if they are inconsistent;
[0021] S3023 converts the connection information message format. If an error occurs during the conversion process, the websocket connection fails.
[0022] S3024 verifies the token. If an error occurs, it returns that the current user has no operation permission.
[0023] S3025 obtains parameter information, and if the product application is ice, verifies it through the ice method; if the product application is mysql, verifies it through the mysql method;
[0024] S3026 converts the arguments parameter, and returns the conversion parameter failure when an error occurs;
[0025] S3027 creates related resources and returns result information.
[0026] A separation system of gotty front-end and back-end, the system specifically includes a front-end processing module, a front-end setting module, a back-end processing module and an information feedback module:
[0027] Front-end processing module: embed the front-end part of the gotty application into the front-end of the Angular project;
[0028] Front-end setting module: create a new front-end page on the front-end of the Angular project, add token information transmission and custom parameters;
[0029] Backend processing module: add token verification, product name judgment, and parameter checking to the backend of the Gotty application;
[0030] Information feedback module: returns corresponding information based on the verification and inspection results.
[0031] The front-end setting module specifically includes a file creation module, a button addition module and a description addition module:
[0032] File creation module: create a new HTML file and add a div element named terminal;
[0033] Button addition module: add sidebar, including connection button and new window opening button;
[0034] Description of additional modules: Add help description.
[0035] The backend processing module specifically includes a verification module, a name verification module and a mirroring module:
[0036] Verification and additional modules: integrate iam, add token verification through KeycloakClient.ValidateToken, and return the message "the current user has no operation permission" for tokens that do not meet the verification requirements;
[0037] Name verification module: Use the processWSConn method to add checks and verifications on product names;
[0038] Image addition module: write Dockerfile files, build backend images, and deploy them.
[0039] The name verification module specifically includes a reading module, a comparison module, a conversion module, a permission module, a parameter module, a conversion module and a creation module:
[0040] Read module: reads the connection information and returns websocket connection failure when an error occurs;
[0041] Comparison module: compares message types and returns an illegal message type if they are inconsistent;
[0042] Conversion module: converts the connection information message format. If an error occurs during the conversion process, the websocket connection failure is returned.
[0043] Permission module: Verify the token, and return the error message indicating that the current user has no permission to operate.
[0044] Parameter module: obtain parameter information. If the product application is ice, it is verified by the ice method. If the product application is mysql, it is verified by the mysql method.
[0045] Conversion module: converts arguments parameters, and returns conversion failure when an error occurs;
[0046] Create module: Create related resources and return result information.
[0047] The beneficial effects of the present invention are as follows: the present application discloses a method for separating the front-end and back-end of gotty, the method displays the terminal on a web browser; transmits the output of the terminal to the client, receives input from the client, and forwards it to the terminal; the separated gotty can add token verification as needed to improve access security; the transfer parameters can be added or deleted as needed to improve the scalability of use; when the user uses the system to perform terminal operations, he only needs to pay attention to the actual operation content, and for unsafe access, the "token verification failed" information is returned, and for parameters that do not meet the requirements, the "parameter transfer is incorrect, please check" information is returned, ensuring the convenience of user use and meeting the needs of users to use the system; at the same time, the reusability of the present invention is very high, the user only needs to ensure the Angular environment and the NG-ZORRO component library, and directly use the logic of the invention without performing additional operations, which improves reusability and ensures the accuracy of execution. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0049] Figure 1 is a flow chart of the method of the present invention; Figure 2 It is a structural schematic diagram of the system of the present invention; Figure 3 is a front-end processing flow chart of an embodiment of the present invention; Figure 4 It is a backend processing flow chart of an embodiment of the present invention. DETAILED DESCRIPTION
[0050] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.
[0051] Embodiment 1:
[0052] A method for separating the front and back ends of Gotty, wherein the specific steps of the method include:
[0053] S1 embeds the front-end part of the gotty application into the front-end of the Angular project;
[0054] S2 creates a new front-end page on the front end of the Angular project, adding token information transmission and custom parameters;
[0055] S3 adds token verification, product name judgment, and parameter checking to the backend of the Gotty application;
[0056] S4 returns corresponding information according to the verification and checking results;
[0057] When using the method of the present invention to separate the front-end and back-end of Gotty, first embed the front-end part of the Gotty application into the front-end of the Angular project according to S1:
[0058] Copy the js / src directory under the Gotty project into the webshell-ui component of the front-end project. The path is webshell-ui / js / src / **;
[0059] Then put the contents of js / src / main.ts into the ts file corresponding to the front-end page, that is, webshell-ui.component.ts;
[0060] Then, according to S2, create a new front-end page in the front-end of the Angular project, add the transmission of token information and custom parameters, and modify the front-end content:
[0061] Add xterm and hterm dependencies in package.json. The xterm version is 2.7.0.
[0062] Add the token parameter to the initialization parameters of WebTTY and obtain it from the cookie;
[0063] Customize the args parameter, modify the arg parameter according to product or project needs, and pass it as a parameter when initializing WebTTY;
[0064] Change the access address of ws to the backend deployment address;
[0065] Modify the content in webshell-ui.component.ts according to Angular coding rules, then start the application and test the connection;
[0066] Then, according to S3, the backend of the Gotty application is added with token verification, product name determination, and parameter inspection, and then according to S4, corresponding information is returned based on the verification and inspection results;
[0067] The method of the present invention separates the front-end and back-end of Gotty, integrates the front-end of Gotty into the Angular project, increases the liberalized style configuration of page display, increases the parameters of custom transmission, and increases the transmission and verification of tokens, thereby improving the application security of terminal access and realizing the control of page display at the same time; the method of the present invention separates the front-end and back-end of Gotty, increases the front-end and back-end verification, realizes the transmission of custom parameters, and controls the page display style. Compared with the method of directly using Gotty, the method improves the convenience and adaptability of data reading, reduces the difficulty of users to perform complex data operations, thereby improving the efficiency of users using the product and the convenience and comfort of using the product;
[0068] Furthermore, the S2 creates a new front-end page in the front-end of the Angular project, and the specific steps of adding the transmission of token information and customizing parameters include:
[0069] S201 creates a new HTML file and adds a div element named terminal;
[0070] S202 adds a sidebar, including a connection button and a new window open button;
[0071] S203 added help description;
[0072] Furthermore, the S3 adds token verification to the backend of the gotty application, and the specific steps of determining the product name and checking the parameters include:
[0073] S301 integrates iam and adds token verification through KeycloakClient.ValidateToken. For tokens that do not meet the verification requirements, the message "the current user has no operation permission" is returned;
[0074] S302 uses the processWSConn method to add checking and verification of the product name;
[0075] S303 writes the Dockerfile file, builds the backend image, and deploys it.
[0076] Furthermore, the specific steps of the processWSConn method in S302 include:
[0077] S3021 reads the connection information and returns websocket connection failure when an error occurs;
[0078] S3022 compares the message types and returns an illegal message type if they are inconsistent;
[0079] S3023 converts the connection information message format. If an error occurs during the conversion process, the websocket connection fails.
[0080] S3024 verifies the token. If an error occurs, it returns that the current user has no operation permission.
[0081] S3025 obtains parameter information, and if the product application is ice, verifies it through the ice method; if the product application is mysql, verifies it through the mysql method;
[0082] S3026 converts the arguments parameter, and returns the conversion parameter failure when an error occurs;
[0083] S3027 creates related resources and returns result information.
[0084] Embodiment 2:
[0085] A separation system of gotty front-end and back-end, the system specifically includes a front-end processing module, a front-end setting module, a back-end processing module and an information feedback module:
[0086] Front-end processing module: embed the front-end part of the gotty application into the front-end of the Angular project;
[0087] Front-end setting module: create a new front-end page on the front-end of the Angular project, add token information transmission and custom parameters;
[0088] Backend processing module: add token verification, product name judgment, and parameter checking to the backend of the Gotty application;
[0089] Information feedback module: returns corresponding information according to the verification and inspection results;
[0090] When using the system of the present invention to separate the front-end and back-end of Gotty, first use the front-end processing module to embed the front-end part of the Gotty application into the front-end of the Angular project:
[0091] Copy the js / src directory under the Gotty project into the webshell-ui component of the front-end project. The path is webshell-ui / js / src / **;
[0092] Then put the contents of js / src / main.ts into the ts file corresponding to the front-end page, that is, webshell-ui.component.ts;
[0093] Then use the front-end settings module to create a new front-end page in the Angular project front-end, add token information transmission and custom parameters, and modify the front-end content:
[0094] Add xterm and hterm dependencies in package.json. The xterm version is 2.7.0.
[0095] Add the token parameter to the initialization parameters of WebTTY and obtain it from the cookie;
[0096] Customize the args parameter, modify the arg parameter according to product or project needs, and pass it as a parameter when initializing WebTTY;
[0097] Change the access address of ws to the backend deployment address;
[0098] Modify the content in webshell-ui.component.ts according to Angular coding rules, then start the application and test the connection;
[0099] Then, the backend processing module adds token verification, product name judgment, and parameter inspection to the backend of the Gotty application, and then the information feedback module returns corresponding information based on the verification and inspection results;
[0100] The system of the present invention separates the front-end and back-end of Gotty, integrates the front-end of Gotty into the Angular project, increases the free style configuration of page display, increases the parameters of custom transmission, and increases the transmission and verification of tokens, thereby improving the application security of terminal access and realizing the control of page display at the same time; the system of the present invention separates the front-end and back-end of Gotty, increases the front-end and back-end verification, realizes the transmission of custom parameters, and controls the page display style. Compared with the method of directly using Gotty, the system of the present invention improves the convenience and adaptability of data reading, reduces the difficulty of users to perform complex data operations, thereby improving the efficiency of users in using the product and the convenience and comfort of using the product;
[0101] Furthermore, the front-end setting module specifically includes a file creation module, a button addition module and a description addition module:
[0102] File creation module: create a new HTML file and add a div element named terminal;
[0103] Button addition module: add sidebar, including connection button and new window opening button;
[0104] Description of additional modules: Add help description;
[0105] Furthermore, the backend processing module specifically includes a verification module, a name verification module and a mirroring module:
[0106] Verification and additional modules: integrate iam, add token verification through KeycloakClient.ValidateToken, and return the message "the current user has no operation permission" for tokens that do not meet the verification requirements;
[0107] Name verification module: Use the processWSConn method to add checks and verifications on product names;
[0108] Image addition module: write Dockerfile files, build backend images, and deploy them.
[0109] Furthermore, the name verification module specifically includes a reading module, a comparison module, a conversion module, a permission module, a parameter module, a conversion module and a creation module:
[0110] Read module: reads the connection information and returns websocket connection failure when an error occurs;
[0111] Comparison module: compares message types and returns an illegal message type if they are inconsistent;
[0112] Conversion module: converts the connection information message format. If an error occurs during the conversion process, the websocket connection failure is returned.
[0113] Permission module: Verify the token, and return the error message indicating that the current user has no permission to operate.
[0114] Parameter module: obtain parameter information. If the product application is ice, it is verified by the ice method. If the product application is mysql, it is verified by the mysql method.
[0115] Conversion module: converts arguments parameters, and returns conversion failure when an error occurs;
[0116] Create module: Create related resources and return result information.
[0117] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for separating the front and back ends of Gotty, characterized in that The specific steps of the method include: S1 embeds the front-end part of the gotty application into the front-end of the Angular project: Copy the js / src directory under the Gotty project into the webshell-ui component of the front-end project. The path is webshell-ui / js / src / **; Then put the contents of js / src / main.ts into the ts file corresponding to the front-end page, that is, webshell-ui.component.ts; S2 creates a new front-end page on the front end of the Angular project, adds the transmission of token information and custom parameters, and modifies the front-end content: Add xterm and hterm dependencies in package.json. The xterm version is 2.7.
0. Add the token parameter to the initialization parameters of WebTTY and obtain it from the cookie; Customize the args parameter, modify the arg parameter according to product or project needs, and pass it as a parameter when initializing WebTTY; Change the access address of ws to the backend deployment address; Modify the content in webshell-ui.component.ts according to Angular coding rules, then start the application and test the connection; S3 adds token verification, product name judgment, and parameter checking to the backend of the Gotty application; S4 returns corresponding information according to the verification and checking results.
2. The method according to claim 1, characterized in that The specific steps of S2 creating a new front-end page on the front-end of the Angular project and adding the transmission of token information and custom parameters include: S201 creates a new HTML file and adds a div element named terminal; S202 adds a sidebar, including a connection button and a new window open button; S203 adds help description.
3. The method according to claim 2, characterized in that The specific steps of adding token verification to the backend of the Gotty application, determining the product name, and checking the parameters include: S301 integrates iam and adds token verification through KeycloakClient.ValidateToken. For tokens that do not meet the verification requirements, the message "the current user has no operation permission" is returned; S302 uses the processWSConn method to add checking and verification of the product name; S303 writes the Dockerfile file, builds the backend image, and deploys it.
4. The method according to claim 3, characterized in that The specific steps of the processWSConn method in S302 include: S3021 reads the connection information and returns websocket connection failure when an error occurs; S3022 compares the message types and returns an illegal message type if they are inconsistent; S3023 converts the connection information message format. If an error occurs during the conversion process, the websocket connection fails. S3024 verifies the token. If an error occurs, it returns that the current user has no operation permission. S3025 obtains parameter information, and if the product application is ice, verifies it through the ice method; if the product application is mysql, verifies it through the mysql method; S3026 converts the arguments parameter, and returns the conversion parameter failure when an error occurs; S3027 creates related resources and returns result information.
5. A separation system for the front and rear ends of gotty using the method of claim 1, characterized in that The system specifically includes a front-end processing module, a front-end setting module, a back-end processing module and an information feedback module: Front-end processing module: embed the front-end part of the gotty application into the front-end of the Angular project; Front-end setting module: create a new front-end page on the front-end of the Angular project, add token information transmission and custom parameters; Backend processing module: add token verification, product name judgment, and parameter checking to the backend of the Gotty application; Information feedback module: returns corresponding information based on the verification and inspection results.
6. The system according to claim 5, characterized in that The front-end setting module specifically includes a file creation module, a button addition module and a description addition module: File creation module: create a new HTML file and add a div element named terminal; Button addition module: add sidebar, including connection button and new window opening button; Description of additional modules: Add help description.
7. The system according to claim 6, characterized in that The backend processing module specifically includes a verification module, a name verification module and a mirroring module: Verification and additional modules: integrate iam, add token verification through KeycloakClient.ValidateToken, and return the message "the current user has no operation permission" for tokens that do not meet the verification requirements; Name verification module: Use the processWSConn method to add checks and verifications on product names; Image addition module: write Dockerfile files, build backend images, and deploy them.
8. The system according to claim 7, characterized in that The name verification module specifically includes a reading module, a comparison module, a conversion module, a permission module, a parameter module, a conversion module and a creation module: Read module: reads the connection information and returns websocket connection failure when an error occurs; Comparison module: compares message types and returns an illegal message type if they are inconsistent; Conversion module: converts the connection information message format. If an error occurs during the conversion process, the websocket connection failure is returned. Permission module: Verify the token, and return the error message indicating that the current user has no permission to operate. Parameter module: obtain parameter information. If the product application is ice, it is verified by the ice method. If the product application is mysql, it is verified by the mysql method. Conversion module: converts arguments parameters, and returns conversion failure when an error occurs; Create module: Create related resources and return result information.
