Skip to content

Change passport-github to passport-github2 and @octokit/rest to v18 - #211

Merged
danielbeardsley merged 38 commits into
masterfrom
update-github-passport-to-alternative-v2
Aug 11, 2021
Merged

Change passport-github to passport-github2 and @octokit/rest to v18#211
danielbeardsley merged 38 commits into
masterfrom
update-github-passport-to-alternative-v2

Conversation

@addison-grant

@addison-grant addison-grant commented May 5, 2021

Copy link
Copy Markdown

This library seems popular and claims to use a different auth method
that I think will bandaid our current brownout issue.

New package: https://github.com/cfsghost/passport-github
Deprecation notice: (Links to original notice)
https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/


Changes made:

  1. Removed the usage of the npm package passport-github in favor of passport-github2
  2. Updated the npm package @octokit/rest to v18
  3. By updating @octokit/rest , the function calls in lib/git-manager.js had to be updated to reflect the new function calls that call the same endpoints (Change passport-github to passport-github2 and @octokit/rest to v18 #211 (comment)). Also had to update the checkOrgMembershipRequirements function in lib/authentication.js
  4. Removed the use of the rate-limit function as the plugin @octokit/plugin-throttling now allows for the GitHub API object to throttle itself (https://github.com/octokit/plugin-throttling.js#readme)
  5. Removed the use of the paginate function as @octokit/rest v18 now has its own pagination function.

QA

You can run update-pulldasher on cominor with a clone of this repo with this branch checked out, and check out https://pulldasher.cominor.com. Look around pulldasher, let it run throughout the day and make sure the cards reflect the state of their PRs at the end of the day.

Associated issue: #210

This library seems popular and claims to use a different auth method
that I think will bandaid our current brownout issue.

New package: https://github.com/cfsghost/passport-github
Deprecation notice: (Links to original notice)
https://developer.github.com/changes/2020-02-10-deprecating-auth-through-query-param/
@addison-grant

Copy link
Copy Markdown
Author

Need to test this out. I checked the library and it seemed legit, as in didn't notice anything that seemed bad...can a couple other people double-check?

@addison-grant

Copy link
Copy Markdown
Author

Wasn't a silver bullet, sadly.

@addison-grant

Copy link
Copy Markdown
Author

dev_block ☀️ I think this might be needed, but there's more changes needed, as well.

@addison-grant addison-grant reopened this May 5, 2021
@ardelato

ardelato commented May 5, 2021

Copy link
Copy Markdown
Contributor

Test Comment -- Webhook

@addison-grant addison-grant left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test

Comment thread lib/authentication.js
@addison-grant addison-grant changed the title Use alternative library for passport-github Change passport-github to passport-github2 and @octokit/rest to v18 May 5, 2021
@addison-grant

Copy link
Copy Markdown
Author

The test comments were to test out comment webhooks.

@addison-grant

Copy link
Copy Markdown
Author

Some relevant docs:

https://octokit.github.io/rest.js/v18

Comment thread lib/git-manager.js Outdated
Comment thread lib/git-manager.js Outdated
Comment thread lib/git-manager.js
Comment thread lib/git-manager.js Outdated
Comment thread lib/authentication.js Outdated
@danielbeardsley

Copy link
Copy Markdown
Member

Thanks @addison-grant for working on this!!

Comment thread package.json
"notify-queue": "0.0.5",
"passport": "^0.4.0",
"passport-github": "1.1.0",
"passport-github2": "^0.1.12",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked through the diff between passport-github and passport-github2, and it looks totally reasonable. I'm not quite sure how hard we want to version lock this; I'm nervous about the fact that this is one semi-random guy's fork.

@andyg0808 andyg0808 Jun 9, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(when I say "how hard we want to version lock this", I mean "do we want to use a version like

Suggested change
"passport-github2": "^0.1.12",
"passport-github2": "0.1.12",

which won't allow any other version to be used" (although I don't think it prevents malicious uploads over 0.1.12 on NPM).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package looks pretty small, actually, looking over at https://github.com/cfsghost/passport-github/tree/master/lib. I wonder if we would want to fork passport-github2, take a little time to understand it, and install from our fork.

Comment thread lib/git-manager.js Outdated
Comment thread lib/git-manager.js Outdated
Comment thread lib/git-manager.js
function getCommit(repo, sha) {
return rateLimit(github.repos.getCommit)(params({ sha }, repo))
.then(res => res.data);
return githubRest.repos.getCommit(params({ ref: sha }, repo)).then(res => res.data);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the res.data still needed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure...I'll look into this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is still needed because we need the data property off the response. Was there a particular reason you thought we don't need it?

Comment thread lib/git-manager.js
debug("Getting commit status for %s", ref);
return rateLimit(github.repos.getCombinedStatusForRef)(params({ ref }, repo))
return githubRest.repos.getCombinedStatusForRef(params({ ref }, repo))
.then(res => res.data.statuses)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the res.data still needed here as well?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, will investigate

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is still needed because we need the particular sub-property off the response. Was there a particular reason you thought we don't need it?

@andyg0808

Copy link
Copy Markdown
Contributor

CR 🐟 through 5dca5e7
deploy_block 👍 on comments.

addison-grant and others added 6 commits June 9, 2021 08:30
Co-authored-by: Andrew Gilbert <andrewg@ifixit.com>
We want to keep the colors around because it's a great indication as to
how old the pulls are at a glance. Let's match the colors to the
preexisting colors that we use on the pull cards.

QA:
--
Make sure the colors look good
Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.4.7 to 1.5.1.
- [Release notes](https://github.com/unshiftio/url-parse/releases)
- [Commits](unshiftio/url-parse@1.4.7...1.5.1)

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [underscore](https://github.com/jashkenas/underscore) from 1.9.1 to 1.12.1.
- [Release notes](https://github.com/jashkenas/underscore/releases)
- [Commits](jashkenas/underscore@1.9.1...1.12.1)

Signed-off-by: dependabot[bot] <support@github.com>
@addison-grant addison-grant reopened this Jun 15, 2021
@ardelato ardelato added QAing Under QA team review and removed QAing Under QA team review labels Jun 17, 2021
Comment thread lib/authentication.js
github = require('./git-manager').github,
passport = require('passport'),
_ = require('underscore'),
GitHubStrategy = require('passport-github').Strategy;

@deltuh-vee deltuh-vee Jul 16, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test dev_block 👍

hello -Addison

Comment thread lib/authentication.js Outdated
const getTeamId = github.orgs.getTeams({org: config.github.requireOrg})

// `github` here is octokit.rest imported from git-manager
const getTeamId = github.teams.list({org: config.github.requireOrg})

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to test a pull_request_review event

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A single comment on a diff

@danielbeardsley

Copy link
Copy Markdown
Member

I'm a little worried why there are commits in here from dependabot. I'm gonna look at the commit history.

@danielbeardsley

Copy link
Copy Markdown
Member

Update: Those exact commit hashes are already on master and github's diff is just showing the wrong thing.

Comment thread lib/authentication.js Outdated
New github octokit has new api options and the team stuff no longer
requires a teamid and can jut work with the team name.
New api call returns data for single-record requests under the data
key. Other endpoints were updated, but this one was missed.
It was using the wrong api after updating to the new octokit.
@danielbeardsley

Copy link
Copy Markdown
Member

Working on this. Still more to review.

I think this was introduced accidentally in a recent merge.
The prototype function references a ._then property that didn't exist on
github promises, so let's just cast each one to a bluebird promise
before calling done.
@danielbeardsley

Copy link
Copy Markdown
Member

QA 👍

Verified this with @addison-grant ! It lives!

@danielbeardsley

Copy link
Copy Markdown
Member

CR 👍

@danielbeardsley
danielbeardsley merged commit 12a29dd into master Aug 11, 2021
@danielbeardsley
danielbeardsley deleted the update-github-passport-to-alternative-v2 branch March 19, 2022 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants