Configuring Spring Data Rest HAL Browser - spring-boot

I have just implemented the HAL Browser bundled with spring-data-rest. It is accessible from my API root and is working fine. But I have found no way to customize anything about it. Is it possible to change the browser look and feel mainly for production use? Also is it possible to put it on a different url? Is it recommended for production in the first place? I am using Spring Boot 2.0.

I would not recommend having HAL browser enabled in production. Why would you need it? It is a tool to easily traverse a HATEOAS API within a browser. You can use it in dev/test environment. Production APIs can be referred with Postman, Insomnia like tools.
Having said that, it is possible to modify the look of HAL browser. All HAL browser related web files are located in META-INF/spring-data-rest/hal-browser. To modify any of these files, you can override them by creating the same folder structure inside src/main/resources directory, copy the files that you want to modify and update it.

Related

Firefox Extension - Database access

I want to make a Firefox extension that can store and retrieve data from a database. However I've only been finding solutions that would work locally for each user. I'd like every user to have access to the same database.
Is that possible?
It is possible to access remote SQL databases like MySQL and PostgreSQL with node.js modules, but it is more sensible to create REST API front ends to your databases and call them from the extension. Exposing the SQL calls directly in your web extension is not a good idea. It is basically bad security practice and will expose your database to hackers.
You will also need your addon to pass Mozilla's approval process if you are going to distribute publicly and I doubt the reviewers will be pleased to see raw SQL calls in your extension's code.
The more sensible way is to update the database is through a REST API front end.
A simple example on how to create a REST API for a Postgres database can be found at Node.js, Express.js, and PostgreSQL: CRUD REST API example - LogRocket Blog and this playlist show how to create a REST interface in a Firefox extension - Build a Firefox Extension from Scratch that integrates with Node.js - DEV Community
The above database example is quite simple. For real world use you will need a more advanced REST framework for your API which sanitizes the data before inserting it into the databasse. You have more reading to do here.
However if you need to make SQL calls directly from your extension which I still don't advise, you can include some packages from node.js in your web extension, and use browserify which extracts and packages the modules needed into your extension. Your addons though had better be for private or in-house use, not for public distribution.
Some nodejs modules for database access are - https://github.com/mysqljs/mysql, https://node-postgres.com/ and https://www.npmjs.com/package/pg.
Just a little advice. Feel free to ignore it if you have nothing to do with it. Your question sounds quiet generic. You should learn and doing it by yourself first and only ask here when there are specific issues you're stuck with.
By "locally", I think you mean via Web SQL or IndexedDB. They're called local database and their behaviors are totally different from what you're looking for.
I should haven't need to tell you to do this. Just in case. Of course first thing first you need to know how website is working for both front end and back end, not just local stuff, especially how they're communicating between each other. So you should know about HTTP request, Javascript, and AJAX.
What has it to do with Firefox extension?. Not just Firefox, browser extension is just another type of web page that overlaying the opened web page in all kind of browser. In Firefox the opened page is called activeTabs. The only difference from regular web page is you need to signup your account first, manifest.json file as your project root file, and it compile from command line with web-ext tools. In case if you're facing Cross-origin resource sharing (CORS) restriction, follow instructions HERE and allow the URL on server side.

Where is my exposed root of my webpage in the directory structure of Azure console?

I created a new .NET based web application named shabang using the web client and it displays the default woohoo-page when I browse to shabang.azurewebsites.net. Then, I discovered that there's a console in the web client and when I use it, I can see a directory structure including my login name, home directory etc. However, I can't find the files being served and, since I can see a web page being rendered when browsing, I'm certain they are there, somewhere.
Where is the (or equivalent of) wwwroot?
I've googled it but it's a bit hard to word what I'm asking in a way that Google will understand. Just a bunch of guides that are way too advanced to distill the information from.
By default, it is d:\home\site\wwwroot. It can also be modified using the Azure Portal.
Note that you should use the Kudu Console to see it. e.g. https://shabang.scm.azurewebsites.net

How to launch and serve subpage from my webapplication?

I am using Spring to create a web application in which a user can upload a zipped folder containing an index.html file along with all it's resources(pretty much like an Adobe captivate generated webpage). The user should be able to request the uploaded web pages in the form of inner web pages.
I can only go as far as unzipping the folder itself, but I have no idea how to launch the index.html present inside the zipped folder.
How do I achieve this?
Quite honestly Spring has no restrictions or advantages over
displaying your subpages inside another page. However you can use Spring MVC to dynamically serve the web pages from the uploaded folder.
More over you have to play the tricks from browser side. Going with iFrame seems to be the best option from client side, though there are many other options. Please check this thread.
You can write some smart APIs in SpringController which accepts the folder path or folder name as parameter, picks the necessary pages from the requested folder and serves the user.
Another approach could be to use a headless browser for the server side rendering and give the output as screenshots to client. This can render the pages server side. Please check this thread for more details.
I hope this helps you!

Domino Xpages with Reverse Proxy

I have a problem with Domino Web Server with an XPages Application which is placed behind some reverse proxy. The problem is, the proxy forwards all requests from the URL like h2tps://organization/test_server/ to the Domino Web Server.
This makes all links in the application brocken. And I don't know how to fix it.
For example, the login attempt will be redirected by the server to h2tps://organization/names.nsf?Login instead of h2tps://organization/test_server/names.nsf?Login
Have you any idea how to fix it?
When using a reverse proxy, we recommend keeping the original URL unchanged. Because many redirects, Ajax requests, cookie are closely related to URL, if the URL changes, almost must go to modify the code.
This problem is especially serious in Domino, because in a lot of Javascript code that will be used in the absolute path, for example /names.nsf. As a comparison of Java applications in general will use relative paths (for example ../login).
The actual way to achieve URL unchanged: map the domain name of the original domino server (for example test.domino.xxx), to the reverse proxy server, and reverse proxy server via http HOST header to determine forwarded to which backend server, without the need to add additional path (for example test_server).
In IBM WebSeal example, this configuration is called virtual host junctions.
Did you create a site document on the domino Server?
I have solved the problem with some efforts.
At first I have moved the DB in the folder /test_server/.
Then I have changed all static HTML links to use the /test_server/.
With the option xsp.application.context.proxy=test_server I have changed the
paths for internal XPages and Extensions Library resources.
At the end I have to add some substitution rules on the Domino
to prevent duplicated paths like /test_server/test_server/.
Now it seems to be working well.
The proposal from the proxy team was to use url rewrite on the Web Server. It can be done with Domino without doubt, but requires to develop a DNSAPI Addon (a dll written in C). And it doesn't look for me like an easy task.
Anyway, thanks a lot for your help!

Storage Options with Mozilla Addon-SDK

I am a newbie to Addon-SDK. I am making an Addon in which I log some information meant for manually viewing later on. I came across the
Simple-Storage API but as far as I could figure out, it saves the information internally in some format which can only be accessed via function calls i.e. "ss.storage.variable_name".
I was wondering if this information is accessible somehow from windows directory structure i.e. maybe from some file in the profile directory.
And secondly, is there any way to access the SQlite Database, or any third
party API?
(I don't know why but the cfx test for this API gives me errors, so not able
to use this).
You can try with localStorage of HTML5 via Javascript: http://www.w3schools.com/html/html5_webstorage.asp
And then with Store: https://developer.mozilla.org/es/docs/Storage

Resources