[keycloak-dev] Using plain javascript in javascript based policy
Pedro Igor Silva
psilva at redhat.com
Thu Aug 22 08:37:48 EDT 2019
Hi,
Scripts in Keycloak are run using Nashorn (a script engine). It basically a
ECMAScript implementation, so you don't have support for XMLHttpRequest.
Your requirements seem to be related to
https://issues.jboss.org/browse/KEYCLOAK-5346. We are also working to allow
deployments of custom Policy Providers so that you can just select them in
the admin console in order to create a policy.
On Thu, Aug 22, 2019 at 8:25 AM abhishekumar005 at yahoo.com <
abhishekumar005 at yahoo.com> wrote:
> Hi all,I am using a Javascript-based policy to verify a user in order to
> access a particular resource. I want to include an extra check, like, I
> will call an external API and if that API returns true, then only access
> will be provided to the user. I tried using XMLHttpRequest to open a get
> request, but it is not working. In fact, plain js functions like
> console.log() is also not working in javascript policy. The error show is
> given below:
> Unexpected error while evaluating permissions: java.lang.RuntimeException:
> Failed to evaluate permissions.
> Caused by: org.keycloak.scripting.ScriptCompilationException: Could not
> compile 'Mail-policy' problem was: <eval>:7:4 Expected ; but found xhrlet
> xhr = new XMLHttpRequest(); ^ in <eval> at line number 7 at column
> number 4
>
> How to do this? Is there any other approach?
> Regards,Abhishek
>
> _______________________________________________
> keycloak-dev mailing list
> keycloak-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-dev
More information about the keycloak-dev
mailing list