Social authentication for websites that don't provide any.
Overview
This project will both describe:
- a protocol to authenticate users from any website on your software, regardless they provide social authentication feature,
- a Node.js library to ease the implementation.
Protocol
An user wants to authenticate on your website with his example.com username.
-
They fill a form with the username they want to authenticate with.
-
You generates a nonce, and store it in some kind of session (like signed cookies) for this user, together with the username they want to authenticate.
-
The user is then told to paste this "verification code" (the nonce) somewhere on example.com where they can easily be identified, that may be in a private message to a "bot" user you own, in teir profile description, or whatever is possible on the website.
-
When the use is done, they confirm it to your website (optionally providing some data so you can easily find the key if it's not ovbious), which will search the expected location for the nonce.
-
If the nonce is found, and it was effectively posted by the user in question, the user is a authenticated, and you can be sure they own the example.com account they claimed.
Also, note you could add some time limit to complete the authentication, for exmaple by storing the current time in session when the authentication request is made (when the nonce is generated), and checking it before verifying the nonce.
Library
Example with an Express web app.
// Default settings.const auth = // Extend settings.const auth = // example.com imaginary API/crawler.const example = const app = const then = appappapp // Request user authentication.app // Verify authentication.app // Regular page.app
Example
See jvc-auth for a practical usage example.