Open ygyg70 opened 1 year ago
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Is there any update on this? I am struggling with a native image build since adding the firebase-admin
dependency.
Is there any update on this?
Is there any update on this?
This is error i am getting:
[INFO] [creator] Jan 07, 2024 9:07:06 PM com.google.api.gax.nativeimage.NativeImageUtils registerClassForReflection [INFO] [creator] WARNING: Failed to find io.grpc.netty.shaded.io.netty.channel.ProtocolNegotiators on the classpath for reflection.
Hi everyone,
I've been working on GraalVM native image support for Spring Boot applications using Firebase Cloud Messaging (FCM) and wanted to share two projects that could help those facing similar challenges with native image compatibility:
Both projects demonstrate how to configure Spring Boot applications with FCM and make them GraalVM native image compatible, including handling reflection and other related issues. These might be helpful as examples or starting points for your own projects. Feel free to explore them and share feedback!
Hello everyone. @waileong specially hi for you :) I am having issues while validating a Firebase Auth idToken using the firebase admin sdk. When I compile as native, it works fine, the app boots up, but when it gets the first request it throws an error:
java.lang.NullPointerException: Failed to load: admin_sdk.properties
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:924) ~[na:na]
at com.google.firebase.internal.SdkUtils.loadSdkVersion(SdkUtils.java:46) ~[na:na]
at com.google.firebase.internal.SdkUtils.
I want to note that I am using the tenant manager as I am not using the default tenant in my GCP Project.
@Component public class FirebaseAuthenticationFilter extends OncePerRequestFilter {
@Autowired
FirebaseAuthConfiguration firebaseAuthConfiguration;
@Override
protected void doFilterInternal(
HttpServletRequest request,
HttpServletResponse response,
FilterChain filterChain)
throws ServletException, IOException {
String idToken = request.getHeader("Authorization");
if (idToken == null || idToken.isEmpty()) {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Missing Authorization token");
return;
}
try {
FirebaseToken token =
FirebaseAuth.getInstance().
getTenantManager().getAuthForTenant(firebaseAuthConfiguration.getTenantId())
.verifyIdToken(idToken.replace("Bearer ", ""));
List<GrantedAuthority> authorities = getAuthoritiesFromToken(token);
SecurityContextHolder.getContext()
.setAuthentication(
new FirebaseAuthenticationToken(idToken, token, authorities));
SecurityContextHolder.getContext().getAuthentication().setAuthenticated(true);
} catch (Exception e) {
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Invalid Firebase ID-Token");
return;
}
filterChain.doFilter(request, response);
}
Does anyone have any idea of how to make it work?
Is your feature request related to a problem? Please describe. Notifications are not sent when run as a native image. I was able to use the library after adding reflection configuration for these classes: Message.class, Notification.class, AndroidConfig.class, AndroidNotification.class, AndroidFcmOptions.class, WebpushConfig.class, WebpushFcmOptions.class, WebpushNotification.class, ApnsConfig.class, ApnsFcmOptions.class, ApsAlert.class, FcmOptions.class, MessagingServiceResponse.class, MessagingServiceErrorResponse.class
Describe the solution you'd like Add reflect-config.json file to the project
Describe alternatives you've considered Document how to achieve native image compatibility