I have a jetty project (running through the gradle jetty plugin but I don't think that's important here). I have configured the resource base to point to some directory X. That directory has a bunch of subdirectories, A, B and C. When I go to the root page http://mywebserver/X, it shows directories A,B and C as expected.
Is there a way to filter out certain directories, so it shows only A and B for example (and C is inaccessible). I know I could setup different web contexts for each one, but I'd prefer to be able to add the top level directory and then filter out the directories I do or do not want.
In your web.xml file for your webapp, you can set a security constraint. For each directory you want to restrict, you can set the URL pattern and the types of http method you want to restrict from being performed.
Since the XML can get fairly complicated and you have a specific use case, this is a good article that explains how to set up the security constraint in your web.xml file. Keep in mind that any http methods that you do not explicitly list in your security constraint are automatically allowed. I hope this answer has helped!
Related
I have set up an S3 bucket to host static files.
When using the website endpoint (http://.s3-website-us-east-1.amazonaws.com/): it forces me to set an index file. When the file isn't found, it throws an error instead of listing directory contents.
When using the s3 endpoint (.s3.amazonaws.com): I get an XML listing of the files, but I need an HTML listing that users can click the link to the file.
I have tried setting the permissions of all files and the bucket itself to "List" for "Everyone" in the AWS Console, but still no luck.
I have also tried some of the javascript alternatives, but they either don't work under the website url (that redirects to the index file) or just don't work at all. As a last resort, a collapsible javascript listing would be better than nothing, but I haven't found a good one.
Is this possible? If so, do I need to change permissions, ACL or something else?
I've created a simple bit of JS that creates a directory index in HTML style that you are looking for: https://github.com/rgrp/s3-bucket-listing
The README has specific instructions for handling Amazon S3 "website" buckets: https://github.com/rgrp/s3-bucket-listing#website-buckets
You can see a live example of the script in action on this s3 bucket (in website mode): http://data.openspending.org/
There is also this solution: https://github.com/caussourd/aws-s3-bucket-listing
Similar to https://github.com/rgrp/s3-bucket-listing but I couldn't make it work with Internet Explorer. So https://github.com/caussourd/aws-s3-bucket-listing works with IE and also add the possibility to order the files by names, size and date. On the downside, it doesn't follow folders: only the files at one level are displayed.
This might solve your problem. Security settings for Everyone group:
(you need the bucketexplorer.com software for this)
If you are sharing files of HTTP, you may or may not want people to be able to list the contents of a bucket (folder.) If you want the bucket contents to be listed when someone enters the bucket name (http://s3.amazonaws.com/bucket_name/), then edit the Access Control List and give the Everyone group the access level of Read (and do likewise with the contents of the bucket.) If you don’t want the bucket contents list-able but do want to share the file within it, disable Read access for the Everyone group for the bucket itself, and then enable Read access for the individual files within the bucket.
I created a much simpler solution. Just place the index.html file in root of your folder and it will do the job. No configuration required. https://github.com/prabhatsharma/s3-directorylisting
I had a similar problem and created a JavaScript-and-iframe solution that works pretty well for listing directories in S3 website files. You just have to drop a couple of .html files into the directory you want to list. You can find it here:
https://github.com/adam-p/s3-file-list-page
I found s3browser, which allowed me to set up a directory on the main web site that allowed browsing of the s3 bucket. It worked very well and was very easy to set up.
Using another approach base in pure JavaScript and AWS SDK JavaScript API. Not need PHP or other engine just pure web site (Apache or even IIS).
https://github.com/juvs/s3-bucket-browser
Not intent for deploy on your own bucket (for me, no make sense).
Using the new IAM Users from AWS you can provide more specific and secure access to your buckets. No need to publish your bucket to website and make all public.
If you want secure the access, you can use the conventional methods to authenticate users for your current web site.
Hope this help too!
It is well known that nextjs API routes provide a straightforward solution to build your API with Next.js. and that any file inside the folder pages/api is mapped to /api/* and will be treated as an API endpoint instead of a page.
I have just one doubt: is the code within the pages/api exposed to the world? I mean, can I build some logic there that has some key that must be hidden or maybe some MySQL connection?
Whether or not /api is in any way exposed to the world I do not know for sure, but according to Next documentation, "they are server-side only bundles."
In general though, for any key/sql connection that you want to run, I would put that into an .env.local file on your machine, a file that gets git ignored and never uploaded, and if you are hosting on Vercel, then use their environmental variables to store sensitive information.
You'd find environmental variables under:
{Your Account}/{Project}/Settings/Environmental Variables
p.s. Also from Next.js docs, I think you'd find this bit on getStaticProps useful.
I have an XML file and 3 xsl files that tranform the same xml. I want to create a home page, with three buttons. Each button will redirect to one of three tranformations. How can I create a link to the xml file with a spesific transformation.
Let's say I have : example.xml and t1.xsl, t2.xsl, t3.xsl and index.html with buttons t1, t2, t3. When I press the t1 button I want to get the XML file transformed by t1.xsl.
From your description ("home page, ...") I infer that all this should happen on the Web; in that case the answer will most likely involve the rules for configuring your Web server, so it's going to be a question about Apache, or IIS, or nginx, or Jetty, or whatever server is actually serving your documents.
There are many ways to achieve the goal; these are the first three or four that occur to me. For concreteness I will assume you are using Apache (many people do), know how to find and edit Apache configuration files, and can adapt relative references to suit your directory layout.
Assuming that what you want is precisely what #Stefan Hegny assumes you do not want.
You save three copies of the XML document. The one named example.1.xml begins
<?xml-stylesheet href="t1.xsl" type="text/xsl"?>
<example>
...
The one named example.2.xml begins
<?xml-stylesheet href="t2.xsl" type="text/xsl"?>
<example>
...
And similarly example.3.xml begins with a reference to t3.xsl.
The three buttons point to these three documents.
If example.xml is still changing, you will want to automate the process of updating the three near-identical copies of it whenever the master document changes; I use Make and sed for such tasks, myself.
Another way to achieve the same thing, with a single copy of example.xml
Another way to achieve the same effect is to maintain a single copy of example.xml, with a reference to t1.xsl (so it looks like the example.1.xml described above), and tell your server
Whenever a user requests the URI example.1.xml, serve document example.xml.
Whenever a user requests the URI example.2.xml, run the command sed -e s/t1.xsl/t2.xsl/ < example.xml and send the result (stdout) to the client.
Whenever a user requests the URI example.3.xml, run the command sed -e s/t1.xsl/t3.xsl/ < example.xml and send the result (stdout) to the client.
In Apache, I use the Rewrite module to redirect these three URIs to a CGI script which inspects the URI by which it was called and runs the appropriate command.
The three buttons continue to point to the three URIs example.1.xml, example.2.xml, and example.3.xml.
Running the stylesheet on the server
If the three displays must work even with browsers that don't support XSLT, then you want to run the stylesheet on the server.
Here, again, I use Rewrite to redirect the URIs to a CGI script, but instead of running sed, the CGI script runs xsltproc, or whatever XSLT processor is available on my server.
Running the stylesheet in the browser
Another way to handle this requirement is to make index.xhtml be an XForms document, suited for a processor which supports the transform() extension function (e.g. XSLTForms). The document example.xml is referred to by an xf:instance element, and the three buttons invoke the three stylesheets on that instance. They might update an auxiliary instance, or they might simply cause different cases in an xf:switch to display. (If this mostly makes sense to you but you need more details, ask a question tagged XForms; if it doesn't make sense to you, then you probably don't know XForms and this is not the simplest path to the goal you describe.)
Some people would use Javascript instead of XForms for this task, but browsers vary a lot in how they want their internal XSLT processor to be invoked, so unless you enjoy working around browser inconsistencies in Javascript, you might not want to go that way, either.
I have a site:
example.com/index.html
There is a subfolder (subsite):
example.com/subsite/different_index.html
different_index.html contains a form:
<FORM action="different_index.html?action=edit">
However, when the submit input button on this form is clicked, the page attempts to redirect to:
example.com/subsite/subsite/different_index.html
I've tried making the form action the exact url needed:
<FORM action="example.com/subsite/different_index.html?action=edit"> <!-- target self -->
But I still get:
example.com/subsite/subsite/different_index.html
subsite is duplicated within the URL.
Any ideas how to correctly target this form?
The fact that you have a form is actually irrelevant. What you are really asking is about referencing resources and the rules are pretty simple:
If the resource you need is part of the same web site (not talking about folder structure here, talking about domain), you should use relative paths, where:
a. fileName.ext is all you need if the resource is in the same folder as the currently loaded document.
b. folderName/fileName.ext is what you need if the file you need is in a sub-folder of the current folder that the loaded document is in.
c. ../fileName.ext is what to use if the file you need is one directory higher than the current document's folder. The ../ can be repeated if you need to go up more than one level (i.e. ../../fileName.ext).
d. /fileNameext or /folderName/fileName.ext indicates that the file or folder specified should be found starting from the root of the web site, regardless of where the current document is.
If the resource you need is located on another domain, you'd use an Absolute Path (http://something.something/file.ext).
a. DO NOT use absolute paths for local resources! This may work but causes the domain name to have to be resolved again, resulting in a longer load time.
WARNING: Different servers have different configurations and requirements that may affect whether these reference rules work or not. For example, GoDaddy web hosting provides an "httpDocs" folder at the root of a web site. You don't have to use it, but that's where their servers expect the site's content to be placed. Not following those rules result in relative paths not working. Additionally, many servers are hosted on operating systems the have case-sensitive file systems, so always refer to files and folders in the same case that is actually used. Again, not doing this may work for you locally, while you develop (because you haven't moved the files to the remote server yet), but don't let that lull you into thinking that case doesn't matter.
via its tree view Gitweb is a great tool to browse through repository content at filesystem level. In case there are files inside the repository it's then easily possible to simply view/open them with your browser - just click them. Problem is if these are "html" files referencing other resources (pictures, javascript, etc.) a browser can't find them because although they are available in the repository, and also accessible via Gitweb's "tree" view - they aren't served at there expected location by the (Git)web server.
Stupid question: Is it any possible to configure Gitweb to do some sort of magic URL rewriting or whatever else to be able to fully view an html file with all its references in case the html file itself and all referenced content is present?
I actually don't think so.
Current work-around: At the moment I just clone/check-out the git repository into a directory served by a web server. Works, but whenever anyone wants to view an older commit-level I have to checkout another commit-id. The flexibility of just browsing through files AND commit levels is gone. Plus whoever wants to use this work-around must be able to use git. Also people must know another URL to actually see the content from the repository.
Question: Does anyone see a more flexible work-around?