'Quarkus Auth Server Disable JWT Issue

i wish to disable the auth server when running in dev mode, which I am able to do so with %dev.quarkus.oidc.enabled=false . But it causes an exception given below. I had pulled the code from https://github.com/quarkusio/quarkus-quickstarts/tree/master/security-openid-connect-web-authentication-quickstart and made the change of oidc.enabled=false in app.properties. Anyone knows what I am doing wrong?

Caused by: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type org.eclipse.microprofile.jwt.JsonWebToken and qualifiers [@Default] - java member: com.xxx.UserProfileEndpoint#jwt - declared on CLASS bean [types=[com.xxx.UserProfileEndpoint, java.lang.Object], qualifiers=[@Default, @Any], target=com.xxxx.UserProfileEndpoint]



Solution 1:[1]

In this case you should also inject JsonWebToken as Instance<JsonWebToken>

Solution 2:[2]

Manage to find a way to workaround it.

I needed the JWT to get the username and roles only...

So instead of using

@Inject
JsonWebToken jwt;

Just use:

@Inject
SecurityIdentity securityIdentity;

        if (securityIdentity.isAnonymous()) {
            // Only occurs in Dev Mode when "quarkus.oidc.enabled" is set to false
            name = "defaultUser";
            roles = new HashSet<>();
        } else {
            // When token is provided
            name = securityIdentity.getPrincipal().getName();
            roles = securityIdentity.getRoles();
        }

You're welcome! sunglasses

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sergey Beryozkin
Solution 2 Katone Vi