and I've put it in the ignition/lib/core/common folder, gateway is restarted.
I'm trying to start testing functionality:
from com.auth0.jwt import *
But I get this error:
ImportError: No module named auth0
I know the proper way is to create an ignition module but we're not that familiar with java and never did such a thing so for now I just want to get something working and then look at a more permanent/better solution.
and rebooted gateway/designer and I'm still getting the same result.
If there's another JWT Lib that you know works would also be helpfull.
All I need is to verify a JWT, so validate signature and decode the base 64 to check scope and expiry
I might be able to do the same with a crypto and base 64 lib
I think you also need jackson-annotations-2.15.4.jar.
I just gave this a try and it worked for me
Added these 4 JAR files to lib/core/common, restarted Gateway, launched new Designer:
kevin@DV-55J5DY3-LT ~/D/m/t/dependency> ls -lh
total 2.3M
-rw-r--r--. 1 kevin kevin 74K Feb 15 2024 jackson-annotations-2.15.4.jar
-rw-r--r--. 1 kevin kevin 536K Feb 15 2024 jackson-core-2.15.4.jar
-rw-r--r--. 1 kevin kevin 1.6M Feb 15 2024 jackson-databind-2.15.4.jar
-rw-r--r--. 1 kevin kevin 63K Jan 29 06:39 java-jwt-4.5.0.jar
In the script console:
from com.auth0.jwt import JWT
JWT.decode("")
(which obviously errors out, but shows the library is loaded)
Java Traceback:
Traceback (most recent call last):
File "<input>", line 3, in <module>
at com.auth0.jwt.TokenUtils.wrongNumberOfParts(TokenUtils.java:45)
at com.auth0.jwt.TokenUtils.splitToken(TokenUtils.java:23)
at com.auth0.jwt.JWTDecoder.<init>(JWTDecoder.java:37)
at com.auth0.jwt.JWTDecoder.<init>(JWTDecoder.java:33)
at com.auth0.jwt.JWT.decode(JWT.java:52)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
com.auth0.jwt.exceptions.JWTDecodeException: com.auth0.jwt.exceptions.JWTDecodeException: The token was expected to have 3 parts, but got 0.
at org.python.core.Py.JavaError(Py.java:545)
at org.python.core.Py.JavaError(Py.java:536)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:192)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:208)
at org.python.core.PyObject.__call__(PyObject.java:461)
at org.python.core.PyObject.__call__(PyObject.java:465)
at org.python.pycode._pyx11.f$0(<input>:3)
at org.python.pycode._pyx11.call_function(<input>)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1703)
at org.python.core.Py.exec(Py.java:1747)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:277)
at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:130)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:628)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:616)
at java.desktop/javax.swing.SwingWorker$1.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.desktop/javax.swing.SwingWorker.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: com.auth0.jwt.exceptions.JWTDecodeException: The token was expected to have 3 parts, but got 0.
at com.auth0.jwt.TokenUtils.wrongNumberOfParts(TokenUtils.java:45)
at com.auth0.jwt.TokenUtils.splitToken(TokenUtils.java:23)
at com.auth0.jwt.JWTDecoder.<init>(JWTDecoder.java:37)
at com.auth0.jwt.JWTDecoder.<init>(JWTDecoder.java:33)
at com.auth0.jwt.JWT.decode(JWT.java:52)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
... 19 more
Traceback (most recent call last):
File "<input>", line 3, in <module>
at com.auth0.jwt.TokenUtils.wrongNumberOfParts(TokenUtils.java:45)
at com.auth0.jwt.TokenUtils.splitToken(TokenUtils.java:23)
at com.auth0.jwt.JWTDecoder.<init>(JWTDecoder.java:37)
at com.auth0.jwt.JWTDecoder.<init>(JWTDecoder.java:33)
at com.auth0.jwt.JWT.decode(JWT.java:52)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
com.auth0.jwt.exceptions.JWTDecodeException: com.auth0.jwt.exceptions.JWTDecodeException: The token was expected to have 3 parts, but got 0.
>>>
Just keep in mind you'll have to repeat this procedure any time you upgrade Ignition. These lib/core/* directories are wiped out and replaced during the upgrade.