I'm trying to test the Javascript Based policies defined in this project https://github.com/mposolda/devconf2019-authz/blob/master/cars-realm.json#L191, but everytime I try to access a protected ressource I got the following error in keycloak logs :
Caused by: java.lang.IllegalStateException: Could not find ScriptEngine for script: Script{id='null', realmId='cars', name='Only From a Specific Client Address', type='text/javascript', code='var contextAttributes = $evaluation.getContext().getAttributes();
if (contextAttributes.containsValue('kc.client.network.ip_address', '127.0.0.1')) {
$evaluation.grant();
}', description='Defines that only clients from a specific address can do something'}
at org.keycloak.keycloak-services#15.0.2//org.keycloak.scripting.DefaultScriptingProvider.createPreparedScriptEngine(DefaultScriptingProvider.java:106)
at org.keycloak.keycloak-services#15.0.2//org.keycloak.scripting.DefaultScriptingProvider.prepareEvaluatableScript(DefaultScriptingProvider.java:72)
at org.keycloak.keycloak-services#15.0.2//org.keycloak.scripting.DefaultScriptingProvider.prepareEvaluatableScript(DefaultScriptingProvider.java:33)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.js.JSPolicyProviderFactory.lambda$getEvaluatableScript$0(JSPolicyProviderFactory.java:109)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.js.ScriptCache.lambda$computeIfAbsent$0(ScriptCache.java:80)
at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1224)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.js.ScriptCache.computeIfAbsent(ScriptCache.java:80)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.js.JSPolicyProviderFactory.getEvaluatableScript(JSPolicyProviderFactory.java:106)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.js.JSPolicyProvider.evaluate(JSPolicyProvider.java:46)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.aggregated.AggregatePolicyProvider.evaluate(AggregatePolicyProvider.java:66)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.aggregated.AggregatePolicyProvider.evaluate(AggregatePolicyProvider.java:66)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.permission.AbstractPermissionProvider.evaluate(AbstractPermissionProvider.java:56)
at org.keycloak.keycloak-authz-policy-common#15.0.2//org.keycloak.authorization.policy.provider.permission.ScopePolicyProvider.evaluate(ScopePolicyProvider.java:52)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.policy.evaluation.DefaultPolicyEvaluator.lambda$createPolicyEvaluator$0(DefaultPolicyEvaluator.java:116)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$PolicyCache.cacheQuery(StoreFactoryCacheSession.java:1098)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$PolicyCache.cacheQuery(StoreFactoryCacheSession.java:1073)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$PolicyCache.findByScopeIds(StoreFactoryCacheSession.java:1045)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.AuthorizationProvider$3.findByScopeIds(AuthorizationProvider.java:430)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.policy.evaluation.DefaultPolicyEvaluator.evaluate(DefaultPolicyEvaluator.java:86)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.permission.evaluator.UnboundedPermissionEvaluator.lambda$evaluate$0(UnboundedPermissionEvaluator.java:49)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.permission.Permissions.lambda$all$1(Permissions.java:87)
at java.base/java.util.function.Consumer.lambda$andThen$0(Consumer.java:65)
at java.base/java.util.function.Consumer.lambda$andThen$0(Consumer.java:65)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$ResourceCache$1.accept(StoreFactoryCacheSession.java:678)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$ResourceCache$1.accept(StoreFactoryCacheSession.java:673)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.utils.ClosingStream.forEach(ClosingStream.java:128)
at org.keycloak.keycloak-model-jpa#15.0.2//org.keycloak.authorization.jpa.store.JPAResourceStore.findByOwnerFilter(JPAResourceStore.java:136)
at org.keycloak.keycloak-model-jpa#15.0.2//org.keycloak.authorization.jpa.store.JPAResourceStore.findByOwner(JPAResourceStore.java:101)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$ResourceCache.lambda$findByOwner$7(StoreFactoryCacheSession.java:673)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$ResourceCache.cacheQuery(StoreFactoryCacheSession.java:845)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$ResourceCache.cacheQuery(StoreFactoryCacheSession.java:830)
at org.keycloak.keycloak-model-infinispan#15.0.2//org.keycloak.models.cache.infinispan.authorization.StoreFactoryCacheSession$ResourceCache.findByOwner(StoreFactoryCacheSession.java:671)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.AuthorizationProvider$4.findByOwner(AuthorizationProvider.java:501)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.permission.Permissions.all(Permissions.java:85)
at org.keycloak.keycloak-server-spi-private#15.0.2//org.keycloak.authorization.permission.evaluator.UnboundedPermissionEvaluator.evaluate(UnboundedPermissionEvaluator.java:48)
Is there any further step I need to do in order to make this example work ?
Keycloak version : 15.0.2
Java version : 15
Thanks !
When we look at the first line of the log message:
Could not find ScriptEngine for script: Script{ ... type='text/javascript'... }
we see that keycloak is not able to load a javascript scripting engine.
Since Java >= 15, no javascript engine is provided with the JVM (see JEP 372). This is the reason why keycloak cannot find a javascript engine.
I see two possible solutions to the problem:
Provide a javascript engine through some 3rd party libraries (for detail see this question by Paul Taylor), or
Downgrade Java to <= 14 (not recommended).
Related
I am trying to set/get an array as a cookie in Javascript as follows:
let features = [];
for(const property in object) {
...
let feature = new Feature(...);
features.push(feature);
}
cookie.set('features', JSON.stringify(features));
console.log(JSON.parse(cookie.get('features')));
and I get the following error:
VM21081:1 Uncaught SyntaxError: Unexpected token u in JSON at position 0
P.S. If I do not use stringify/parse the result is undefined.
Could you help me, please?
Thank you in advance.
the issue is that you try to set and get cookies in the browser on the local environment.
I copied from the answer in this topic (Why does Chrome ignore local jQuery cookies?)
'Chrome doesn't support cookies for local files (or, like Peter Lyons mentioned, localhost*) unless you start it with the --enable-file-cookies flag. You can read a discussion about it at http://code.google.com/p/chromium/issues/detail?id=535.
*Chrome does support cookies if you use the local IP address (127.0.0.1) directly. so in the localhost case, that could be an easier workaround.'
to test your code you can use w3school editor, here is an example:
https://www.w3schools.com/code/tryit.asp?filename=GHTVNK8POVWM
(click run button to see the result)
I am trying to switch to javascript for scripting in loadrunner. While this process i recorded script by changing the script language and I got a script. Now when i was trying to correlate a parameter i am getting error as described below.
Loadrunner Version : 12.63
This code snippet is copied from MF documentation made made changes according to my need: HERE
// ClientID":"f3d65s4gs6dg4df65g465fd4","
web.reg_save_param (""outFlightVal",
new String []{
"NOTFOUND=ERROR",
"LB=ClientID\":\"",
"RB=\",\"" ,
"LAST"} );
ERROR :
Action.js(142): Error: 'SyntaxError: missing ) after argument list'.
Source line: ' web.reg_save_param (""outFlightVal",'.
I even tried :
web.regSaveParamEx(paramName:"outFlightVal",lb:'ClientID":"',rb:'",');
ERROR:
Action.js(149): Error: 'SyntaxError: missing ) after argument list'.
Source line: ' web.regSaveParamEx(paramName:"outFlightVal",lb:'ClientID":"',rb:'",');'.
After some research I got to know that the java code given in the documentation is not for javascript. it is for java Vuser which is used by some protocol like oracle DB, JMS ..etc
and web_reg_save_param is a older version of web_reg_save_param_ex and is no longer supported when we use javascript as a scripting language. so only web.regSaveParamEx is supported and it accepts an object so
instead of :
web.regSaveParamEx(paramName:"outFlightVal",lb:'ClientID":"',rb:'",');
use :
web.regSaveParamEx({paramName:"outFlightVal",lb:'ClientID":"',rb:'",'});
I am new to machine learning and I was following this blog on how to write a model with mobilenet.
I managed to convert the .h5 file model and tried to implement it
on my web app.
Unfortunately, when I try to load the JSON model I get this error:
Uncaught (in promise) Error: Provided weight data has no target
variable: block1_conv1_2/kernel.
Screenshot of the error on a browser
I converted the .h5 model in the command line like so:
tensorflowjs_converter --input_format keras model.h5 ConvertedModel/
The code to load the model in the browser, I followed this blog
let model;
async function loadModel(name) {
$(".progress-bar").show();
model = undefined;
model = await tf.loadModel(`ConvertedModel/model.json`);
$(".progress-bar").hide();
}
To see the code of the model please refer to the blog link.
But below is a screenshot of how the model is compiled.
Model compilation
Dependencies:
Tensorflow 1.13.1
Python 3.6.0
tensorflowjs 1.0.1
Any help to fix this would be appreciated. Thank you so much.
It seems you've encountered this error where an extra suffix has been added to some of your weights.
You can work around this issue by manually removing these extra suffixes from your model.json:
block1_conv1_2/kernel
should instead be:
block1_conv1/kernel
The 'Error in clip' bug has now been fixed so I'm not too sure why you've received this one, but once again you can work around this by manually editing the model.json, and changing every instance of:
{"type":"ndarray", "value":6}
to
6
If use pattern matching for checking type of variable then it raise The JavaScript language service has been disabled
var exception = ex as XYZException; //it has no issue
but if :
if (ex is XYZException exception) // it generate error of JaVascript Service Disabled
Please see screenshot :
UPDATE : Fixed by updating Visual Studio.
Seems you need to update the visual studio.
https://learn.microsoft.com/en-us/visualstudio/releasenotes/vs2017-relnotes#knownissues
I am using a java applet that performs functionality that requires access outside the browser sandbox. The applet is prepared as follows:
All calls requiring privileged access are wrapped appropriately in calls to AccessController.doPrivileged().
The jar is signed and includes a certificate chain that validates with jarsigner -verify (output is "jar verified.").
The MANIFEST.MF in the jar contains:
Manifest-Version: 1.0
Created-By: 1.8.0_05 (Oracle Corporation)
Permissions: all-permissions
The jnlp file contains:
<security>
<all-permissions />
</security>
The applet is deployed using dtjava:
dtjava.embed({
id: 'myapplet',
url: 'myapplet.jnlp',
width: 1,
height: 1,
placeholder: "appletPlaceholder",
},
{},
{
onJavascriptReady: mycallback,
}
);
In the callback, I call a method on the applet:
var applet = document.getElementById(appletId);
applet.someMethod();
Everything works as expected--but only if the base URL that is serving the applet (e.g., http://www.example.com/) is added to Java's "Exception Site List" within the Java control panel.
If the base URL is not listed in the Exception Site List, then I get the following error from the javascript when someMethod() is called:
Error calling method on NPObject!
This is cryptic, and I'm not sure how to track down the cause of the problem.
How do I fix this error? How do I even debug this error?