Building an SSO from scratch