Commit Graph
48 Commits
Author SHA1 Message Date
Paul MelnikowandGitHub b10a6a4aa7 Refactor [github] token persistence, again (#1906)
Instead of saving tokens on a timer, save them when they change. Use EventEmitter to keep the components loosely coupled.

This is easier to reason about, much easier to test, and better supports adapting to backends which support atomic operations.

This replaces json-autosave, which was a bit difficult to read and also hard to test, with fsos, the lower-level utility it’s built on.

Ref: #1848
2018-08-18 23:54:53 -04:00
Paul MelnikowandGitHub 66d444aa40 Clean up our callback style and enforce no exclusive tests and remove an exclusive test (#1900)
We use arrow functions in most places; this enforces it.

Passing arrow functions to Mocha is discouraged: https://mochajs.org/#arrow-functions

This was a mix of autofixes and hand adjustments.
2018-08-12 20:45:43 -04:00
Paul MelnikowandGitHub 9007658fd0 Refactor and test [github] token persistence (#1863)
Ref #1848 #1205
2018-08-11 20:13:40 -04:00
Paul MelnikowandGitHub 39d393028d Fix and test the github admin route (#1886)
Fix regressions in the github admin and token acceptor endpoints, introduced in #1813.
2018-08-11 19:48:43 -04:00
Paul MelnikowandGitHub c11d97a192 Refactor [github] initialization (#1861)
This creates a new convenience class which consolidates all the Github initialization. It supports dependency injection and facilitates refactoring the persistence along the lines of #1205.

Also ref #1848
2018-08-09 07:20:57 -04:00
Paul MelnikowandGitHub 7a664ca3e8 Run prettier (#1866)
Merging this separately so the commit with the tooling change is readable. This is a follow-on to #1167 which turned prettier on.
2018-08-08 17:57:14 -04:00
Paul MelnikowandGitHub 2ff71dab6a Start cleaning up github auth routes (#1813)
- Move github token debug route to separate module
- Use crypto.timingSafeEqual
- Rename getTokenDebugInfo -> serializeDebugInfo
2018-08-01 21:58:11 -04:00
Paul MelnikowandGitHub 9882a44e56 Configure for deployment with zeit now (#1308)
I'm experimenting with Zeit Now as another hosting option. These changes enable a working deployment.
2017-12-04 18:25:16 -05:00
Paul MelnikowandGitHub 1d313bdd19 Github admin endpoint: use basic auth password instead of username (#1317) 2017-12-03 15:07:58 -05:00
Paul MelnikowandGitHub 127b46aef8 Github auth admin endpoint and logging (#1267)
- Periodically log github auth information
    - Tokens are hashed which reduces the security risk inherent in the logs
        - A consistent hash is used so tokens can be correlated across the three data structures and across the three servers
- Add an admin endpoint for github auth information
    - Tokens are returned as-is to enable troubleshooting (e.g. comparing our reqRemaining to github’s)
2017-11-30 13:21:27 -05:00
Thaddee Tyl 59c0662874 Fix bug saving GitHub tokens from other servers
This fixes a bug introduced in 076cb14, wherein we discarded tokens received
from other servers, and wherein we could save tokens with invalid
identification.

The bug was raised by Paul Melnikow.
2017-11-11 10:27:24 +01:00
Paul MelnikowandGitHub 8733a8b8f2 Use GitHub token rotation in production :P (#1266) 2017-11-10 13:51:39 -05:00
Paul MelnikowandPaul Melnikow 4d22799962 Fix Github base url again
Fix #1243.
2017-11-02 10:35:22 -04:00
Paul MelnikowandGitHub b16122d9a4 When a global gh_token is configured, always use it (#1118)
If I configure a global gh_token, I expect it to be used all the time. I expect to see predictable failures when that token is exhausted.
2017-10-29 22:36:39 -04:00
Paul MelnikowandGitHub 446d4ce21e Correct cache behavior for custom query parameters (#1186)
I developed this for #820 to provide the correct cache behavior when a service wants to use custom parameters from the query string.

For safety, only the declared parameters (and the global parameters) are provided to the service. Consequently, failure to declare a parameter results in the parameter not working at all (undesirable, but easy to debug) rather than indeterminate behavior that depends on the cache state (undesirable, but hard to debug).
2017-10-24 23:00:23 -04:00
Paul MelnikowandPaul Melnikow 6aae294b28 Avoid errors when offline 2017-10-21 11:29:30 -04:00
Paul MelnikowandGitHub dc44ba7725 Clean up request-handler, github-auth, and analytics; upgrade to Mocha 4 (#1142)
- Add tests to request-handler to prepare for some tweaks to caching for #820
- Clean up code in request-handler: renames, DRY, arrows, imports
- Allow for clean shutdown of `setInterval` code. This requires the ability to cancel autosaving.
- Upgrade to Mocha 4, and clean up so the process exits on its own (see mochajs/mocha#3044)
- Better encapsulate analytics
2017-10-17 22:01:46 -04:00
Paul MelnikowandGitHub 5a3516c687 Clean up some helpers (#1117)
Address comments from #1109 and make several code-quality fixes which were caught by a local run of eslint-config-standard.
2017-10-06 13:11:29 -04:00
Thaddee Tyl 95ef1da7a5 Change BASE_URL to img.shields.io
It seems like a mistake from #870. Indeed, the code in that patch
defaults to shields.io for BASE_URL, but the author mentions they
think it defaults to img.shields.io: https://github.com/badges/shields/pull/870#discussion_r115143960
The correct value to maintain the behavior that was present prior
to the patch in question was indeed img.shields.io.
2017-10-03 00:21:17 +02:00
Thaddee Tyl 39a084d7c6 Log GitHub OAuth authentication failure 2017-10-02 23:50:16 +02:00
Paul MelnikowandGitHub f271b82670 Nudge forward style checks a la eslint-config-standard (#1082)
Because I despise nitpicking stuff like indentation and spacing in pull request comments, I'd like to nudge forward our automated style checking, at least for new files being added.

I don't want to totally rewrite server.js just to get automated style checking… the blame tracking is just too useful. So let's it's just take care of that when we start splitting it out.

More discussion in #948.
2017-10-01 21:09:43 -04:00
Adriaan GroenenboomandDaniel Lo Nigro 15f24fbcce Improve Docker run (envsubst, Alpine, documented env file) (#870)
* Add template for secret.json

- Move to faster and lighter Alpine base image

* Update documentation

* Update documentation

* Fix Github token config for secret.json

* Extend env file for Docker runtime configuration

- Update documentation
- Add gh_token for GH personal access token to secret template

* Change http to https in infoSite

* Update .dockerignore

* Update .gitignore

* Update dockerignore

* Remove ENV directive from Dockerfile

- Environment is needed at runtime, not at buildtime

* Docker: contain secret.json in private/

- Incorporates fix from 7c8b0e3d

* Use localhost in example env

* Use baseUrl in GitHub redirect

* Move GH personal token retrieval up

- To remove duplicate Promise.then()

* Typo in shields.example.env
2017-05-07 11:13:02 -07:00
Frode KnutsenandPaul Melnikow 2133ff9d1f fix default value for githubUserTokens 2017-03-27 16:56:58 -04:00
Paul Melnikow 47a8bf51dc First pass for linting on PRs 2017-03-20 16:54:27 -04:00
Thaddee Tyl 076cb14b3b Perform constant equal comparison for shared Shields secret
This should prevent timing attacks.
2017-02-25 18:20:07 +01:00
Thaddee Tyl 7c8b0e3d32 Contain all private files in private/ 2017-02-05 16:24:35 +01:00
Thaddee Tyl 0684c25b94 Remove todo for GitHub auth documentation
It was accidentally done by 56746d4a38.
2016-07-02 12:14:34 +02:00
Thaddee Tyl 71bb291f40 Remove verbose logs for GitHub auth 2016-07-02 10:39:57 +02:00
Thaddee Tyl a7cfac6e93 GitHub auth: use token with the most remaining requests
Part of #529.
2016-06-27 20:07:15 +02:00
Thaddee Tyl bfc6e7d863 GitHub auth: use up to 3/4 of the user's rate limit 2016-06-27 19:38:01 +02:00
Thaddee Tyl 56746d4a38 GitHub auth: rely on cache if no tokens remain 2016-06-27 19:37:19 +02:00
Thaddee Tyl 12b0ded4a3 GitHub auth: use UTC epoch seconds instead of milliseconds 2016-06-26 18:41:32 +02:00
Thaddee Tyl 63e25b29eb GitHub auth: no longer rely on buggy rate limit cache 2016-06-26 18:30:27 +02:00
Thaddee Tyl a3ba53a0d8 GitHub auth: user token selection supports remaining requests 2016-06-26 18:01:48 +02:00
Thaddee Tyl 2b849b2b7f GitHub auth: log token requests 2016-06-26 17:21:00 +02:00
Thaddee Tyl 014753a736 GitHub auth: better messages 2016-06-26 16:45:44 +02:00
Thaddee Tyl 14d436084b GitHub auth: log token rate limits and unauthorization 2016-06-25 20:32:30 +02:00
Thaddee Tyl 997e6a6f43 GitHub auth: maintain rate limit reset information, track token with highest remaining requests 2016-06-23 19:28:56 +02:00
Thaddee Tyl fe279e4a75 GitHub auth: removal of unauthorized user tokens 2016-06-22 10:12:07 +02:00
Thaddee Tyl a54a247f16 GitHub auth: only use user tokens if over rate limit 2016-06-21 09:26:52 +02:00
Thaddee Tyl 58cbb18c1d GitHub auth: query parameter, don't shadow request() 2016-06-20 22:30:51 +02:00
Thaddee Tyl 3564e4474b GitHub auth: set up lowest available rate limit 2016-06-19 23:30:21 +02:00
Thaddee Tyl b3e8ab9556 Custom GitHub requests 2016-06-18 23:28:43 +02:00
Thaddee Tyl ec2a35266b Hide GitHub user tokens 2016-06-15 23:57:59 +02:00
Thaddee Tyl fc223c9f86 Put GitHub user token synchronization in the background
Issue #529.
2016-06-01 23:55:17 +02:00
Thaddee Tyl c403e367f7 Synchronize saved GitHub user tokens
Issue #529.

Having a server down breaks the process currently. That will be addressed in a
later commit.
2016-06-01 00:15:45 +02:00
Thaddee Tyl 419483f24e Transmit and save GitHub user tokens
Issue #529.
2016-05-28 22:33:34 +02:00
Thaddee Tyl ccaacfc408 Support GitHub OAuth user authentication
Issue #529.
2016-05-21 21:34:35 +02:00