I have a web application which is hosted at https://example.com. I would like to share a session cookie between the main domain https://example.com and sub-domain https://www.example.com. Thus, there should be no need for a user to re-login if they switch from one domain to another. How do I achieve this in springboot 2.2.6?
This is what I have tried:
I went to application.properties and set server.servlet.session.cookie.domain=.example.com
Now, this does not help. I get an error:
java.lang.IllegalArgumentException: An invalid domain [.example.com] was specified for this cookie
at org.apache.tomcat.util.http.Rfc6265CookieProcessor.validateDomain(Rfc6265CookieProcessor.java:210) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.tomcat.util.http.Rfc6265CookieProcessor.generateHeader(Rfc6265CookieProcessor.java:145) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
at org.apache.catalina.connector.Response.generateCookieString(Response.java:973) ~[tomcat-embed-core-9.0.33.jar:9.0.33]
If I set server.servlet.session.cookie.domain=example.com, then the cookie is not visible for http://www.example.com and if I set server.servlet.session.cookie.domain=www.example.com, then the cookie is not visible for http://example.com
I have read discussions about Rfc6265CookieProcessor and LegacyCookieProcessor, but I don't know the right way to fix this issue.
Springboot 2.2.6 uses tomcat version 9.0.*
So, how do I fix this issue?
EDIT:
I was trying the above changes on localhost only and not on production. Instead of accessing http://www.example.com, I was doing https://www.localhost and instead of accessing http://example.com, I was doing http://localhost
The right value is:
server.servlet.session.cookie.domain=example.com
What I was trying was that I was making changes on localhost and they were not working for me. I was modifying the values in chrome console manually and expecting to see cookies set on https://localhost with domain localhost to be visible in another tab for domain https://www.localhost and that was not happening.
I read the answer here: Share cookie between subdomain and domain and #Cesc 's comment on that answer which was :
I am not sure where to put this so I am choosing the comments of the
accepted answer. It took long time and failed experiments to prove the
above on my localhost, until it occurred to me that I should call the
localhost with a dot in the name. Like "localhost.com" or something
like that. Then all the "set cookies" behaviours started following the
explanations written here in this answer. Hoping this might help
somebody.
So, I tried my changes on production directly and they worked fine. I am still not able to get it to work on localhost. The way I access my website on localhost is:
https://localhost and https://www.localhost. Based on #Cesc 's comment, I probably need to access the website on localhost as https://www.localhost.com or https://localhost.com and then it will work. But, I have not tried that.
Rather than testing with 'localhost' on your dev machine, try using your machine's fully-qualified host name. I've had a similar challenge with testing authentication against our single-signon platform.
Related
I have this code:
Connector conn = FrameworkUtil.getConnector(context, ALFRESCO_ENDPOINT_ID);
ConnectorContext c = new ConnectorContext(HttpMethod.POST);
c.setContentType("application/json");
Response res = conn.call("/slingshot/profile/userprofile", c,
new ByteArrayInputStream(buf.toString().getBytes()));
That makes a POST to the link: POST http://localhost:8080/share/service/components/profile/userprofile
But, I got the error:
TypeError: g.getResponseHeader is undefined
...unction(g){var b=g.argument.config;var
f=g.getResponseHeader["Content-Type"]||g....
In a search on the Internet, I saw that this can be a problem that is solved adding Content-Type with CORS.
Something like:
.header("Access-Control-Allow-Headers", "x-requested-with,Content-Type");
How can I do this in my code? With Connector or ConnectorContext I don't find a way to set the header...
Or if this is not the way to solve this, how can I solve this error?
I think you might have a few things configured incorrectly here, or you might be misunderstanding a few things. If you're making a remote connection to the ALFRESCO_ENDPOINT_ID then this typically means that you're trying to connect to the Alfresco Repository - and based on where you say you're trying to make the call from it would appear that this is in a Java-backed WebScript running within the Share application - is this correct?
If so, the URL that should be requested would actually be:
http://localhost:8080/alfresco/service/slingshot/profile/userprofile
Which would be equivalent to calling the following:
http://localhost:8080/share/proxy/alfresco/slingshot/profile/userprofile
(the second URL automatically proxies to the Alfresco enpoint).
If you have both the Alfresco Repository and Share running in the same server (which the use of the port 8080 implies you do) then you shouldn't be hitting CORS issues - unless you're trying to go from localhost to some remote location where the Alfresco Repository is running.
Share/Surf should be taking care of all of this for you - perhaps you can provide a bit more context on exactly what it is you're trying to do,
where the code is running (e.g. WebScript, Share, etc) and where you're trying to connect to?
This might help in best advising how to solve your main problem.
I have set up a project to use Glassfish 4 with a resource that links back to a MySql database and I am using Eclipse Keplar. I have set up the connection pool with the relevant details and pinging it from the glassfish admin page succeeds. I have an EJB project with JPA set up to access the resource but when access is atempted either in a browser or Eclipse I get a "No database selected" error.
After searching around I found that there are issues with the Url parameter of the pool and renaming that parameter to URL might solve it. the post I found also suggested that I enter the connection string as he suspected that different calls were being made and the string was not getting constructed correctly outside of Glassfish. I did these things but I then get an error "No Password Credential" even though I do have the password entered in the connection string.
Has anyone else encountered this and have any advice as to what the problem is and how I can solve it?
For me, editing the URL and Url parameters didn't work. However after restarting Glassfish (domain), the problem disappeared.
I have figured this out and it was the url value that needed to be set correctly. I didn't need it all but I did need to set the server and database name on it:
jdbc:mysql://localhost:3306/<DB Name Here>
I had changed the parameter name to URL from Url but it turns out that this is not required.I have no idea why this step is required as the values are all there in other parameters and the ping succeeds from the admin pages.
MYSQL and Glassfish.
In glassfish 4.0 if "No password credential found" error appears whenever you try to ping, it most probably means, you did not setup password(you gave empty password) when you first installed mysql server on your system, glassfish4.0 has a problem with empty password. Either you need to reset the password or uninstall the mysql server completely, and then re-install, by giving new password. To uninstall the mysql-server completely please flow this link, https://askubuntu.com/questions/640899/how-do-i-uninstall-mysql completely it worked for me.
I am using Payara 5.181 and after I changed some properties and clicked flush, it throwed exceptions and ping resulted in this error. After domain restart it works, don't know why.
Our company running Liferay without virtual host. We using VM IP with port 80 open for our portal. No any problems with this setup.
When I'm added virtual host to Liferay and changed DNS on my machine -- I can't opened any assets (articles) with long russian names.
Tomcat console:
WARN [404_jsp:109] /home/-/asset_publisher/JbL5ejmhvwSa/content/%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D0%BF%D1%80%D0%BE%D0%BA%D0%BE%D0%BC-%D0%BF%D0%BE-%D0%BE%D0%BF%D1%82%D0%B8%D0%BC%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D0%B8-%D1%80%D0%B0%D0%B1%D0%BE%D1%87%D0%B5%D0%B3%D0%BE-%D0%B2%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%B8-%D1%81%D0%BE%D1%82%D1%80%D1%83%D0%B4%D0%BD%D0%B8%D0%BA%D0%BE%D0%B2-%D0%BD%D0%B0-%D0%B1%D0%B0%D0%B7%D0%B5-%D0%BF%D1%80%D0%BE%D0%B4%D1%83%D0%BA%D1%82%D0%BE%D0%B2-ibm
Virtual host enabled URL (not working)
http://companyname.com/home/-/asset_publisher/JbL5ejmhvwSa/content/%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D0%BF%D1%80%D0%BE%D0%BA%D0%BE%D0%BC-%D0%BF%D0%BE-%D0%BE%D0%BF%D1%82%D0%B8%D0%BC%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D0%B8-%D1%80%D0%B0%D0%B1%D0%BE%D1%87%D0%B5%D0%B3%D0%BE-%D0%B2%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%B8-%D1%81%D0%BE%D1%82%D1%80%D1%83%D0%B4%D0%BD%D0%B8%D0%BA%D0%BE%D0%B2-%D0%BD%D0%B0-%D0%B1%D0%B0%D0%B7%D0%B5-%D0%BF%D1%80%D0%BE%D0%B4%D1%83%D0%BA%D1%82%D0%BE%D0%B2-ibm?redirect=http%3A%2F%2Finterprocom.ru%2Fhome%3Fp_p_id%3D101_INSTANCE_JbL5ejmhvwSa%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-2%26p_p_col_pos%3D1%26p_p_col_count%3D2
Virtual host disabled URL (working)
http://192.168.10.35/web/guest/home/-/asset_publisher/JbL5ejmhvwSa/content/%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D0%BF%D1%80%D0%BE%D0%BA%D0%BE%D0%BC-%D0%BF%D0%BE-%D0%BE%D0%BF%D1%82%D0%B8%D0%BC%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D0%B8-%D1%80%D0%B0%D0%B1%D0%BE%D1%87%D0%B5%D0%B3%D0%BE-%D0%B2%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%B8-%D1%81%D0%BE%D1%82%D1%80%D1%83%D0%B4%D0%BD%D0%B8%D0%BA%D0%BE%D0%B2-%D0%BD%D0%B0-%D0%B1%D0%B0%D0%B7%D0%B5-%D0%BF%D1%80%D0%BE%D0%B4%D1%83%D0%BA%D1%82%D0%BE%D0%B2-ibm?redirect=http%3A%2F%2F192.168.10.45%2Fweb%2Fguest%2Fhome%3Fp_p_id%3D101_INSTANCE_JbL5ejmhvwSa%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-2%26p_p_col_pos%3D1%26p_p_col_count%3D2
It's few days until we go public. We'll use our domain companyname.com
I'm worried that we will got same issue.
Without being able to immediately solve the underlying problem: You can also use the last option with the host name: No virtual host names, just have the name resolve to 192.168.10.35 (change to an actual IP when going live).
Also, what version of Liferay are you on?
see this Question, my be it help you: Liferay: After changing Public Virtual Host settings, can't log in
Also you can see in generated jsp code tomcat/work/... why this do not work.
And at last, you can debug Liferay and find the solution :) The simple way to debug Liferay is to get Liferay IDE and add Liferay Source as eclipse project. Good luck.
Even I face this issue and observed that with liferay's virtual host mapping, url's with special characters are not showing up when they are related to entries in Guest site.
By mapping virtual host, web/guest part is removed from the URL.
Now if you try manually adding web/guest before the URL, In your case
try accessing with following URL
http://companyname.com/web/guest/home/-/asset_publisher/JbL5ejmhvwSa/content/%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D0%BF%D1%80%D0%BE%D0%BA%D0%BE%D0%BC-%D0%BF%D0%BE-%D0%BE%D0%BF%D1%82%D0%B8%D0%BC%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D0%B8-%D1%80%D0%B0%D0%B1%D0%BE%D1%87%D0%B5%D0%B3%D0%BE-%D0%B2%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%B8-%D1%81%D0%BE%D1%82%D1%80%D1%83%D0%B4%D0%BD%D0%B8%D0%BA%D0%BE%D0%B2-%D0%BD%D0%B0-%D0%B1%D0%B0%D0%B7%D0%B5-%D0%BF%D1%80%D0%BE%D0%B4%D1%83%D0%BA%D1%82%D0%BE%D0%B2-ibm?redirect=http%3A%2F%2Finterprocom.ru%2Fhome%3Fp_p_id%3D101_INSTANCE_JbL5ejmhvwSa%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-2%26p_p_col_pos%3D1%26p_p_col_count%3D2
and it should work.
So one possible way to resolve this issue is to keep virtual host
mapping in your windows/your os hosts file and rename virtual host to
localhost in Liferay in portal settings under Portal tab in control
panel.
STEPS:
1) In hosts file keep the mapping as you have done i.e
192.168.10.35 companyname.com
2) In liferay, remove the virtual host mapping i.e rename virtual host to localhost in "portal settings" under "Portal" tab in control panel.
and try to access your entry and it will work.
This is very interesting behavior/ may be a bug in liferay.
Hope this helps.
So you testing Liferay on your local host, then trying to move on real domain and facing some weird behaviour.
First thing you want to do is to check Control Panel and type in your new virtual host there.
I'm not sure about this because we are using 6.0 now and I did not remember how exactly we fixed it. If my advice did not helped please check other comments to this question.
I exported a working Selenium test case to Java, running it via selenium-rc's selenium-server.jar in Junit4 on Eclipse.
The test case breaks the next step after opening the page, trying to write to an element. When stepping through the runtime I noticed the error,
The requested URL could not be retrieved
The following error was encountered:
Unable to determine IP address from host name for unknown server name
This means that: The cache was not able to resolve the hostname presented in the URL. Check if the address is correct.
So, I changed the url to the corresponding IP address of the web page, but now I am timing out.
Opening the page using both the url and IP formats manually is working, (except IP doesn't for IE8). I'm originally targeting Firefox, but will expand to other browsers once I have solved this issue.
Is there a security issue involved with Selenium opening a page in a browser via RC programatically that browsers don't like? What sort of issues should I be investigating to solve this?
I think you are trying to open a secure page.In selenium pages which has ssl certificates should be handled.
The problem actually came down to the proxy set up on my machine. After removing it things worked fine.
I'm following Scott Davis' tutorials on developing grails apps, but whenever i try to run my app (or indeed his source code) i get "Firefox has detected that the server is redirecting the request for this address in a way that will never complete." Safari gives a similar error message as does Opera.
As i've tested the original authors source code which gives the same error i'm fairly confident it's nothing to do with the code.
Is this a problem with the web server on my machine? I use Mac OS Snow Leopard so i'm assuming it's apache that's generating this error.
Edit: Seems Grails as standard uses Jetty, so probably not Apache that is causing the problem. However also tested the app on Glassfish and i get the same error.
Anyone know what i can do to fix this?
Cheers
It depends on the code and Apache configuration you are using. I assume that the web server sends cyclic HTTP redirections, eg. from /root/ to /root (without the slash) and vice versa. This causes a redirection infinite loop.
Check your configuration on conditions that cause a HTTP redirect. For example, Apache automatically adds slashes to directory URLs in standard configuration (like the /root/ example above). I don't know Grails, so I cannot give you a hint on how URLs are processed within the app.
You can also use manual HTTP requests for debugging to see whats going on behind the scenes, using telnet on a terminal:
$ telnet localhost 80
GET / HTTP/1.0
I guess the response will be something like that:
HTTP/1.0 302 Found
Location: XXX
...
Now do a second request on the URL passed in the Location header and so on.
I was getting the same error a little while ago, heres how I fixed:
Try the same page on a different internet setup (it could be your ISP)
Open up Safari, Firefox or whatever your using and empty the cache and delete ALL your cookies
Reboot your computer and try again
It may work now, but if it doesn't:
open up Firefox and type 'about:config' (without the quotes) into the URL bar
You will get some little warning, just press OK
Type 'redirect' into the Filter box
You should see a listing for 'network.http.redirection-limit'
Double click the listing and type a large number (anything above 50 and lower than 200)
Press OK, quit and re-open FireFox
Basically all that does is make FireFox's tolerance for redirect loops higher which should fix your problem - but usually, just borrowing someone else's internet connection fixes it
Hope that all helps =)
Just carefully check your URLMappings configuration:
YOUR_APP/grails-app/conf/UrlMappings.groovy
Common case:
You configured request to be handled like this:
"/anything" (controller:"someController")
So without action, request will be handled by default one, "index". "index" action usually redirects to "list", and "list", in some cases redirect back to "index"
There is your loop.
Good luck