Little late to the party but have you considered using something like an authorization server?<p>We created Anvil Connect (based on OAuth 2.0 and OpenID Connect) to solve a bundle of auth-related problems all at once. It&#x27;s a separate server instead of a library, because once you need to share user accounts between several apps (think different platforms) the complexity increases dramatically. There are (third party) client libraries available for a number of languages.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;anvilresearch&#x2F;connect" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;anvilresearch&#x2F;connect</a>