call [pepy] with auth (#9748)

This commit is contained in:
chris48s
2023-11-19 19:24:56 +00:00
committed by GitHub
parent 5ad1e35101
commit 19b50a66a6
8 changed files with 30 additions and 4 deletions

View File

@@ -16,6 +16,10 @@ inputs:
description: 'The SERVICETESTS_OBS_PASS secret'
required: false
default: ''
pepy-key:
description: 'The SERVICETESTS_PEPY_KEY secret'
required: false
default: ''
sl-insight-user-uuid:
description: 'The SERVICETESTS_SL_INSIGHT_USER_UUID secret'
required: false
@@ -66,6 +70,7 @@ runs:
LIBRARIESIO_TOKENS: '${{ inputs.librariesio-tokens }}'
OBS_USER: '${{ inputs.obs-user }}'
OBS_PASS: '${{ inputs.obs-pass }}'
PEPY_KEY: '${{ inputs.pepy-key }}'
SL_INSIGHT_USER_UUID: '${{ inputs.sl-insight-user-uuid }}'
SL_INSIGHT_API_TOKEN: '${{ inputs.sl-insight-api-token }}'
TWITCH_CLIENT_ID: '${{ inputs.twitch-client-id }}'

View File

@@ -35,6 +35,7 @@ jobs:
LIBRARIESIO_TOKENS=${{ secrets.SERVICETESTS_LIBRARIESIO_TOKENS }}
OBS_USER=${{ secrets.SERVICETESTS_OBS_USER }}
OBS_PASS=${{ secrets.SERVICETESTS_OBS_PASS }}
PEPY_KEY=${{ secrets.SERVICETESTS_PEPY_KEY }}
SL_INSIGHT_API_TOKEN=${{ secrets.SERVICETESTS_SL_INSIGHT_USER_UUID }}
SL_INSIGHT_USER_UUID=${{ secrets.SERVICETESTS_SL_INSIGHT_API_TOKEN }}
TWITCH_CLIENT_ID=${{ secrets.SERVICETESTS_TWITCH_CLIENT_ID }}

View File

@@ -29,6 +29,7 @@ jobs:
librariesio-tokens: '${{ secrets.SERVICETESTS_LIBRARIESIO_TOKENS }}'
obs-user: '${{ secrets.SERVICETESTS_OBS_USER }}'
obs-pass: '${{ secrets.SERVICETESTS_OBS_PASS }}'
pepy-key: '${{ secrets.SERVICETESTS_PEPY_KEY }}'
sl-insight-user-uuid: '${{ secrets.SERVICETESTS_SL_INSIGHT_USER_UUID }}'
sl-insight-api-token: '${{ secrets.SERVICETESTS_SL_INSIGHT_API_TOKEN }}'
twitch-client-id: '${{ secrets.SERVICETESTS_TWITCH_CLIENT_ID }}'

View File

@@ -27,6 +27,7 @@ jobs:
librariesio-tokens: '${{ secrets.SERVICETESTS_LIBRARIESIO_TOKENS }}'
obs-user: '${{ secrets.SERVICETESTS_OBS_USER }}'
obs-pass: '${{ secrets.SERVICETESTS_OBS_PASS }}'
pepy-key: '${{ secrets.SERVICETESTS_PEPY_KEY }}'
sl-insight-user-uuid: '${{ secrets.SERVICETESTS_SL_INSIGHT_USER_UUID }}'
sl-insight-api-token: '${{ secrets.SERVICETESTS_SL_INSIGHT_API_TOKEN }}'
twitch-client-id: '${{ secrets.SERVICETESTS_TWITCH_CLIENT_ID }}'

View File

@@ -96,6 +96,7 @@ private:
obs_pass: 'OBS_PASS'
redis_url: 'REDIS_URL'
opencollective_token: 'OPENCOLLECTIVE_TOKEN'
pepy_key: 'PEPY_KEY'
postgres_url: 'POSTGRES_URL'
sentry_dsn: 'SENTRY_DSN'
sl_insight_userUuid: 'SL_INSIGHT_USER_UUID'

View File

@@ -185,6 +185,7 @@ const privateConfigSchema = Joi.object({
obs_pass: Joi.string(),
redis_url: Joi.string().uri({ scheme: ['redis', 'rediss'] }),
opencollective_token: Joi.string(),
pepy_key: Joi.string(),
postgres_url: Joi.string().uri({ scheme: 'postgresql' }),
sentry_dsn: Joi.string(),
sl_insight_userUuid: Joi.string(),

View File

@@ -254,6 +254,14 @@ OpenCollective's GraphQL API only allows 10 reqs/minute for anonymous users.
An [API token](https://graphql-docs-v2.opencollective.com/access)
can be provided to access a higher rate limit of 100 reqs/minute.
### Pepy
- `PEPY_KEY` (yml: `pepy_key`)
The Pepy API requires authentication. To obtain a key,
Create an account, sign in and obtain generate a key on your
[account page](https://www.pepy.tech/user).
### SymfonyInsight (formerly Sensiolabs)
- `SL_INSIGHT_USER_UUID` (yml: `private.sl_insight_userUuid`)

View File

@@ -20,6 +20,12 @@ export default class PepyDownloads extends BaseJsonService {
pattern: 'dt/:packageName',
}
static auth = {
passKey: 'pepy_key',
authorizedOrigins: ['https://api.pepy.tech'],
isRequired: true,
}
static openApi = {
'/pepy/dt/{packageName}': {
get: {
@@ -38,10 +44,12 @@ export default class PepyDownloads extends BaseJsonService {
static defaultBadgeData = { label: 'downloads' }
async fetch({ packageName }) {
return this._requestJson({
url: `https://api.pepy.tech/api/v2/projects/${packageName}`,
schema,
})
return this._requestJson(
this.authHelper.withApiKeyHeader({
url: `https://api.pepy.tech/api/v2/projects/${packageName}`,
schema,
}),
)
}
async handle({ packageName }) {