quarkus-google-cloud-services icon indicating copy to clipboard operation
quarkus-google-cloud-services copied to clipboard

SecurityIdentity identity is not an instanceof JsonWebToken

Open NickPaul41 opened this issue 11 months ago • 0 comments

The example code for getting a JsonWebToken does not seem to work. firebase-admin

@Path("/app")
public class FirebaseAppResource {

    @Inject
    FirebaseApp firebaseApp;

    @Inject
    SecurityIdentity identity;

    @GET
    @Path("/options")
    @Produces(MediaType.APPLICATION_JSON)
    public FirebaseOptions getOptions() {
        if(identity instanceof JsonWebToken) {
            System.out.println("JWT: " + ((JsonWebToken) identity).getClaim("email"));
        }

        return firebaseApp.getOptions();
    }

}

When debugging my project identity is not an instanceof JsonWebToken.

I'm able to do a workaround by casting identity.getPrincipal() to a FirebasePrincipal.

@GET
    @Produces(MediaType.APPLICATION_JSON)
    public FirebaseOptions getOptions() {
        FirebasePrincipal fbp;
        if(identity.getPrincipal() instanceof FirebasePrincipal) {
            fbp = (FirebasePrincipal) identity.getPrincipal();
            System.out.println("FirebasePrincipal: " + fbp.getClaim("email"));
        }

        return firebaseApp.getOptions();
    }

Is this an issue with the documentation or should identity be an instance of JsonWebToken?

NickPaul41 avatar Mar 08 '24 18:03 NickPaul41