Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: protect individual certificate endpoint with token #250

Merged
merged 5 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Bug fixes

- Protect individual certificate endpoint with token
- Kibana disk space alerts now work regardless of your disk device names. Alerts listen devices mounted both to `/` and `/data` (encrypted data partition)
- "Publish release" pipeline now correctly uses the "Branch to build from" value as the branch to be tagged. Previously it tried tagging "master". "Release tag" is also now used as the release version as is instead of it being read from `package.json`.

Expand Down
20 changes: 20 additions & 0 deletions src/api/certificates/handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* OpenCRVS is also distributed under the terms of the Civil Registration
* & Healthcare Disclaimer located at http://opencrvs.org/license.
*
* Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
*/

import { Request, ResponseToolkit } from '@hapi/hapi'
import { readFileSync } from 'fs'

export async function certificateHandler(request: Request, h: ResponseToolkit) {
const res = readFileSync(
`./src/api/certificates/source/Farajaland-${request.params.event}-certificate-v2.svg`
).toString()
return h.response(res).code(200)
}
48 changes: 0 additions & 48 deletions src/data-seeding/certificates/handler.ts

This file was deleted.

33 changes: 10 additions & 23 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import { ErrorContext } from 'hapi-auth-jwt2'
import { mapGeojsonHandler } from '@countryconfig/api/dashboards/handler'
import { formHandler } from '@countryconfig/form'
import { locationsHandler } from './data-seeding/locations/handler'
import { certificateHandler } from './data-seeding/certificates/handler'
import { certificateHandler } from './api/certificates/handler'
import { rolesHandler } from './data-seeding/roles/handler'
import { usersHandler } from './data-seeding/employees/handler'
import { applicationConfigHandler } from './api/application/handler'
Expand Down Expand Up @@ -238,18 +238,15 @@ export async function createServer() {

server.auth.default('jwt')

if (process.env.NODE_ENV !== 'production') {
server.route({
method: 'GET',
path: '/certificates/{event}.svg',
handler: certificateHandler,
options: {
auth: false,
tags: ['api', 'certificates'],
description: 'Returns only one certificate metadata'
}
})
}
server.route({
method: 'GET',
path: '/certificates/{event}.svg',
handler: certificateHandler,
options: {
tags: ['api', 'certificates'],
description: 'Returns only one certificate metadata'
}
})
// add ping route by default for health check
server.route({
method: 'GET',
Expand Down Expand Up @@ -490,16 +487,6 @@ export async function createServer() {
}
})

server.route({
method: 'GET',
path: '/certificates',
handler: certificateHandler,
options: {
tags: ['api', 'certificates'],
description: 'Returns certificate metadata'
}
})

server.route({
method: 'GET',
path: '/roles',
Expand Down
Loading