Handle authentication from github, reddit and twitter with passportjs.
Define a new Auth Router with the following routes:
Routes
|route|description|response|
|---|---|---|
|/auth/github?redirectUrl|Authenticate via Github|Redirects to GH auth page|
|/auth/github/callback||redirects to `redirectUrl`|
|/auth/reddit|Authenticate via Reddit|Redirects to Reddit auth page|
|/auth/reddit/callback||redirects to `redirectUrl`|
|/auth/twitter|Authenticate via Twitter|redirects to Twitter auth page|
|/auth/twitter/callback||redirects to `redirectUrl`|
|/auth/logout|destroys users session (session endpoint not accessible anymore)|`{ payload: 'ok'}`|
|/auth/session|returns all the parameters required to join an interep group **only if the user is authenticated**|`{ provider, token, username, reputation }`|
Define a new auth model table with provider, token, userId columns
Test plan
First make sure you have all the required config settings
Config
```
"ghPat": "obtain from https://github.com/settings/profile",
"ghCallbackUrl": "define in https://github.com/organizations/zkitter/settings/applications",
"ghClientId": "define in https://github.com/organizations/zkitter/settings/applications",
"ghClientSecret": "define in https://github.com/organizations/zkitter/settings/applications",
"rdCallbackUrl": "set in https://www.reddit.com/prefs/apps",
"rdClientId": "set in https://www.reddit.com/prefs/apps",
"rdClientSecret": "set in https://www.reddit.com/prefs/apps",
"twCallbackUrl": "obtain from twitter dev dashboard",
"twClientId": "obtain from twitter dev dashboard (oauth 2)",
"twClientSecret": "obtain from twitter dev dashboard (oauth 2)",
"twConsumerKey": "obtain from twitter dev dashboard",
"twConsumerSecret": "obtain from twitter dev dashboard",
"twBearerToken": "obtain from twitter dev dashboard",
"twAccessKey": "obtain from twitter dev dashboard",
"twAccessSecret": "obtain from twitter dev dashboard",
"rapidAPIKey": "obtain from rapid api dashboard",
```
Then for provider in [github, reddit, twitter], repeat the following steps:
Go to http://127.0.0.1:3000/auth/<provider>?redirectUrl=http%3A%2F%2F127.0.0.1%3A3000%2Fauth%2Fsession
Authorize application
You're redirected to /auth/session endpoints that displays a response like:
To deploy this, there are a few additional config settings that need to be defined.
Closes #29, closes #50, closes #55
Handle authentication from github, reddit and twitter with passportjs.
Define a new
Auth
Router with the following routes:Routes
|route|description|response| |---|---|---| |/auth/github?redirectUrl|Authenticate via Github|Redirects to GH auth page| |/auth/github/callback||redirects to `redirectUrl`| |/auth/reddit|Authenticate via Reddit|Redirects to Reddit auth page| |/auth/reddit/callback||redirects to `redirectUrl`| |/auth/twitter|Authenticate via Twitter|redirects to Twitter auth page| |/auth/twitter/callback||redirects to `redirectUrl`| |/auth/logout|destroys users session (session endpoint not accessible anymore)|`{ payload: 'ok'}`| |/auth/session|returns all the parameters required to join an interep group **only if the user is authenticated**|`{ provider, token, username, reputation }`|
Define a new
auth
model table withprovider
,token
,userId
columnsTest plan
First make sure you have all the required config settings
Config
``` "ghPat": "obtain from https://github.com/settings/profile", "ghCallbackUrl": "define in https://github.com/organizations/zkitter/settings/applications", "ghClientId": "define in https://github.com/organizations/zkitter/settings/applications", "ghClientSecret": "define in https://github.com/organizations/zkitter/settings/applications", "rdCallbackUrl": "set in https://www.reddit.com/prefs/apps", "rdClientId": "set in https://www.reddit.com/prefs/apps", "rdClientSecret": "set in https://www.reddit.com/prefs/apps", "twCallbackUrl": "obtain from twitter dev dashboard", "twClientId": "obtain from twitter dev dashboard (oauth 2)", "twClientSecret": "obtain from twitter dev dashboard (oauth 2)", "twConsumerKey": "obtain from twitter dev dashboard", "twConsumerSecret": "obtain from twitter dev dashboard", "twBearerToken": "obtain from twitter dev dashboard", "twAccessKey": "obtain from twitter dev dashboard", "twAccessSecret": "obtain from twitter dev dashboard", "rapidAPIKey": "obtain from rapid api dashboard", ```
Then for
provider
in[github, reddit, twitter]
, repeat the following steps:Go to
http://127.0.0.1:3000/auth/<provider>?redirectUrl=http%3A%2F%2F127.0.0.1%3A3000%2Fauth%2Fsession
Authorize application
You're redirected to
/auth/session
endpoints that displays a response like:You can also manually check that a record was inserted in the
auths
tableGo to
http://127.0.0.1:3000/auth/logout
You are successfully logged outGo to
http://127.0.0.1:3000/auth/session
Expected error:Start back from step 1 with a different provider
Comments
Let's keep the old (to be legacy) twitter auth endpoints until UI integration confirms that everything works correctly.