WIP: refactor auth-server
WIP: more refactor