Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JWT+REST Client+OT: SecurityIdentityProxy exception popping up #39667

Closed
Karm opened this issue Mar 25, 2024 · 4 comments · Fixed by #40466
Closed

JWT+REST Client+OT: SecurityIdentityProxy exception popping up #39667

Karm opened this issue Mar 25, 2024 · 4 comments · Fixed by #40466

Comments

@Karm
Copy link
Member

Karm commented Mar 25, 2024

Describe the bug

When I migrated a small test app from Jaeger to OpenTelemetry, a new exception has started to pop up in the log.
Note that this is a tiny test app, mushing together client and server, initiating a REST Client call from within an already ongoing request. Perhaps that could be a part of the issue. I am fine refactoring the app, but it's not obvious to me if this is indeed an expected behavior. Despite "Security" keyword in the exception, I do not thing there is any immediate security implication at hand.

Expected behavior

There is no error in the log.

Actual behavior

ERROR [org.jbo.thr.errors] (executor-thread-1) Thread Thread[#36,executor-thread-1,5,main] threw an uncaught exception: jakarta.enterprise.context.ContextNotActiveException: RequestScoped context was not active when trying to obtain a bean instance for a client proxy of CLASS bean [class=io.quarkus.security.runtime.SecurityIdentityProxy, id=U3fuB4yO9MSr82V2xU36xFn98dk]
    - you can activate the request context for a specific method using the @ActivateRequestContext interceptor binding
    at io.quarkus.arc.impl.ClientProxies.notActive(ClientProxies.java:70)
    at io.quarkus.arc.impl.ClientProxies.getSingleContextDelegate(ClientProxies.java:30)
    at io.quarkus.security.runtime.SecurityIdentityProxy_ClientProxy.arc$delegate(Unknown Source)
    at io.quarkus.security.runtime.SecurityIdentityProxy_ClientProxy.isAnonymous(Unknown Source)
    at io.quarkus.opentelemetry.runtime.exporter.otlp.EndUserSpanProcessor.lambda$onStart$0(EndUserSpanProcessor.java:31)
    at io.smallrye.context.impl.wrappers.SlowContextualRunnable.run(SlowContextualRunnable.java:19)
    at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:587)
    at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
    at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
    at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:1583)

How to Reproduce?

$ git clone https://github.com/Karm/dev-null
$ cd dev-null/reproducer87326/
$ mvn clean package
$ java -jar target/quarkus-app/quarkus-run.jar 

Then in a separate terminal, trivial, one client connection at a time:

$ while [ 1 ];do curl http://0.0.0.0:8080/secured/test;done 

You can run the OT collector too, but it doesn't seem to be necessary to see the issue:

$ docker run -p 127.0.0.1:4317:4317   -p 127.0.0.1:55679:55679 otel/opentelemetry-collector:0.96.0 

The correct expected result of the call is:

Claim value within JWT of 'custom-value' : PROTECTED: My value

Note that the call works fine, it's the exception in the log that is...unexpected.

Output of uname -a or ver

Linux amd64, 5.14.0-425.el9.x86_64

Output of java -version

21.0.1

Quarkus version or git rev

3.8.0, 3.8.3, 3.9.0

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae) Maven home: /home/karm/Tools/apache-maven-3.9.6 Java version: 21.0.1-beta, vendor: Eclipse Adoptium, runtime: /var/X/JDKs/jdk-21.0.1+12 Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "5.14.0-425.el9.x86_64", arch: "amd64", family: "unix"

Additional information

No response

Copy link

quarkus-bot bot commented Mar 25, 2024

/cc @cescoffier (rest-client), @geoand (rest-client), @sberyozkin (jwt,security)

@Karm Karm changed the title JWT+REST Client+OT: io.quarkus.security.runtime.SecurityIdentityProxy exception popping up JWT+REST Client+OT: SecurityIdentityProxy exception popping up Mar 25, 2024
@sberyozkin
Copy link
Member

sberyozkin commented Mar 25, 2024

This is probably related to #39563, where a context issue is also reported in the OT attempting to access the security identity, @michalvavrik FYI

@michalvavrik
Copy link
Member

Absolutely, thanks for reporting it. I have fix in progress and @brunobat is planning to remove the feature with #39648

@michalvavrik
Copy link
Member

fixed #40466

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants