[keycloak-user] Script Based Authenticator - Web Service Call
cedric@couralet.eu
cedric at couralet.eu
Thu Nov 7 12:47:23 EST 2019
Hello,
Le Jeudi, Novembre 07, 2019 15:16 CET, Frank Herrmann <frank.herrmann at modernizingmedicine.com> a écrit:
> Hello all,
>
> I'm attempting to use a script based authenticator to fire as part of the
> post login flow of an identity provider. I need to make a web service call
> from this script. Is this even possible? I've tried using XMLHttpRequest,
> but as this is not executing inside a browser, it does not work. Is there a
> way to get access to RestEasy on Wildfly and use REST.request()?
>
For a similar need, we used the SimpleHttp class from keycloak like this :
SimpleHttp = Java.type("org.keycloak.broker.provider.util.SimpleHttp");
function authenticate(context) {
var result= SimpleHttp.doGet('http://yoururl.test').asString();
//do something with result
context.success();
}
SimpleHttp methods can be found here : https://github.com/keycloak/keycloak/blob/master/server-spi-private/src/main/java/org/keycloak/broker/provider/util/SimpleHttp.java
There may be a way to get a complete RestEasy client but SimpleHttp was enough for us.
Cédric
> Basically, has anyone had to do anything similar, and what did you do to
> accomplish this? Or, if this isn't possible in the limitations of a script
> based authenticator, should I just write a small authenticator in Java to
> handle this.
>
> Thanks for the help.
>
> -Frank
More information about the keycloak-user
mailing list