Skip to content

Commit

Permalink
Merge pull request #20 from magda-io/issue/19
Browse files Browse the repository at this point in the history
Issue/19 Basic Auth support & access getRecords via POST request
  • Loading branch information
t83714 authored Nov 8, 2021
2 parents a9bfe38 + 675b4b4 commit 02a0e05
Show file tree
Hide file tree
Showing 20 changed files with 8,309 additions and 89 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Use Node.js 10
- name: Use Node.js 12
uses: actions/setup-node@v1
with:
node-version: 10
node-version: 12
- run: yarn install
- run: yarn build
- run: yarn test
Expand Down
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"protocol": "inspector",
"name": "Debug test case",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"cwd": "${workspaceRoot}",
"args": [
"--require",
"ts-node/register",
"--require",
"tsconfig-paths/register",
"src/test/**/*.ts"
]
}
]
}
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 1.1.0

- Add POST request support for getRecords endpoints
- Add HTTP basic Auth Support
- Try to locate metadata ID when codeSpace info for the id is not present
- Upgrade to node 12
- Allow basicAuth username & password to be supplied via k8s secret

# 1.0.0

- Upgrade dependencies
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:10
FROM node:12-alpine

RUN mkdir -p /usr/src/app
COPY . /usr/src/app
Expand Down
35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,23 @@ Kubernetes: `>= 1.14.0-0`

## Values

| Key | Type | Default | Description |
| ---------------------------------- | ------ | ------------------------- | ----------- |
| config.id | string | `"default-csw-connector"` | |
| defaultImage.imagePullSecret | bool | `false` | |
| defaultImage.pullPolicy | string | `"IfNotPresent"` | |
| defaultImage.repository | string | `"docker.io/data61"` | |
| defaultSettings.includeCronJobs | bool | `true` | |
| defaultSettings.includeInitialJobs | bool | `false` | |
| defaultTenantId | int | `0` | |
| global.connectors.image | object | `{}` | |
| global.image | object | `{}` | |
| image.name | string | `"magda-csw-connector"` | |
| resources.limits.cpu | string | `"100m"` | |
| resources.requests.cpu | string | `"50m"` | |
| resources.requests.memory | string | `"30Mi"` | |
| Key | Type | Default | Description |
| ---------------------------------- | ------ | ------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
| config.basicAuthEnabled | bool | `false` | Whether or not to send basic auth header. |
| config.basicAuthPassword | string | `nil` | basic auth password. You can also passing this value via secret. To do so, set `basicAuthSecretName` to the secret name. |
| config.basicAuthSecretName | string | `nil` | You can set this value to supply basic auth username & password. The secret must have two keys: `username` & `password`. |
| config.basicAuthUsername | string | `nil` | basic auth username. You can also passing this value via secret. To do so, set `basicAuthSecretName` to the secret name. |
| config.id | string | `"default-csw-connector"` | |
| config.usePostRequest | bool | `false` | |
| defaultImage.imagePullSecret | bool | `false` | |
| defaultImage.pullPolicy | string | `"IfNotPresent"` | |
| defaultImage.repository | string | `"docker.io/data61"` | |
| defaultSettings.includeCronJobs | bool | `true` | |
| defaultSettings.includeInitialJobs | bool | `false` | |
| defaultTenantId | int | `0` | |
| global.connectors.image | object | `{}` | |
| global.image | object | `{}` | |
| image.name | string | `"magda-csw-connector"` | |
| resources.limits.cpu | string | `"100m"` | |
| resources.requests.cpu | string | `"50m"` | |
| resources.requests.memory | string | `"30Mi"` | |
2 changes: 1 addition & 1 deletion deploy/magda-csw-connector/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: magda-csw-connector
description: A Helm chart for Magda csw Connector
version: "1.0.0"
version: "1.1.0"
kubeVersion: ">= 1.14.0-0"
home: "https://github.com/magda-io/magda-csw-connector"
sources: [ "https://github.com/magda-io/magda-csw-connector" ]
Expand Down
12 changes: 12 additions & 0 deletions deploy/magda-csw-connector/templates/cronjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ spec:
secretKeyRef:
name: auth-secrets
key: jwt-secret
{{- if .Values.config.basicAuthSecretName }}
- name: BASIC_AUTH_USERNAME
valueFrom:
secretKeyRef:
name: {{ .Values.config.basicAuthSecretName | quote }}
key: username
- name: BASIC_AUTH_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.config.basicAuthSecretName | quote }}
key: password
{{- end }}
restartPolicy: "OnFailure"
volumes:
- name: config
Expand Down
12 changes: 12 additions & 0 deletions deploy/magda-csw-connector/templates/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ spec:
secretKeyRef:
name: auth-secrets
key: jwt-secret
{{- if .Values.config.basicAuthSecretName }}
- name: BASIC_AUTH_USERNAME
valueFrom:
secretKeyRef:
name: {{ .Values.config.basicAuthSecretName | quote }}
key: username
- name: BASIC_AUTH_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.config.basicAuthSecretName | quote }}
key: password
{{- end }}
restartPolicy: "OnFailure"
volumes:
- name: config
Expand Down
20 changes: 19 additions & 1 deletion deploy/magda-csw-connector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,22 @@ config:

## Crontab schedule for how often this should happen.
# default = "0 14 * * 6" i.e. 12am Sydney time on Sunday
# schedule?: string;
# schedule?: string;

# -- Whether or not use POST request to call getRecords API
usePostRequest: false

# -- Whether or not to send basic auth header.
basicAuthEnabled: false

# -- basic auth username. You can also passing this value via secret.
# To do so, set `basicAuthSecretName` to the secret name.
basicAuthUsername:

# -- basic auth password. You can also passing this value via secret.
# To do so, set `basicAuthSecretName` to the secret name.
basicAuthPassword:

# -- You can set this value to supply basic auth username & password.
# The secret must have two keys: `username` & `password`.
basicAuthSecretName:
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@magda/csw-connector",
"description": "MAGDA OGC Catalogue Service for the Web (CSW) Connector",
"version": "1.0.0",
"version": "1.1.0",
"scripts": {
"prebuild": "rimraf dist tsconfig.tsbuildinfo",
"build": "yarn run compile",
Expand All @@ -11,7 +11,7 @@
"watch": "tsc -b --watch",
"start": "node dist/index.js",
"dev": "run-typescript-in-nodemon src/index.ts",
"test": "mocha --require ts-node/register --require tsconfig-paths/register \"src/test/**/*.spec.ts\"",
"test": "mocha --require ts-node/register --require tsconfig-paths/register \"src/test/**/black-box.spec.ts\"",
"docker-build-local": "create-docker-context-for-node-component --build --push --tag auto --local",
"docker-build-prod": "create-docker-context-for-node-component --build --push --tag auto",
"retag-and-push": "retag-and-push",
Expand Down Expand Up @@ -46,8 +46,10 @@
"rimraf": "^3.0.0",
"sinon": "^2.4.1",
"ts-loader": "^6.2.1",
"ts-node": "9.0.0",
"tsconfig-paths": "3.9.0",
"tsconfig-paths-webpack-plugin": "^3.2.0",
"typescript": "^3.7.2",
"typescript": "^3.9.2",
"webpack": "^4.28.3",
"webpack-cli": "^3.3.10"
},
Expand Down
Loading

0 comments on commit 02a0e05

Please sign in to comment.