mattmorg55 / Owin.Security.Keycloak

Keycloak Authentication Middleware for the C# OWIN Pipeline
http://keycloak.jboss.org
MIT License
17 stars 20 forks source link

CORS issue #7

Open matthewjordaan opened 5 years ago

matthewjordaan commented 5 years ago

Apologies if this is not an issue or a failure on my side - when using this and following from the sample project I get a CORS problem:

Failed to load http://localhost:8080/auth/realms/demo/protocol/openid-connect/auth?redirect_uri=http:%2F%2Flocalhost:5595%2Fowin%2Fsecurity%2Fkeycloak%zzz.KeyCloakClientPortalSession%2Fcallback&response_type=code&scope=openid&state=oidc_state_d2b840d1da384a4392199e7b4c9d7721&client_id=zzz: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:5595' is therefore not allowed access.

From my research I need to add "enableCors: true" to the header for KeyCloak but don't seem to be able to come right with that

ghost commented 5 years ago

@matthewjordaan Is zzz the client_id configured for the app on the server?

matthewjordaan commented 5 years ago

@nettolicious yes it is

ghost commented 5 years ago

@matthewjordaan and localhost:5595 is configured as a valid redirect? The only other thing I can think of is that the full redirect URI looks a little weird redirect_uri=http:%2F%2Flocalhost:5595%2Fowin%2Fsecurity%2Fkeycloak%zzz.KeyCloakClientPortalSession%2Fcallback ... That being said, I haven't worked with Keycloak in a while. You might try checking the logs on the server.

matthewjordaan commented 5 years ago

@nettolicious yes - I added "http://localhost:5595/*" and "http://localhost:5595" as redirects to see. That redirect uri is created by the middleware... so I'm not sure