quarkiverse / quarkus-google-cloud-services

Google Cloud Services Quarkus Extensions
https://docs.quarkiverse.io/quarkus-google-cloud-services/main/index.html
Apache License 2.0
53 stars 32 forks source link

SecurityIdentity identity is not an instanceof JsonWebToken #592

Open NickPaul41 opened 4 months ago

NickPaul41 commented 4 months ago

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?