rewrite xsrf generation