50 Commits

Author SHA1 Message Date
chris48s
9bc673f40b time out long running requests more aggressively (#10833) 2025-02-08 17:51:51 +00:00
Pierre-Yves Bigourdan
4a75cf09a7 Add auth support to [Reddit] badges (#10790)
* Add auth support to [Reddit] badges

* Simplify token response schema
2025-01-18 16:13:53 +01:00
chris48s
9eaa2ed507 deprecate [wheelmap] service (#10538)
* deprecate [wheelmap] service

* remove app.json
2024-09-15 15:20:22 +00:00
Chase
37032641e3 Fix Gitea not having credentials/authorizedOrigins in Docker environments (#10486) 2024-09-02 13:09:10 +00:00
Leo Q
e8671be7f2 support setting pypiBaseUrl by environment variables and queryParameters; affects [pypi] (#10044)
* support setting pypiBaseUrl by environment variables

* Add support for pypiBaseUrl configuration

* Update Pypi services to include pypiBaseUrl parameter

* change package name example to a more well-known package

* Update custom-environment-variables.yml

* Update Pypi services to include pypiBaseUrl parameter

* fix openapi mismatch

* Update doc/server-secrets.md

---------

Co-authored-by: chris48s <chris48s@users.noreply.github.com>
2024-04-21 16:33:42 +00:00
chris48s
880c1fb49c call [docker] with auth (#9803)
* allow user to set dockerhub credentials

* add withJwtAuth function to AuthHelper

* use withJwtAuth in DockerHub badges

* add unit tests for JWT auth

* use auth when calling docker cloud

* refactor and assert fetch helpers call withJwtAuth

* store token for a max duration (defaults to 1 hour)

* tangent: update test example
2023-12-31 14:55:18 +00:00
chris48s
19b50a66a6 call [pepy] with auth (#9748) 2023-11-19 19:24:56 +00:00
chris48s
8f76982e1c Switch [OpenCollective] badges to use GraphQL and auth (#9387)
* [OpenCollective] update opencollective to api v2 (#9346)

* update opencollective to api v2

* fix tests

* fix: do not filter by accountType for opencollective/all

* remove 404

* remove required in schema

* cnt -> count

* keep by-tier code as-is

---------

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>

* allow calling OpenCollective api with an auth token

* add test for opencollective auth

* cache OpenCollective badges for longer

---------

Co-authored-by: xxchan <xxchan22f@gmail.com>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2023-08-20 18:24:38 +00:00
Sandro Marques
96e9e130de Add [CurseForge] badges (#9252)
* add curseforge downloads badge

* Add more [CurseForge] badges

Adds the following badges:
 - /curseforge/dt/:projectId (downloads)
 - /curseforge/game-versions/:projectId (game versions)
 - /curseforge/v/:projectId (version)

The following secret:
 - CURSEFORGE_API_KEY (yml: private.curseforge_api_key)

* Remove default logo from badges

* Linter fixes

* Rename `errorMessages` to `httpErrors`

* Remove namedLogo from ModrinthGameVersions badge

* Remove namedLogo from ModrinthVersion badge

* Remove namedLogo from ModrinthFollowers badge

---------

Co-authored-by: Minecraftschurli <minecraftschurli@gmail.com>
Co-authored-by: Pierre-Yves Bigourdan <10694593+PyvesB@users.noreply.github.com>
2023-08-13 18:00:40 +00:00
chris48s
b96192eec6 remove redis token persistence backend (#9065)
* remove redis token persistence backend

* error and exit if redis_url is set
2023-04-15 20:17:35 +01:00
chris48s
091ccfdbcd migrate token pooling to postgres (#8922)
* add ability to store token pool in Postgres DB

* update transitive ansi-regex dependencies
2023-02-23 17:18:39 +00:00
chris48s
c3d08f7f8b Send X-GitHub-Api-Version when calling [GitHub] v3 API (#8669)
* send X-GitHub-Api-Version when calling GitHub v3 API

* TODO: invesitgate

* read baseUrl from config.service.baseUri

* add workflow to check for new GH api releases on schedule

* format config/default.yml to match yaml.dump() format

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2022-12-31 15:56:04 +00:00
chris48s
53c5cfa94d allow passing key to [stackexchange] (#8539)
* refactoring groundwork

* add stackapps_api_key setting

* add test for stackexchange auth

* clarify docs

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2022-12-04 10:53:59 +00:00
chris48s
3b2056ae5f move all public production config into yaml (#7885) 2022-04-26 21:54:15 +01:00
chris48s
99bffd3a86 Send better user-agent values (and got config changes) (#7309)
* expose fetchLimitBytes/userAgent in got-config module

* export a function not a factory

* send better user-agent values

- add userAgentBase setting
- send short SHA in user agent on heroku
- set a version (tag or short SHA) in Dockefile and use
  it to report server version in UA for docker users

* add a comment explaining fileSize

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-11-25 17:11:49 +00:00
Caleb Cartwright
ae58e4a211 Add authentication for Libraries.io-based badges, run [Libraries Bower] (#7080)
* feat: support authentication on Libraries.io requests

* feat: wire up libraries.io config and api provider instantiation

* feat: create libraries.io and bower base classes

* refactor: tweak libraries/bower service classes and tests

* rename request fetcher function/arg

* throw exception when no tokens available

* cleanup old value

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-10-28 19:21:24 -05:00
chris48s
0ce98396d7 remove [github] admin routes (#7105) 2021-10-05 17:17:26 +01:00
Florian "sp1rit
8a9efb2fc9 [OBS] add Open Build Service service-badge (#6993)
* service: add obs service

* service: obs: replaced replaceAll with replace and global regex

* service: obs: added space between class members

* service: obs: support for multiple instances

* service: obs: removed user prefix from auth vars

obs_userName is now called obs_user and obs_userPass is called obs_pass

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>

* service: obs: removed constructor hack in favour of serviceKey

* service: obs: apply suggestions from @calebcartwright

* service: obs: remove unneccesary http status mappings

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-09-25 17:44:56 +00:00
Caleb Cartwright
d728749886 fix: support gitlab token via env var (#7023) 2021-09-16 22:28:54 +00:00
Caleb Cartwright
961e13b229 Add API-based support for [GitLab] badges, add new GitLab Tag badge (#6988)
* Added GitLab Tag service

* Added prettyMessage for when repo has no tags

* Added pretty message for repo not found

* core: esm-ify gitlab tag service

* feat: support gitlab auth

* feat: support custom gitlab url on tag badges

* tests: add auth test for gitlab

* docs: fix gitlab config key references

* feat: support gitlab tag sorting options

* docs: add custom gitlab instance example for tags badge

* use v in gitlab route

* fix: gitlab tag examples

Co-authored-by: Ideotec <guille@ideotec.es>
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-09-14 23:06:57 +00:00
Seth Falco
bd6f4ee146 fix: authenticate weblate requests (#6790)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-07-25 15:53:41 +00:00
Pierre-Yves B
59dcdf24f3 Remove rate limiting functionality (#6513) 2021-05-20 08:02:44 +01:00
Pierre-Yves B
9c7baa26ab Deprecate [Bintray] service (#6423) 2021-04-24 18:05:59 +01:00
chris48s
7d452472de return a 408 Request Timeout response for timed out requests (#6371) 2021-04-11 21:29:13 +01:00
chris48s
b1fc492592 add setting which allows us to set a timeout on HTTP requests (#6364)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2021-04-05 17:56:32 +00:00
chris48s
e1bae8c18f remove redirectUrl: from prod settings (#5885) 2020-11-29 12:09:30 +00:00
chris48s
a14083d858 map REDIRECT_URI env var to redirectUrl setting (#5845)
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
2020-11-18 21:04:00 +00:00
Paul Melnikow
1fab1a7140 When configured, require requests to come from Cloudflare (#5666)
This is the code part of #3027, following [this article](https://www.viget.com/articles/heroku-cloudflare-the-right-way/) and using [this middleware](https://github.com/clive-io/cloudflare-middleware).

I pulled in the `addHandlerAtIndex()` function @chris48s wrote for #5574.

The middleware isn't perfect for scoutcamp, since it relies on `req.ip` which is something set by Express. However, the other solutions I found were either explicitly deprecated ([cloudflare-ip](https://www.npmjs.com/package/cloudflare-ip)) or relied on dynamically fetching the list of Cloudflare hosts ([cloudflare-ips](https://www.npmjs.com/package/cloudflare-ips)), which seems unnecessary as this list has not changed in several years.

I've left this off to start, so we can test it in production using an env var before we make it the production default.
2020-10-12 12:36:42 -04:00
Paul Melnikow
564a9145e9 Remove FsTokenPersistence (#5671)
Closes #5665
2020-10-10 21:59:52 +00:00
Paul Melnikow
eb9743c25c Remove obsolete peer-to-peer GitHub token-sharing code (#5628)
Prevent tokens from being sent to the OVH servers. Instead, add them directly to the Redis DB.

Ref #3393
2020-09-29 21:22:30 -04:00
Pierre-Yves B
135b842946 Migrate [Discord] implementation to use bot token (#5346)
* Migrate [Discord] implementation to use bot token

* Rework authorization field creation

* Revert "Rework authorization field creation"

This reverts commit caf65bde5d.

* Add LGTM exclusion for hardcoded credentials
2020-07-24 18:04:12 +02:00
Pierre-Yves B
0fd557d7bb Implement [YouTube] badge (#5132)
* Implement [YouTube] badge

* Update production-hosting.md with account owner

* Add votes badge variant

* Add links to tests

* Switch to social badge style
2020-06-10 18:44:21 +02:00
Caleb Cartwright
4fe80bb150 Get data for [Discord] badges via OVH server proxies (#4956) 2020-04-27 09:39:57 -04:00
Paul Melnikow
5f80d931ac Set Influx config for Heroku production app (#4953) 2020-04-26 20:48:12 -04:00
Marcin Mielnicki
e66cfa3c21 📈 PaaS-friendly metrics (#4874)
* prom-client JSON to InfluxDB line protocol converter

* Converts a metric with separate names

* prom-client JSON to InfluxDB line protocol (version 2) converter

* Server has instance id

* Read the instance id from an environment variable

* More unit tests for instance-metadata

* Log instance id

* Push influx metrics

* INSTANCE_ID with dyno metadata

* Prepare influx metrics in one place

* Influx metrics endpoint should return metrics

* More readable tests

* Env added to instance metadata

* hostname as an instance label value

* HEROKU_DYNO_ID as an instance id for heroku

* Instance env can be set by env variable

* HEROKU_APP_NAME as an instance env

* Log instance metadata as a JSON

* Typo fix

* Code refactoring in tests

* wait-for-expect dev dependency added

* Test for pushing metrics

* Test for pushing metrics

* Use basic authentication for pushing metrics

* intervalSeconds=2 for development env

* Using existing methods

* TODOs removed

* Schema for influx credentials

* Influx config removed from config files

* Require username and password when influx metrics are enabled

* Unused args removed

* pushing component should log errors

* Speed up tests

* should log error responses

* InstanceMetadata class replaces by simple object

* Influx metrics can be configuredd by env variables

* Use application label name instead of service

* Unused code removed

* Integration test for prom-client and converter

* metrics.influx.enabled configuration option added

* Improved influx configuration schema

* instanceMetadata validation

* Typo fix

* Default value for env

* metrics.infux.hostnameAsAInstanceId added

* should add hostname as an instance label when hostnameAsAInstanceId is enabled

* Default values for influx configuration

* flatMap is not available in Node.js 9.4

* Env vars removed from Procfile

* Better instance metadata values in tests

* Typo fix

* lodash.groupby added to prod dependencies

* Allow other keys in private config

* Missing test - should allow other private keys when influx metrics are enabled

* Missing test - should require private metrics config when influx configuration is enabled

* log.error instead of console.log

* metrics.influx.uri -> metrics.influx.url

* Unused arguments removed

* async removed

* promisify sendMetrics

* Allow to disable prometheus metrics

* Create test server with custom config

* 'metrics-influx' resource removed

* 'metrics-influx' resource removed

* Private config schema flattened out

* Extra code removed in Prometheus tests

* promisify moved outside of the class

* Do not throw errors from got in a specific test

* hostnameAliases added

* instanceIdFrom added

* instanceIdEnvVarName added

* envLabel added to schema

* instanceMetadata is not used by InfluxMetrics

* Instance metadata removed

* hostnameAsAnInstanceId removed

* A comment added

* waitForExpect removed

* Unused code removed
2020-04-19 20:03:00 +02:00
Pierre-Yves B
097bf87e41 Make it easier to benchmark and profile the code (#4780)
* Make it easier to benchmark and profile the code

* Remove unnecessary escape

* Clarify that the backend server is started without the frontend

* Add missing NODE_CONFIG_ENV environment variable

* Add error message when user has not included console.time statements

* Fix lint issue

* Handle multiple console.time statements

* Switch NODE_CONFIG_ENV to test

* Switch to const as variable never re-assigned
2020-03-22 20:45:53 +01:00
Paul Melnikow
1ea6ab57af Document which secrets are set in production (#4779) 2020-03-15 17:55:52 -04:00
chris48s
d8831729cb Check request origin before sending credentials (#4729)
Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
Co-authored-by: chris48s <chris48s@users.noreply.github.com>

Co-authored-by: Caleb Cartwright <calebcartwright@users.noreply.github.com>
Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
Co-authored-by: chris48s <chris48s@users.noreply.github.com>
2020-03-04 20:42:27 +00:00
Pierre-Yves B
e755e61203 Add Twitch keys to configuration files (#3985) 2019-09-10 21:28:47 +01:00
Paul Melnikow
65afff40d4 Fix up Redis config (#3705)
- Move to private
- Fix validation
- Don't log the URL

Ref #3332
2019-07-12 19:12:49 -04:00
Paul Melnikow
eec904c262 Fix raster redirect and drop the legacy static .png route (#3659) 2019-07-07 11:49:21 -04:00
Paul Melnikow
66c7f13e38 Drop gif + png, and redirect png to raster.shields.io (#3644)
1. Remove rasterization support from the server. This responsibility is delegated to a raster server which proxies the SVG badges and renders them.
2. When a raster server URL is configured, 301 redirect all .png badges to the identical URL on the raster server.
    `https://img.shields.io/npm/v/express.png?style=flat-square` ↪️`https://raster.shields.io/npm/v/express.png?style=flat-square`
3. For configured redirects, redirect to the canonical URL on the raster server.
    `https://img.shields.io/vso/build/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2.png?style=flat-square`
    ↪️`https://img.shields.io/azure-devops/build/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2.png?style=flat-square`
4. Redirect the "legacy badge old version" to the appropriate URL on the raster server.
5. When no raster server is configured (e.g. PRs), render an SVG containing **404 | raster badges not available** for all `.png` badges. (Note that the raster server can be self-hosted; however, this is deferred to a later PR.)
5. Drop support for jpg and gif which are very infrequently used (see #3112). Render an SVG containing **410 | jpg no longer available**.
7. ~~Remove raster dependencies.~~ Remove the raster cache (which is only used in the CLI, and therefore pointless).
8. Move the LRUCache code out of the npm package.
8. A wee bit of refactoring in `server.js`.

Ref #3112
Close #3631
2019-07-06 16:41:46 -04:00
Cedric van Putten
483ecf24de [Drone] Add Drone build badge (#3240)
* Add drone build badge based on travis

* Fix wrong mocked endpoint for done builder

* Refactor service tester using helper method

* Add missing failure status to red statuses

* Remove extraneous invalid svg test from drone

* Test on failure red status in build status spec

* refactor(drone): use json service instead of svg

* refactor(drone): remove status text and extraneous build path in test

* refactor(drone): allow defining self-hosted drone instances

* fix(drone): use proper urls in drone examples

* fix(drone): add drone token authorization for self-hosted instances

* refactor(drone): call render build status badge directly instead of render

* refactor(drone): use server query parameter for self-hosted instances

* fix(drone): separate url and query params in example

* fix(drone): use actual build status message in examples

* fix(drone): add missing message for status code 401

Co-Authored-By: byCedric <me@bycedric.com>

* refactor(drone): remove color from drone tests

* refactor(drone): remove extraneous comments from drone tests

* refactor(drone): remove unused static preview method

* refactor(drone): remove unused static render method

* refactor(drone): reuse render build status badge helper in static previews

* fix(drone): test inaccessible repos on new message
2019-04-16 11:33:15 -05:00
Paul Melnikow
ace2a7a695 Tweak Docker initialization (#3173)
* Tweak Docker initialization

1. Set NODE_ENV=production in Docker.
2. When NODE_ENV is production, bind to all interfaces. This seems like a
   sensible default.
3. Exclude Dockerfile from container to improve layer cacheability when
   modifying the dockerfile.

Ref #3165

* Rm obsolete comment
2019-03-06 21:15:03 -06:00
Paul Melnikow
84db9e6fe3 Remove IP filtering code for prometheus metrics (#3059)
Closes #2657
2019-02-20 18:38:16 +00:00
chris48s
697ff80dad limit the size of response we will accept (#2726)
limit the size of response we will accept
2019-01-11 21:50:49 +00:00
Paul Melnikow
1e267f891d Document production hosting (#2661) 2019-01-07 20:55:49 -05:00
Paul Melnikow
47bb03572b Set redirectUrl for production; rely on NODE_CONFIG_ENV being set earlier (#2656) 2019-01-06 12:56:26 -05:00
Paul Melnikow
bc0be4f619 Fixes for config update (#2655)
Ref #2626 #2654
2019-01-06 12:23:58 -05:00
Paul Melnikow
fa5309400d PaaS, CI, and production-friendly config (#2626)
This implements the configuration mechanism I described in #2621. The heavy lifting is delegated to [node-config](https://github.com/lorenwest/node-config) with a minor assist from [dotenv](https://github.com/motdotla/dotenv).

`private/secret.json` has been replaced with environment variables and/or `config/local.yml`. See `doc/server-secrets.md`.
2019-01-06 10:42:09 -05:00