Since I have upgraded to the new ServiceStack 4.0.48 from a very old version, it automatically redirects me to the /metadata page. How do I disable that?
I have added the ServiceStack Application to host off an existing application, now I can't use my existing application because it keeps redirecting to /metadata.
I had a look online but can't really find anything, It never used to automatically redirect.
I need to go to example.com but it keeps redirecting me to example.com/metadata
In order to display a homepage, it needs a default index page, e.g. default.cshtml or default.html. If there isn't a home page ServiceStack automatically redirects to the /metadata page so it has something to show. If you have a default document that isn't getting displayed, it maybe due to an Exception on StartUp resulting in incomplete configuration - you can check for Start up errors with the ?debug=requestinfo Debug Route.
Otherwise to redirect to a different route for the home page you can use:
SetConfig(new HostConfig {
DefaultRedirectPath = "/alt-path"
});
Whilst the Metadata redirects can be changed with:
SetConfig(new HostConfig {
MetadataRedirectPath = "/alt-path"
});
Related
I have a baffling issue with cookie handling in a Blazor server app (.NET Core 6) using openid (Keycloak). Actually, more than a couple which are may or may not linked. It’s a typical (?) reverse proxy architecture:
A central nginx receives queries for services like Jenkins, JypyterHub, SonarQube, Discourse etc. These are mapped through aliases in internal IPs where the nginx can access them. This nginx intercepts URL like: https://hub.domain.eu
A reverse proxy which resolves to https://dsc.domain.eu. This forwards request to a Blazor app running in Kestrel in port 5001. Both Kestrel and nginx under SSL – required to get the websockets working.
Some required background: the Blazor app is essentially a ‘hub’ where its various razor pages ‘host’ in iframe-like the above mentioned services. How it works: When the user asks for the root path (https://hub.domain.eu) it opens the root page of the Blazor app (/).
The nav menu contains the links to razor pages which contain the iframes for the abovementioned services. For example:
The relative path is intercepted by the ‘central’ nginx which loads Jenkins. Everything is under the same Keycloak OpenID server. Note that everything works fine without the Blazor app.
Scenarios that cause the same problem
Assume the user logins in my app using the login page of Keycloak (NOT the REST API) through redirection. Then proceeds to link and he is indeed logged in as well. The controls in the App change accordingly to indicate that the user is indeed authenticated. If you close the tab and open a new one, the Blazor app will act as if it’s not logged in while the other services (e.g Jenkins) will show the logged in user from before. When you press the Login link, you’ll be greeted with a 502 nginx error. If you clean the cookies from browser (or in private / stealth mode) everything works again. Or of you just log off e.g. from Jenkins.
Assume that the user is now in a service such as Jenkins, SonarQube, etc. if you press F5 now you have two problems: you get a 404 Error but only on SOME services such as Sonarcube but not in others. This is a side problem for another post. The thing is that Blazor app appears not logged in again by pressing Back / Refresh
The critical part of Program.cs looks like the following:
This class handles the login / logoff:
Side notes:
SaveTokens = false still causes large header errors and results in empty token (shown in the above code with the Warning: Token received was null). I’m still able to obtain user details though from httpContext.
No errors show up in the reverse proxy error.log and in Kestrel (all deployed in Linux)
MOST important: if I copy-paste the failed login link (the one that produced the 502 error) to a "clean" browser, it works fine.
There are lots of properties affecting the OpenID connect, it could also be an nginx issue but I’ve run out of ideas the last five days. The nginx config has been accommodated for large headers and websockets.
Any clues as to where I should at least focus my research to track the error??
The 502 error shows an error at NGINX's side. The reverse proxy had proper configuration but as it turned out, not the front one. Once we set the header size to suggested size, everything played out.
We can use ShellExecute to launch default Web browser and go to specified web page with http: URI scheme. But how can we launch default Web browser and go to Home page using ShellExecute?
I can get some information from here: https://support.microsoft.com/en-us/kb/224816 and https://msdn.microsoft.com/en-us/library/windows/apps/mt228340.aspx#browser but I still don't know how to go Home page. Very appreciate if you can provide some information
What is the default browser on Windows? Is it the registered handler of the HTTP protocol? Is it the default client registered under Clients\StartMenuInternet?
If we assume that the HTTP handler is the default browser then you can use AssocQueryString to get information about the registration:
WCHAR szBrowser[MAX_PATH];
DWORD cch = MAX_PATH;
AssocQueryString(ASSOCF_NOTRUNCATE, ASSOCSTR_EXECUTABLE, L"http", NULL, szBrowser, &cch);
As a side note, just getting the executable might not be the best option, the user could have configured it with parameters like --some-browser-option --profile c:\foo and those would be ignored. ASSOCSTR_COMMAND can retrieve the command but you need to replace %1 with a empty string.
Even if you do all of this it can still break in certain configurations. A protocol registration is not required to specify a executable, it is legal to just have a COM object. I would therefore recommend that you read the StartMenuInternet client as a fallback.
I don't think there is a standard parameter to open the homepage (unlike ? for search), you just have to hope that starting the browser without a URL will open the homepage(s).
An ember cli site was deployed onto a server and it works fine. Links via {{link-to}} all work beautifully.
BUT, when a user (me that is) manually enters a url and hits return. then the site is not found.
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
even changing a parameter of a working url (initially navigated to thru link-to)
http://site/start/0/length/30
and simply backspacing, changing the 30 to 20 and hit return
http://site/start/0/length/20
its a no go
localhost:4200 doesn't have this issue.
has anyone observed this vicious behaviour.
i actually need it for a callback redirect for oauth. but then noticed than any manually entered urls dont function.
It is because your server (IIS?) is trying to access the full path requested by your browser (eg /start/0/length/30), and not finding a valid file on disk returns a 404.
So, you need to configure your web server to proxy/rewrite the requests to the proper location. Assuming you are deploying your application in your "root" directory, the proper location is /index.html (the file ember-cli creates).
Unfortunately, I can't help you with IIS, but I can provide you with the proper configuration for nginx:
location / {
try_files $uri $uri/ /index.html;
}
This says "If the requested URI doesn't exist, instead respond with the /index.html file".
When you are using ember server on localhost:4200 you don't have the same problem because it is automatically doing something similar transparently.
If you are serving this up from any web server that isn't the built in Ember, ie non local server, you need to have a wildcard rule that returns your Ember app's index.html file for anything below your websites base url. If you only have your base url return the index.html file, then your webserver is confused by the unrecognized url and thinks it has nothing to return. If your rule, though,
for baseUrl/* returns index.html, your Ember app will then run the correct route hooks to establish the app context
this is a dupe and the question is
How to run emberJS application in IIS?
the easy answer is set locationType: hash in ember-cli's environment.config file (copied from accepted answer)
that will introduce a '#' in the url but doesnt require an IIS change.
var ENV = {
...
locationType: 'hash'
... };
I'm trying to make integration of etherpad-lite in the CMS Plone, following Example 1 of the official documentation http://etherpad.org/doc/v1.2.7/
Portal places the cookie "sessionID" with the given value on the client and creates an iframe including the pad.
Everythings goes well except for the cookie. Reading documentation the best pratice seems to make etherpad-lite in the same domain under a specific path. This is what I have done using /pad/ path.
Plone side if no session has been created, I created on, I add a cookie and then I'm doing a redirect to the same page to be sure the cookie is in the browser.
As a results my cookie is added to the request of the main page but not ob the iframe request.
Here is the google chrome console network tab for the main page and the iframe:
http://toutpt.makina-corpus.org/en/images/cookie-in-iframe/
The code corresponding to the setCookie is at https://github.com/toutpt/collective.etherpad/blob/master/collective/etherpad/archetypes.py#L100
For posterity, here's the answer from #AskoSoukka identified and "accepted" in the comments above:
How does the actual cookie stored in you browser look like? Probably, you need to explicitly specify path="/" in setCookie kwargs to make it work for the whole domain.
I am trying to set a loginPage value on a Sitecore site in the web.config. The file referenced in the loginPage is an Sitecore item, so it is not a psycical page on the server. No matter how i reference to it, it doesnot work. I get one of 2 errors (depending on how i refrecen to the file);
The resource cannot be found.
Error executing child request for /sitecore/login. (The path beeing the one i referenced in the web.config)
Any ideas?
The explanatory comment in web.config says that 'loginPage' attribute should be The path to the login page to use. Must point to a physical file or a page in a site that does NOT require login. 'Require login' means denied Read permissions for the Anonymous user. This Anonymous user is the one in the domain specified for this site.
For instance, if you want to have login page set for the 'website' site, you should make sure that extranet\Anonymous has read permission to the item you specified.
Hope this helps.
The loginPage attribute is actually a URL, not an item path. Include the full path with extension -- e.g. /MyAccount/Login.aspx
Try hitting the url in the browser to your login page. If you cannot reach the page itself or if it throws an error in the browser then accessing it in the web.config will not work.
Once you have the login page coming up in the url in the browser using the path yoursite/login or whatever sitecore tree path you have set up. Then add it to the web.config.
Also, in the content tree you can click on security and access viewer for the login item. Then select the anonymous role. If its is a security issue then you will see which role is affecting the security settings for anonymous.
Type this in browser"Url of ur website/Sitecore/showconfig.aspx" .. Here you will get a combination of all the .config files being used. Also, you can just check in fiddler(a software) to see what else you get in response apart from resource can not be found.
Would be nice if you could also paste the settings you applied in the web.config, but this is how I understand the question.
You wanted to create a client user login page, not overriding the Sitecore login page.
If so, you have to ensure that it's under the home item (sitecore> content >home > YOUR_LOGIN_PAGE).
If outside the home item, eg. sitecore> content >YOUR_WEBSITE > YOUR_LOGIN_PAGE then you have to configure that in the sitedefinition.config because that is somehow treated as a new site and not part of the freshly installed Sitecore.
To validate that you have applied it correctly, try accessing the showconfig page on your browser (eg. http://YOUR_WEBSITE/sitecore/admin/showconfig.aspx)
Additional stuffs you might want to double check:
Make sure you were able to publish it on the web database, if not try accessing in the preview mode
Make sure that the item has layout and rendering definition. Otherwise, it won't work.
Make sure you have the right permission, for you to be able to access the page. I would assume you're in the admin role
This issue can be caused by modified setting :
<setting name="RequestErrors.UseServerSideRedirect" value="false" />"
which is false by default.
According to notes in config file If true, Sitecore will use Server.Transfer instead of Response.Redirect. But Server.Transfer is not good option for regular login page redirect because:
ASP.NET does not verify that the current user is authorized to view the resource delivered by the Transfer method.
You can change it in Sitecore.config file
<site name="shell" ... loginPage="yoururl" ... />
<site name="login" ... virtualFolder="/yoururl" ... />
<site name="admin" ... virtualFolder="/yoururl" ... loginPage="/yoururl/login.aspx" />