@ Override public Result call ( AddCSRFToken configuration , RequestContext context ) throws Exception { if ( csrf . eligibleForCSRF ( context . context ( ) ) && ( csrf . extractTokenFromRequest ( context . context ( ) ) == null || configuration . newTokenOnEachRequest ( ) ) ) { // Generate a new token, it will be stored in the request scope. String token = csrf . generateToken ( context . context ( ) ) ; // Add it to the response return csrf . addTokenToResult ( context . context ( ) , token , context . proceed ( ) ) ; } else { return context . proceed ( ) ; } }
Injects a CSRF token into the result if the request is eligible .