zkitter / zkitterd

MIT License
10 stars 2 forks source link

feat: use passport for github, reddit, twitter auth #54

Closed sripwoud closed 1 year ago

sripwoud commented 2 years ago

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.

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:

  1. Go to
    http://127.0.0.1:3000/auth/<provider>?redirectUrl=http%3A%2F%2F127.0.0.1%3A3000%2Fauth%2Fsession

  2. Authorize application

  3. You're redirected to /auth/session endpoints that displays a response like:

    {
     payload: {
       token,
       provider,
       username,
       reputation
     }
    }

    You can also manually check that a record was inserted in the auths table

  4. Go to http://127.0.0.1:3000/auth/logout You are successfully logged out

    { payload: 'ok' }
  5. Go to http://127.0.0.1:3000/auth/session Expected error:

    { "error": "not authenticated" }
  6. 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.