rewriting authentication