casbin/jcasbin

ClassCastException for Strings within grouping fucntions

pza94 opened this issue · 3 comments

pza94 commented

Hi there,

I created a matcher that extracts a string from a given request object, and checks if that is in a given group:

g4(keyGet2(r.obj, "/customer/:cid/*", "cid"), p.dom )

When I try to call enforce it throws a ClassCastException.

java.lang.ClassCastException: <String, > is not a javaType

	at com.googlecode.aviator.runtime.function.FunctionUtils.getJavaObject(FunctionUtils.java:107)
	at org.casbin.jcasbin.util.BuiltInFunctions$1.variadicCall(BuiltInFunctions.java:354)
	at com.googlecode.aviator.runtime.function.AbstractVariadicFunction.call(AbstractVariadicFunction.java:71)
	at Script_1644402524748_59/70807318.execute0(Script_1644402524748_59:1)
	at com.googlecode.aviator.ClassExpression.executeDirectly(ClassExpression.java:44)
	at com.googlecode.aviator.BaseExpression.execute(BaseExpression.java:237)
	at org.casbin.jcasbin.main.CoreEnforcer.enforce(CoreEnforcer.java:478)
	at org.casbin.jcasbin.main.CoreEnforcer.enforce(CoreEnforcer.java:590)
	at com.w.platform.rbac.MCEnforcer.enforce(MCEnforcer.java:95)

I made some investigation myself, I found that the g(rouping)-function expects that the arguments are AviatorJavaObjects (fx. p.dom) and just fails when it receives a raw string. But keyGet2 returns string so it feels that it is impossible to use keyGet2 within a group match function.

PS. the exact same configuration: same policies, groups, model, request works as intended in the online editor, https://casbin.org/en/editor/