[keycloak-user] How to set up CORS for javascript calling a REST app

Stian Thorgersen stian at redhat.com
Tue May 6 04:54:38 EDT 2014


I added some fixes to CORS in the adapters that haven't made it into a release yet. Have you tried with building the server from source?

----- Original Message -----
> From: "Bill Burke" <bburke at redhat.com>
> To: keycloak-user at lists.jboss.org
> Sent: Monday, 5 May, 2014 11:42:11 PM
> Subject: Re: [keycloak-user] How to set up CORS for javascript calling a REST app
> 
> You are using the latest release? I'll take a look.  I don't have any
> unit tests for the CORs stuff in the last alpha release (have some in
> trunk though) and I don't think I tested it manually either.
> 
> On 5/5/2014 3:41 PM, Boettcher, Jim wrote:
> > Hi,
> >
> > I’m trying to get CORS working for a javascript app. The javascript app
> > (gui_app) is making AJAX requests to a different REST app (rest_app).
> >
> > In the Keycloak admin console I created an application for the rest_app
> > application and set a Web Origin of “*” . I then copied the Installation
> > for Jboss Subsystem XML to the standalone.xml of the JBoss 7.1.1 server
> > that the rest_app is running on. I modified the configuration to add
> >
> > <enable-cors>true</enable-cors>
> >
> > When I try to open the gui_app from Chrome I get errors like:
> >
> > XMLHttpRequest cannot load
> > http://localhost:8080/auth/rest/realms/dp-gui/tokens/login?client_id=rest_app&redirect_uri=https%3A%2F%2Flocalhost%3A7116%2Frest_app%2Frestws%2Ftimezone&state=3%2F502272ab-ab8f-4d9e-b8ea-4484a81de15c&login=true.
> > No 'Access-Control-Allow-Origin' header is present on the requested
> > resource. Origin 'https://localhost:7116' is therefore not allowed access.
> >
> > I’ve tried playing with various settings but can’t get anything to work.
> >
> > Is there an example available for how to get this to work?
> >
> > Is there anything else that needs to be done on the Keycloak server
> > side? Or on the Adapter side?
> >
> > Thanks,
> >
> > Jim
> >
> >
> >
> > _______________________________________________
> > keycloak-user mailing list
> > keycloak-user at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/keycloak-user
> >
> 
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
> 



More information about the keycloak-user mailing list