[WIP] [Question] Add a token to badges for private repos#286
[WIP] [Question] Add a token to badges for private repos#286valeriangalliat wants to merge 4 commits into
Conversation
|
Hey @valeriangalliat, this is amazing! Thank you for taking the time to work on this. I'm going to review and merge as soon as I can, sorry I haven't had a chance to yet! :) |
|
Hi @alanshaw, any updates on this? This would be awesome! Thanks @valeriangalliat for putting in this work! |
|
@alanshaw - Same general question. It would be awesome to be able to use this in my private "work related" repos as well as the public ones. |
|
@alanshaw likewise, I am interested to know if there's any update on this PR. Thanks all |
|
@alanshaw Would you please let us know the status on this? Thank you very much for making david-dm. It has helped us a lot! 😃 |
|
Any status update?...or a reason the PR was approved, but then went stale before merge? |
|
any news here? |
|
Is there any progress or update on this feature? |
|
teelek201460@gmail.com
Puttasak
|
|
Any update on the status of this? Was it resolved? |
|
is there ANTHING that is going to be done with this? |
Issue
We can't share/embed David badges for private repos. Currently, viewing the badge for a private repo requires to be logged-in with a GitHub account that have access to the repo in question.
Closes #165, #176.
Proposition
For private repos, add a
tokenparameter to the badge URL. This token is the current user's GitHub token, encrypted with a secret server key provided via configuration.Pros
Cons
Implementation
Config
token.algorithmandtoken.secretconfig options, algorithm defaulting toaes-256-ctr(which is I think a sane default), and no secret. If no secret is set, no token will be generated and the behavior will be the same as now.Library
lib/badge-token.js, exposingencryptanddecryptfunctions, using the config algorithm and secret, andgetAuthTokento get a token either from the current session or the globally configured GitHub token. Theencryptfunction appends an HMAC to the generated token, and thedecryptfunction verifies it.package.jsonprivatekey is always set (if not explicitly set, will be whether the GitHub repo is private). Allows the rest of the code to do specific actions for private repos.Index
badgeTokeninbadgeandstatusroutes.Frontend
embed-badge*views to takeqsandlinkQsvariables instead ofpath. This is necessary because we need to add atokenparameter for private repos, but since there's already a potentialpathparameter, it's more complex to add a new parameter (might need a?or a&), and I prefered to rely onjQuery.paramsand give the whole query string. But since the token is only for the image and not the link, I introduced two variables for this.data-tokenwith generated token for the badge of private repos.embed-badge*views, usingjQuery.params.Routes
tokenparameter, decrypt it to get the GitHub token and use it in place of the session token if valid.badgeToken.getAuthToken) and pass it to the view.To-do
Note: this PR pretty critical since it involves encryption and security of GitHub tokens. I'm not a cryptography expert, so if we end up going with this solution, I'd feel better having it thoroughly reviewed by someone competent, and it would maybe we wise to ping the GitHub security team at some point.