How to hide the server host but show the base path in Redoc? - openapi

Currently Redoc includes the host URL in my API endpoint which I do not want it to do.
I tried several ways to hide it and only show the base path and endpoint in Redoc docs, but nothing seems to work.
Current behaviour - http://localhost:8000/v1/abc
Expected behaviour - /v1/abc
I do not want Redoc to add the host.
I tried passing an empty url in the servers attribute in my OpenAPI file, hide-hostname in Redoc options and other various ways like only passing a "/" in the url, but it always adds the security scheme or browser URL if nothing is provided.

Related

Github pages and custom domain from 123Reg

I've got a custom domain from 123Reg - www.mydomainname.co.uk - which I want to use for my github page - mygithub.github.io
I've managed to set it up so that www.mydomainname.co.uk works, but it isn't using https and therefore shows as unsecure, how can I make it use https?
Also, is there a way of allowing mydomainname.co.uk to work as well?
First you should make sure HTTPS is working on https://www.mydomainname.co.uk (by default it should). You can Enforce HTTPS under your repository settings, so it would do the redirection from http to https.
To get your apex domain mydomainname.co.uk working, it's best if you do a redirection to www.mydomainname.co.uk from where you manage your DNS (some don't have the feature).

How to fix "load unsafe scripts"?

so I'll start from the very beginning.
Basicly I purchased a template off themeforest and I manually edited the code in a markup editor to match my preferences.
As I was finished, I decided to host my website on github pages - I uploaded my code directory to a repository as you do.
Here's a link to my repository:
https://github.com/KristofferHari/kristofferhari.github.io
Here's a link to my current website URL:
https://kristofferhari.github.io/ (As you can see, everything's kinda buggy)
So I managed to contact the seller and this is what I was provided with:
The reason for that is because the resources are using a http connection and they can’t be loaded on https connection website. So
you have to upload all the resources (scripts/stylesheets) to github
in order to use them on github.
So I suppose that through my browser, I am trying to connect to my website through a https connection rather than an http. (Is this what is actually causing the problem, and what's the difference between a http connection and a https?)
Secondly, how would I upload all my resources (scripts/stylesheets) to github?
Thanks in advance!
There is a relatively simple solution: to use a protocol-relative URL format.
e.g. your error
Mixed Content: The page at 'https://kristofferhari.github.io/' was loaded over HTTPS, but requested an insecure stylesheet 'http://fonts.googleapis.com/css?family=Open+Sans:400,700,300,900'. This request has been blocked; the content must be served over HTTPS.
The problem is you are loading
http://fonts.googleapis.com/css?family=Open+Sans:400,700,300,900'
from
https://kristofferhari.github.io/
The page is secure (HTTPS), but it's loading insecure content (HTTP).
To fix it, you basically need to change the stylesheet to:
https://fonts.googleapis.com/css?family=Open+Sans:400,700,300,900'
But a more flexible solution is to use a protocol relative format:
//fonts.googleapis.com/css?family=Open+Sans:400,700,300,900'
which will then work on either http or https.
Apply this change to all included resources.

Google Authorized redirect URIs

Let's say my app's main domain is at https://www.example.com
App is going to have lots of instances, i.e.
https://www.example.com/client1
https://www.example.com/client2
https://www.example.com/client3
<..>
In order to have OAuth2 authentication against my app, I currently have redirect URIs as such:
https://www.example.com/client1/SignInGoogle
https://www.example.com/client2/SignInGoogle
Is there a way to add one Authorized redirect URI for all of these clients? i.e.
https://www.example.com/*
or
https://www.example/com/*/SignInGoogle
Or does this URI has to be the exact match?
If you look at the Google Developer console
Must have a protocol (HTTP / HTTPS)
Cannot contain a URL Fragment (#)
Cannot contain a relative path.
Cannot be a public IP address.
Examples of Relitve vs Absolute URIs
Relative URI Absolute URI
about.html http://WebReference.com/html/about.html
tutorial1/ http://WebReference.com/html/tutorial1/
tutorial1/2.html http://WebReference.com/html/tutorial1/2.html
/ http://WebReference.com/
//www.internet.com/ http://www.internet.com/
/experts/ http://WebReference.com/experts/
../ http://WebReference.com/
../experts/ http://WebReference.com/experts/
./about.html http://WebReference.com/html/about.html
What you want to do is something like a Relative URI. What you need to remember is that an Authentication server is nothing but a web service. If you cant access the redirect URI from a normal web browser the authentication server cant either.
So no you cant do that it has to match exactly.

Swagger Multiple hosts in same Json spec

I am using a single host for documenting REST API's in Swagger Ui 2.0 but I need two hosts in the JSON file for calling rest API's one for http and the other one for https. Is it possible? If yes then how to do that?
Thanks!
The way swagger figures out URLs is this:
You provide the basic one in index.html from where the swagger.json gets generated. The generated swagger.json does not contain a URL per se, or any http/https information. It only has a path relative to the base URL you provided.
After the UI gets generated based on generated swagger.json, the "Try it out" buttons execute GET/POST/PUT requests based on the URL info in the address bar. check this piece of code in your swagger-ui.js:
if (url && url.indexOf('http') !== 0) {
url = this.buildUrl(window.location.href.toString(), url);
}
So, if you want to use https, use https in the address bar to hit Swagger UI. You will also need to mention the same in your index.html, and in swagger-ui.js in the above code.

exposing a sparql endPoint publicly?

I have a website power by a tomcat server. My application tap on a tripleStore that i would like to make public trough a sparql endpoint at www.mywebsiteaddress/sparql.
What configuration do i need on my webserver to do that ?
I use Jena Fuseki on the background which is running on the Port 3030 and my webserver is on the port 80.
My idea is that, when the webserver get a request on the port 80 about ..../sparql it redirect to fuseki sprql endPoint
This is more of a webservice / access control problem than anything SPARQL related. However, since SPARQL endpoints are supposed to be created as per the SPARQL spec, i think this a valid question, as I'm sure people will encounter it again in the future.
So, to answer your question, "public" usually means that certain headers are set in order to allow a request to hit the endpoint when it is not coming from the same domain. From there, you can specifically allow certain types of interactions with the endpoint. If you wanted to kinda just allow everything, you could set the following headers:
'Access-Control-Allow-Origin: *'
"Access-Control-Allow-Credentials: true"
'Access-Control-Allow-Headers: X-Requested-With'
'Access-Control-Allow-Headers: Content-Type'
'Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE //http://stackoverflow.com/a/7605119/578667
'Access-Control-Max-Age: 86400'
Depending on how you built the endpoint, it'll either have some settings somewhere where you can adjust the headers, or, you'll have find the headers settings for the application framework itself if you're using one. But, in general, the above headers would make it "public"