refactor authentication plugins