diff --git a/src/api-openapi.js b/src/api-openapi.js index bcf052c44..b2d1f99a2 100644 --- a/src/api-openapi.js +++ b/src/api-openapi.js @@ -23,13 +23,6 @@ class ApiOpenapiApp { RegisterRoutes(app); - // RFC 8631 service-desc link relation - // https://datatracker.ietf.org/doc/html/rfc8631 - app.get('/ds/api', (req, res) => { - res.setHeader('Link', '; rel="service-desc"'); - res.status(204).end(); - }); - app.get('/ds/api/openapi.yaml', (req, res) => { res.setHeader('Content-Type', 'application/yaml'); res.send(spec); @@ -54,14 +47,9 @@ class ApiOpenapiApp { */ specObject.components.securitySchemes.jwt.flows.clientCredentials.tokenUrl = `${process.env.OIDC_ISSUER}/protocol/openid-connect/token`; - RegisterRoutes(app); + specObject.components.securitySchemes.openid.openIdConnectUrl = `${process.env.OIDC_ISSUER}/.well-known/openid-configuration`; - // RFC 8631 service-desc link relation - // https://datatracker.ietf.org/doc/html/rfc8631 - app.get('/ds/api/v2', (req, res) => { - res.setHeader('Link', '; rel="service-desc"'); - res.status(204).end(); - }); + RegisterRoutes(app); app.get('/ds/api/v2/openapi.yaml', (req, res) => { res.setHeader('Content-Type', 'application/yaml'); @@ -86,6 +74,13 @@ class ApiOpenapiApp { this.prepareV2(app); this.prepareV1(app); + // RFC 8631 service-desc link relation + // https://datatracker.ietf.org/doc/html/rfc8631 + app.get('/ds/api', (req, res) => { + res.setHeader('Link', '; rel="service-desc"'); + res.status(204).end(); + }); + app.use(function errorHandler(err, req, res, next) { if (err instanceof UnauthorizedError) { return res.status(err.status).json({ diff --git a/src/controllers/v2/GatewayController.ts b/src/controllers/v2/GatewayController.ts index 94a7f5c1c..79b0b7a54 100644 --- a/src/controllers/v2/GatewayController.ts +++ b/src/controllers/v2/GatewayController.ts @@ -9,6 +9,8 @@ import { Security, Body, Tags, + FormField, + UploadedFile, } from 'tsoa'; import { KeystoneService } from '../ioc/keystoneInjector'; import { inject, injectable } from 'tsyringe'; @@ -20,6 +22,7 @@ import { removeKeys, } from '../../batch/feed-worker'; import { GatewayRoute } from './types'; +import { PublishResult } from './types-extra'; @injectable() @Route('/namespaces/{ns}/gateway') @@ -31,6 +34,17 @@ export class GatewayController extends Controller { this.keystone = _keystone; } + @Put() + @OperationId('publish-gateway-config') + @Security('jwt', ['Gateway.Config']) + public async put( + @FormField() dryRun: boolean, + @UploadedFile() configFile: Express.Multer.File + ): Promise { + // stub - gwa-api implements this + return { error: 'Stub - not implemented' }; + } + /** * Get a summary of your Gateway Services * > `Required Scope:` Namespace.Manage diff --git a/src/controllers/v2/openapi.yaml b/src/controllers/v2/openapi.yaml index 5c6ad39cd..338ac8ae0 100644 --- a/src/controllers/v2/openapi.yaml +++ b/src/controllers/v2/openapi.yaml @@ -188,6 +188,16 @@ components: - tag2 organization: ministry-of-citizens-services organizationUnit: databc + PublishResult: + properties: + message: + type: string + results: + type: string + error: + type: string + type: object + additionalProperties: false GatewayServiceRefID: type: string GatewayRouteRefID: @@ -277,9 +287,7 @@ components: clientRegistration: managed clientId: a-client-id clientSecret: a-client-secret - CredentialIssuerRefID: - type: string - UserRefID: + undefinedRefID: type: string CredentialIssuer: properties: @@ -338,9 +346,9 @@ components: type: string type: array inheritFrom: - $ref: '#/components/schemas/CredentialIssuerRefID' + $ref: '#/components/schemas/undefinedRefID' owner: - $ref: '#/components/schemas/UserRefID' + $ref: '#/components/schemas/undefinedRefID' type: object additionalProperties: false example: @@ -350,7 +358,7 @@ components: clientAuthenticator: client-secret mode: auto environmentDetails: [] - owner: acope@idir + owner: janis@gov.bc.ca Maybe_Scalars-at-String_: type: string nullable: true @@ -539,6 +547,8 @@ components: type: string LegalRefID: type: string + CredentialIssuerRefID: + type: string Environment: properties: appId: @@ -621,6 +631,10 @@ components: description: 'Authz Portal Login' scheme: bearer bearerFormat: JWT + openid: + type: openIdConnect + description: 'OIDC Login' + openIdConnectUrl: 'https://well_known_endpoint' info: title: 'APS Directory API' version: 1.1.0 @@ -961,6 +975,37 @@ paths: schema: type: string '/namespaces/{ns}/gateway': + put: + operationId: publish-gateway-config + responses: + '200': + description: Ok + content: + application/json: + schema: + $ref: '#/components/schemas/PublishResult' + tags: + - 'Gateway Services' + security: + - + jwt: + - Gateway.Config + parameters: [] + requestBody: + required: true + content: + multipart/form-data: + schema: + type: object + properties: + dryRun: + type: string + configFile: + type: string + format: binary + required: + - dryRun + - configFile get: operationId: get-gateway-routes responses: diff --git a/src/controllers/v2/routes.ts b/src/controllers/v2/routes.ts index 21bb4b1ec..4baa2c8b2 100644 --- a/src/controllers/v2/routes.ts +++ b/src/controllers/v2/routes.ts @@ -34,6 +34,8 @@ const promiseAny = require('promise.any'); import { iocContainer } from './../ioc'; import { IocContainer, IocContainerFactory } from '@tsoa/runtime'; import * as express from 'express'; +const multer = require('multer'); +const upload = multer(); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa @@ -128,6 +130,16 @@ const models: TsoaRoute.Models = { "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "PublishResult": { + "dataType": "refObject", + "properties": { + "message": {"dataType":"string"}, + "results": {"dataType":"string"}, + "error": {"dataType":"string"}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "GatewayServiceRefID": { "dataType": "refAlias", "type": {"dataType":"string","validators":{}}, @@ -185,12 +197,7 @@ const models: TsoaRoute.Models = { "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "CredentialIssuerRefID": { - "dataType": "refAlias", - "type": {"dataType":"string","validators":{}}, - }, - // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "UserRefID": { + "undefinedRefID": { "dataType": "refAlias", "type": {"dataType":"string","validators":{}}, }, @@ -215,8 +222,8 @@ const models: TsoaRoute.Models = { "resourceScopes": {"dataType":"array","array":{"dataType":"string"}}, "clientRoles": {"dataType":"array","array":{"dataType":"string"}}, "clientMappers": {"dataType":"array","array":{"dataType":"string"}}, - "inheritFrom": {"ref":"CredentialIssuerRefID"}, - "owner": {"ref":"UserRefID"}, + "inheritFrom": {"ref":"undefinedRefID"}, + "owner": {"ref":"undefinedRefID"}, }, "additionalProperties": false, }, @@ -355,6 +362,11 @@ const models: TsoaRoute.Models = { "type": {"dataType":"string","validators":{}}, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "CredentialIssuerRefID": { + "dataType": "refAlias", + "type": {"dataType":"string","validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "Environment": { "dataType": "refObject", "properties": { @@ -780,6 +792,37 @@ export function RegisterRoutes(app: express.Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + app.put('/ds/api/v2/namespaces/:ns/gateway', + authenticateMiddleware([{"jwt":["Gateway.Config"]}]), + upload.single('configFile'), + + async function GatewayController_put(request: any, response: any, next: any) { + const args = { + dryRun: {"in":"formData","name":"dryRun","required":true,"dataType":"string"}, + configFile: {"in":"formData","name":"configFile","required":true,"dataType":"file"}, + }; + + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + + let validatedArgs: any[] = []; + try { + validatedArgs = getValidatedArgs(args, request, response); + + const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; + + const controller: any = await container.get(GatewayController); + if (typeof controller['setStatus'] === 'function') { + controller.setStatus(undefined); + } + + + const promise = controller.put.apply(controller, validatedArgs as any); + promiseHandler(controller, promise, response, undefined, next); + } catch (err) { + return next(err); + } + }); + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.get('/ds/api/v2/namespaces/:ns/gateway', authenticateMiddleware([{"jwt":["Namespace.Manage"]}]), diff --git a/src/controllers/v2/types-extra.ts b/src/controllers/v2/types-extra.ts index ecc3eede2..438ddde0d 100644 --- a/src/controllers/v2/types-extra.ts +++ b/src/controllers/v2/types-extra.ts @@ -10,3 +10,12 @@ export interface ActivityDetail { activityAt: Scalars['DateTime']; blob?: any; } + +/** + * @tsoaModel + */ +export interface PublishResult { + message?: string; + results?: string; + error?: string; +} diff --git a/src/controllers/v2/types.ts b/src/controllers/v2/types.ts index 7e4c9839c..2573e41d3 100644 --- a/src/controllers/v2/types.ts +++ b/src/controllers/v2/types.ts @@ -315,7 +315,7 @@ export interface Environment { * "clientAuthenticator": "client-secret", * "mode": "auto", * "environmentDetails": [], - * "owner": "acope@idir" + * "owner": "janis@gov.bc.ca" * } */ export interface CredentialIssuer { @@ -336,8 +336,8 @@ export interface CredentialIssuer { resourceScopes?: string[]; clientRoles?: string[]; clientMappers?: string[]; - inheritFrom?: CredentialIssuerRefID; - owner?: UserRefID; + inheritFrom?: undefinedRefID; + owner?: undefinedRefID; } @@ -477,6 +477,7 @@ export interface User { name?: string; email?: string; legalsAgreed?: UserLegalsAgreed[]; + provider?: string; } @@ -554,3 +555,8 @@ export type OrganizationUnitRefID = string * @tsoaModel */ export type UserRefID = string + +/** + * @tsoaModel + */ +export type undefinedRefID = string