javascript adapter init failure and promise support

105 views
Skip to first unread message

Andrew Gates

unread,
Dec 4, 2020, 3:32:47 AM12/4/20
to Keycloak Dev
Hi there,

I recently opened a ticket regarding the javascript adapter and its initialization behavior - in a nutshell it silently fails when it tries to contact the keycloak server but the server is offline (or the adapter is configured with the incorrect url).


During the investigation, Michal Hajas identified some other potential issues relating to the adapter and its use of promises, which I understand may impact testing and browser compatibility.

I'm starting a conversation here to get opinions on the best way to resolve the issue, specifically
- how to report this type of failure back to the client during initialization (presumably a vanilla exception, or with a specific callback hook perhaps?)
- what (if anything) needs to be done regarding the use of promises, both for the test framework and browser support.

To be clear, I'm very much a newcomer to javascript, so I'm mostly starting the conversation to move the issue forward - I know just enough to know my opinions are dangerous :D

Regards,
Andrew

Erik Jan de Wit

unread,
Dec 9, 2020, 2:34:47 AM12/9/20
to Keycloak Dev
As for the promises polyfill that is only in place for IE, I don't know if we still need to support that browser. The new keycloak admin console will not work on that for instance, and I'm sure a lot of other things will no longer support IE either.
Also I think it's about time that the keycloak adapter got it's own project so that building and testing it will be more geared towards javascript developers as the way it's setup now we loose a lot of community involvement as it's part of this big java based project. That would also mean that testing could occur on something a bit better then phantomjs.
I'm not sure why you are asking about how to report this failure, as the fix from Michal will already take care of that.

Andrew Gates

unread,
Dec 10, 2020, 3:53:36 AM12/10/20
to Keycloak Dev
Hi,

Thanks for the feedback.
My impression from the conversation with Michal Hajas was that there was uncertainty both in what to do about phantomjs / promises / IE, and also about the best way to resolve this particular issue - but I may well have misinterpreted.
Since it seems that IE support is not really an issue, I will try to create a PR for this fix.

Andrew Gates

unread,
Feb 8, 2021, 8:42:49 AM2/8/21
to Keycloak Dev
Hi there,

I logged a ticket a while back about the javascript adapter silently failing on startup if mis-configured (see KEYCLOAK-16455 for details) - essentially the adapter creates an iframe that loads a page from the keycloak server, but if the iframe can't reach the server, the init call silently fails.

I have finally managed to find some time to help work on a fix based on a sample from Michal Hajas (see https://github.com/mhajas/keycloak/commit/b0731e8489803b02744c0c54981698fd7a298cf9#)

I have a few questions about this, and am not sure if the correct forum to raise them is here, or in the pull request?

Question 1:
Should the timeout to receive a response from the iframe be configurable (my vote), or just hard-coded to some value?

Question 2:
I see at least one other place where something like this happens - the adapter creates an iframe and waits for something. Should I add a timeout check here too, or leave that for a separate issue?

Regards,
Andrew

--
You received this message because you are subscribed to a topic in the Google Groups "Keycloak Dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/keycloak-dev/5YAvBID-MJQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to keycloak-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/keycloak-dev/84d78725-a554-4124-875b-5042a370be4an%40googlegroups.com.


--

Regards,
Andrew


Reply all
Reply to author
Forward
0 new messages