dukecon / dukecon_html5

MIT License
2 stars 3 forks source link

Keycloak Auth #20

Closed steffchep closed 8 years ago

steffchep commented 8 years ago

Auth is working, still open: save and load user sattings (filters, favourites, language...)

ascheman commented 8 years ago

@annam002 / @steffchep: Please try to move this forward til the end of the year Maybe online session with @janwesterkamp, @ascheman, @sippsack on Dec. 28/29/30?

ascheman commented 8 years ago

Seems to be solved in general now (thanks to @ahus1), there is only a small follow up left (#30).

annam002 commented 8 years ago

I changed dukecloak.js as indicated. Works fine in Chrome and Firefox, but in IE 11 I get an error message "Unable to update token" and the synchronization does not work. Please have a look.

annam002 commented 8 years ago

I tracked it down to the method checkLoginIframe() in keycloak.json. Something goes wrong there with the iframe. It could be this problem: http://stackoverflow.com/questions/389456/cookie-blocked-not-saved-in-iframe-in-internet-explorer

ahus1 commented 8 years ago

I tried again today with IE11 and http://dev.dukecon.org/latest and don't see this happening.

@annam002 - can you please have a look (again)? Otherwise I will add a P3P header to Keycloak. But I want to see the error myself before I make this change. Instructions on how to reproduce it and/or a screenshot would be great.

annam002 commented 8 years ago

Here, at home, it happens in Firefox and Chrome. I don't have Internet Explorer here, but Edge, and it first gave me an internal server error on log in, and then the log in suddenly worked. I could not see anything in the server log about the error, though. My reproduction recipe: simply log in with the github account. You get the "logged in" symbol and the logged in user name shown, but the log says "Unable to update token". If you refresh the page, you are not logged in anymore. unabletoupdatetoken

ahus1 commented 8 years ago

@annam002 - please merge PR #35 and give it another try with Firefox and Chrome. Both work find for me. Please send a log of the console output. I know that the Keycloak version 1.4 we use has a known problem when the server clock is out of sync with the client clock.

More recent version of Keycloak autocorrect this. The log entries will show if this is a clock skew problem.

To tacke the IE problem there is PR https://github.com/dukecon/dukecon_infra/issues/9 - that will have to wait unti @ascheman merges and deploys this one.

annam002 commented 8 years ago

@ahus1 - This is the log output: local time: 1452425526.471 iat: 1452425376 diff: 150.47099995613098 exp in: 149.52900004386902 isExpired: false

ahus1 commented 8 years ago

@annam002

Die Log-Meldungen zeigen, dass die Zeitdifferenz nicht das Problem war (waren "nur" 3 Minuten) - wie auch immer, das neue Keycloak kann damit besser umgehen.

Danke, Alexander

annam002 commented 8 years ago

I can still reproduce the problem I had with Firefox and Chrome

annam002 commented 8 years ago

I can log in without problems on dev.dukecon.org/latest - seems to be a problem of the local server.

ahus1 commented 8 years ago

@ascheman - I found that for IE the P3P header is missing after we switched to SSL for keycloak. Please update the apache configuration. I made the change here: https://github.com/dukecon/dukecon_infra/commit/48959fed9bcd5775a06cee14c55d88aa7ffc2cea

annam002 commented 8 years ago

This issue only occurs when starting the server locally and seems not to be reliably reproducable

ahus1 commented 8 years ago

I added some more logging when the login fails. @annam002 - please try again on your local PC and post the logs afterwards.

Thanks!

annam002 commented 8 years ago

This is the log output now: Retrieve data from indexeddb dukecloak: documentready We are online - starting timer to check for updates Check for new data on server GET http://localhost:8080/develop/rest/conferences/499959 dukecloak: online GET http://localhost:8080/develop/rest/keycloak.json POST https://keycloak.dukecon.org/auth/realms/dukecon-developer/protocol/openid-connect/token Auth Success!! Authenticated: true local time: 1453225132.28 iat: 1453225097 diff: 35.28200006484985 exp in: 264.7170000076294 isExpired: false Logged out!! Unable to update token result.status: eventnotmached result.text: unable verify session or not logged in, session: dukecon-developer/10f139ea-54ae-485e-8189-f733f5a87bd9/9b3cc922-2b2f-4528-9a66-8fbee1a7da87, event: {"callbackId":"<id: 00.5525240759173605>","loggedIn":false}

ahus1 commented 8 years ago

Welcher Browser war das auf welchem Betriebssystem? [19:12:38] Anna: Das war Firefox auf Windows 10 [19:12:47] Anna: Firefox 43.0.4

ahus1 commented 8 years ago

@annam002 Keycloak öffnet auf der Dukecon-Seite einen iFrame und liest so den Cookie von Keycloak aus.

Hast Du irgendwelche Sicherheitseinstellungen oder Entwickler-/Adblocker-Plugins, die das blockieren könnten?

annam002 commented 8 years ago

Das war es! "Cookies von Drittanbietern akzeptieren" war auf "Nie" gesetzt. Nachdem ich es auf "Nur von besuchten Drittanbietern" gesetzt habe, ging es. Hm.

ahus1 commented 8 years ago

wo hast du das denn eingestellt? Ist das eine Standard-Firefox-Einstellung, oder ein Plugin?

annam002 commented 8 years ago

Einstellungen -> Datenschutz -> Chronik

ahus1 commented 8 years ago

ah, musste noch auf benutzerdefinierte Einstellungen umschalten.

ahus1 commented 8 years ago

Das Problem konnte wie folgt eingegrenzt werden: wenn dukecon auf localhost gestartet wird, dann gilt keycloak.dukecon.org als "Third Party"/"Drittanbieter". Je nach Cookieeinschränkung funktioniert dann die iFrame-Session-Erkennung nicht.

Wenn Dukecon und Keycloak unter der gleichen Domäne läuft wie in Test und Produktion (dev.dukecon.org und keycloak.dukecon.org), dann gilt das nicht als "Third Party"/"Drittanbieter" und die Anmeldung funktioniert.

Das Problem mit "Third Party"/"Drittanbieter" wird also in Produktion nicht auftreten. Nur in dem Fall, dass keine Cookies akzeptiert werden wird Keycloak nicht funktionieren.

Daher schließe ich das Ticket jetzt.