I'm using GWT 2.10.0, and I'd like to deactivate the RPC token only during development, but have it activated in production. Any suggestions on how I can achieve this?
Thank you.
I'm using GWT 2.10.0, and I'd like to deactivate the RPC token only during development, but have it activated in production. Any suggestions on how I can achieve this?
Thank you.
Copyright © 2021 Jogjafile Inc.
It isn't quite clear what you're asking or how you've implemented your own token approach already, so to restate, you have a
com.google.gwt.user.client.rpc.RpcTokenimplementation that can be serialized, and acom.google.gwt.user.server.rpc.XsrfProtectannotation on your RemoteService type. Then you extendedXsrfProtectedServiceServletto provide your server-side implementation of theRemoteService.XsrfProtectedServiceServletextendsAbstractXsrfProtectedServiceServlet, which extendsRemoteServiceServletitself.RemoteServiceServlet provides an empty methodonAfterRequestDeserializedthat can be overridden, andAbstractXsrfProtectedServiceServlet` provides a simple implementation, shared below:Then
AbstractXsrfProtectedServiceServletprovides a simple protected implementation ofshouldValidateXsrfToken, but leavesvalidateXsrfTokenabstract, so that your superclass,XsrfProtectedServiceServlet, can override it. Both of these seem like a reasonable extension point to provide custom functionality - you can override either method, and if you determine you are running in production, call super, otherwise if you are in development/test, ignore the rest of the check and simply return success.For example, assuming you have a
isRunningInProduction()method (up to you to implement, either of these should solve your problem:or
Note that providing both will also work, but only
shouldValidateXsrfTokenwill ever be called.