Giter Site home page Giter Site logo

keycloak-script-provider's People

Contributors

frank-fegert avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

keycloak-script-provider's Issues

TypeError realm.getRoles is not a function

Hi, I have use your spi to extract role attribute policy to token and I got error following this logs.

kc1_1   | 2023-02-02 19:28:38,481 ERROR [org.keycloak.protocol.oidc.mappers.ScriptBasedOIDCProtocolMapper] (executor-thread-0) Error during execution of ProtocolMapper script: org.keycloak.scripting.ScriptExecutionException: Could not execute script 'token-mapper-script_test-map-role-policy' problem was: TypeError: realm.getRoles is not a function in <eval> at line number 36
kc1_1   |       at org.keycloak.scripting.AbstractEvaluatableScriptAdapter.evalUnchecked(AbstractEvaluatableScriptAdapter.java:64)
kc1_1   |       at org.keycloak.scripting.AbstractEvaluatableScriptAdapter.eval(AbstractEvaluatableScriptAdapter.java:30)
kc1_1   |       at org.keycloak.protocol.oidc.mappers.ScriptBasedOIDCProtocolMapper.evaluateScript(ScriptBasedOIDCProtocolMapper.java:156)
kc1_1   |       at org.keycloak.protocol.oidc.mappers.ScriptBasedOIDCProtocolMapper.setClaim(ScriptBasedOIDCProtocolMapper.java:133)
kc1_1   |       at org.keycloak.protocol.oidc.mappers.AbstractOIDCProtocolMapper.transformAccessToken(AbstractOIDCProtocolMapper.java:82)
kc1_1   |       at org.keycloak.protocol.oidc.TokenManager.lambda$transformAccessToken$8(TokenManager.java:751)
kc1_1   |       at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
kc1_1   |       at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
kc1_1   |       at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
kc1_1   |       at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395)
kc1_1   |       at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
kc1_1   |       at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258)
kc1_1   |       at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
kc1_1   |       at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
kc1_1   |       at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
kc1_1   |       at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
kc1_1   |       at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
kc1_1   |       at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
kc1_1   |       at org.keycloak.protocol.oidc.TokenManager.transformAccessToken(TokenManager.java:750)
kc1_1   |       at org.keycloak.protocol.oidc.TokenManager.createClientAccessToken(TokenManager.java:539)
kc1_1   |       at org.keycloak.protocol.oidc.TokenManager$AccessTokenResponseBuilder.generateAccessToken(TokenManager.java:1044)
kc1_1   |       at org.keycloak.protocol.oidc.endpoints.TokenEndpoint.resourceOwnerPasswordCredentialsGrant(TokenEndpoint.java:651)
kc1_1   |       at org.keycloak.protocol.oidc.endpoints.TokenEndpoint.processGrantRequest(TokenEndpoint.java:208)
kc1_1   |       at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
kc1_1   |       at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
kc1_1   |       at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
kc1_1   |       at java.base/java.lang.reflect.Method.invoke(Method.java:566)
kc1_1   |       at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:170)
kc1_1   |       at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:130)
kc1_1   |       at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:660)
kc1_1   |       at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:524)
kc1_1   |       at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:474)
kc1_1   |       at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
kc1_1   |       at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:476)
kc1_1   |       at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:434)
kc1_1   |       at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:192)
kc1_1   |       at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:152)
kc1_1   |       at org.jboss.resteasy.core.ResourceLocatorInvoker.invokeOnTargetObject(ResourceLocatorInvoker.java:183)
kc1_1   |       at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:141)
kc1_1   |       at org.jboss.resteasy.core.ResourceLocatorInvoker.invoke(ResourceLocatorInvoker.java:32)
kc1_1   |       at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:492)
kc1_1   |       at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:261)
kc1_1   |       at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:161)
kc1_1   |       at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:364)
kc1_1   |       at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:164)
kc1_1   |       at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:247)
kc1_1   |       at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
kc1_1   |       at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:151)
kc1_1   |       at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:82)
kc1_1   |       at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.handle(VertxRequestHandler.java:42)
kc1_1   |       at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1284)
kc1_1   |       at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:173)
kc1_1   |       at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:200)
kc1_1   |       at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:84)
kc1_1   |       at io.quarkus.vertx.http.runtime.StaticResourcesRecorder$2.handle(StaticResourcesRecorder.java:71)
kc1_1   |       at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1284)
kc1_1   |       at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:173)
kc1_1   |       at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:200)
kc1_1   |       at io.quarkus.vertx.http.runtime.VertxHttpRecorder$6.handle(VertxHttpRecorder.java:430)
kc1_1   |       at io.quarkus.vertx.http.runtime.VertxHttpRecorder$6.handle(VertxHttpRecorder.java:408)
kc1_1   |       at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1284)
kc1_1   |       at io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:173)
kc1_1   |       at io.vertx.ext.web.impl.RoutingContextWrapper.next(RoutingContextWrapper.java:200)
kc1_1   |       at org.keycloak.quarkus.runtime.integration.web.QuarkusRequestFilter.lambda$createBlockingHandler$0(QuarkusRequestFilter.java:82)
kc1_1   |       at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:576)
kc1_1   |       at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
kc1_1   |       at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
kc1_1   |       at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
kc1_1   |       at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
kc1_1   |       at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
kc1_1   |       at java.base/java.lang.Thread.run(Thread.java:829)
kc1_1   | Caused by: javax.script.ScriptException: TypeError: realm.getRoles is not a function in <eval> at line number 36
kc1_1   |       at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:477)
kc1_1   |       at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:433)
kc1_1   |       at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine$3.eval(NashornScriptEngine.java:521)
kc1_1   |       at java.scripting/javax.script.CompiledScript.eval(CompiledScript.java:89)
kc1_1   |       at org.keycloak.scripting.CompiledEvaluatableScriptAdapter.eval(CompiledEvaluatableScriptAdapter.java:39)
kc1_1   |       at org.keycloak.scripting.AbstractEvaluatableScriptAdapter.evalUnchecked(AbstractEvaluatableScriptAdapter.java:61)
kc1_1   |       ... 70 more
kc1_1   | Caused by: <eval>:36 TypeError: realm.getRoles is not a function
kc1_1   |       at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
kc1_1   |       at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:213)
kc1_1   |       at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:185)
kc1_1   |       at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:172)
kc1_1   |       at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.Undefined.lookup(Undefined.java:100)
kc1_1   |       at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:106)
kc1_1   |       at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:96)
kc1_1   |       at jdk.dynalink/jdk.dynalink.linker.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:161)
kc1_1   |       at jdk.dynalink/jdk.dynalink.linker.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:109)
kc1_1   |       at jdk.dynalink/jdk.dynalink.LinkerServicesImpl.lambda$getGuardedInvocation$0(LinkerServicesImpl.java:137)
kc1_1   |       at jdk.dynalink/jdk.dynalink.LinkerServicesImpl.getWithLookupInternal(LinkerServicesImpl.java:168)
kc1_1   |       at jdk.dynalink/jdk.dynalink.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:135)
kc1_1   |       at jdk.dynalink/jdk.dynalink.DynamicLinker.relink(DynamicLinker.java:242)
kc1_1   |       at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$3$979$\^eval\_.getAllUserRoles(<eval>:36)
kc1_1   |       at jdk.scripting.nashorn.scripts/jdk.nashorn.internal.scripts.Script$Recompilation$2$\^eval\_.:program(<eval>:53)
kc1_1   |       at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:655)
kc1_1   |       at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:513)
kc1_1   |       at jdk.scripting.nashorn/jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:527)
kc1_1   |       at jdk.scripting.nashorn/jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:428)
kc1_1   |       ... 74 more
kc1_1   | 

Environment

  • Docker
  • Keycloak 20.0.3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.