vert-x3 / vertx-rx

Reactive Extensions for Vert.x
Apache License 2.0
147 stars 73 forks source link

vertx rxjava3 vertx-jwt-auth rxAuthenticate Exception #296

Closed doubleyeh closed 1 year ago

doubleyeh commented 1 year ago

Questions

vertx rxjava3 vertx-jwt-auth rxAuthenticate Exception

Version

vertx 4.4.4 rxjava3

pom.xml ` <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0 cn.mok vertxdemo 1.0.0-SNAPSHOT UTF-8 1.8 1.8 3.8.1 3.2.4 3.1.2 3.0.0 2.15.2 4.4.4 3.0.13 5.9.1 cn.mok.vertxdemo.MainVerticle cn.mok.vertxdemo.MainVerticle io.vertx.core.Launcher io.vertx vertx-stack-depchain ${vertx.version} pom import io.vertx vertx-web io.vertx vertx-pg-client io.vertx vertx-rx-java3 io.vertx vertx-redis-client io.reactivex.rxjava3 rxjava ${rxjava3.version} com.fasterxml.jackson.core jackson-databind ${jackson.version} com.fasterxml.jackson.datatype jackson-datatype-jsr310 ${jackson.version} org.projectlombok lombok 1.18.28 true io.vertx vertx-config io.vertx vertx-auth-jwt com.ongres.scram client 2.1 org.slf4j slf4j-api 1.7.32 ch.qos.logback logback-classic 1.2.6 org.mindrot jbcrypt 0.4 io.vertx vertx-junit5 test org.junit.jupiter junit-jupiter-api ${junit-jupiter.version} test org.junit.jupiter junit-jupiter-engine ${junit-jupiter.version} test org.apache.maven.plugins maven-compiler-plugin ${maven-compiler-plugin.version} org.apache.maven.plugins maven-shade-plugin ${maven-shade-plugin.version} package shade ${launcher.class} ${main.verticle} ${project.build.directory}/${project.artifactId}-${project.version}-fat.jar org.apache.maven.plugins maven-surefire-plugin ${maven-surefire-plugin.version} org.codehaus.mojo exec-maven-plugin ${exec-maven-plugin.version} io.vertx.core.Launcher run ${main.verticle} io.reactiverse vertx-maven-plugin 1.0.28 vmp initialize package true

`

Context

` generateToken
JsonObject tokenData = new JsonObject() .put("userId", u.getId()).put("username", username) .put("nickname", u.getNickName()) .put("iat", Long.valueOf(System.currentTimeMillis() / 1000)) .put("exp", Long.valueOf((System.currentTimeMillis() + 3600) / 1000)); msg.reply(Jwt.getAuth().generateToken(tokenData));

rxAuthenticate

Jwt.getAuth().rxAuthenticate(new TokenCredentials(res.body().toString())) .subscribe(user -> { System.out.println("Token is valid. User: " + user.principal().getString("sub")); }, error -> { error.printStackTrace(); System.out.println("Token is invalid. Error: " + error.getMessage()); }); `

Do you have a reproducer?

' java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap') at io.vertx.core.json.JsonObject.getLong(JsonObject.java:493) at io.vertx.core.json.JsonObject.getLong(JsonObject.java:757) at io.vertx.ext.auth.User.expired(User.java:168) at io.vertx.ext.auth.jwt.impl.JWTAuthProviderImpl.authenticate(JWTAuthProviderImpl.java:184) at io.vertx.ext.auth.authentication.AuthenticationProvider.authenticate(AuthenticationProvider.java:109) at io.vertx.rxjava3.ext.auth.authentication.AuthenticationProvider.lambda$rxAuthenticate$6(AuthenticationProvider.java:172) at io.vertx.rxjava3.impl.AsyncResultSingle.subscribeActual(AsyncResultSingle.java:56) at io.reactivex.rxjava3.core.Single.subscribe(Single.java:4813) at io.reactivex.rxjava3.core.Single.subscribe(Single.java:4799) at cn.mok.vertxdemo.router.UserVerticle.lambda$5(UserVerticle.java:61) at io.reactivex.rxjava3.internal.observers.ConsumerSingleObserver.onSuccess(ConsumerSingleObserver.java:62) at io.vertx.rxjava3.impl.AsyncResultSingle.lambda$subscribeActual$0(AsyncResultSingle.java:60) at io.vertx.lang.rx.DelegatingHandler.handle(DelegatingHandler.java:20) at io.vertx.core.impl.future.FutureImpl$3.onSuccess(FutureImpl.java:141) at io.vertx.core.impl.future.FutureBase.lambda$emitSuccess$0(FutureBase.java:54) at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:86) at io.vertx.core.impl.DuplicatedContext.execute(DuplicatedContext.java:163) at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:51) at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211) at io.vertx.core.impl.future.PromiseImpl.tryComplete(PromiseImpl.java:23) at io.vertx.core.Promise.complete(Promise.java:66) at io.vertx.core.eventbus.impl.ReplyHandler.dispatch(ReplyHandler.java:97) at io.vertx.core.eventbus.impl.HandlerRegistration$InboundDeliveryContext.execute(HandlerRegistration.java:137) at io.vertx.core.eventbus.impl.DeliveryContextBase.next(DeliveryContextBase.java:72) at io.vertx.core.eventbus.impl.DeliveryContextBase.dispatch(DeliveryContextBase.java:43) at io.vertx.core.eventbus.impl.HandlerRegistration.dispatch(HandlerRegistration.java:98) at io.vertx.core.eventbus.impl.ReplyHandler.doReceive(ReplyHandler.java:81) at io.vertx.core.eventbus.impl.HandlerRegistration.lambda$receive$0(HandlerRegistration.java:49) at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:833) Token is invalid. Error: class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap') '

Extra

doubleyeh commented 1 year ago

it's customer jackson long serializer/deserializer