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

V3 #6

Merged
merged 13 commits into from
Feb 23, 2025
Merged

V3 #6

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
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14
- name: Use Node.js 18
uses: actions/setup-node@v1
with:
node-version: 14
node-version: 18

- name: Login to GitHub Container Registry
run: |
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Check Helm Chart Document
run: |
code=0
docker run --rm -v "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:v1.5.0 -t ./README.md.gotmpl -o ../../README.md || code=$?;
yarn helm-docs || code=$?;
if [ "$code" != "0" ]; then
echo "Failed to run helm-docs!";
exit 1;
Expand All @@ -40,7 +40,7 @@ jobs:
git ls-files -m | grep -i readme.md || code=$?;
if [ "$code" == "0" ]; then
echo -e "Some of helm chart docs are required to be updated using the [helm-docs](https://github.com/norwoodj/helm-docs) tool. \n
Please run helm-docs (v1.5.0) at project root, review & commit docs changes and push a new commit.";
Please run helm-docs (v1.11.0) at project root, review & commit docs changes and push a new commit.";
exit 1;
else
echo -e "helm docs check passed. helm docs update is not required.";
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Use Node.js 14
- name: Use Node.js 18
uses: actions/setup-node@v1
with:
node-version: 14
node-version: 18

- name: Login to GitHub Container Registry
run: |
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Check Helm Chart Document
run: |
code=0
docker run --rm -v "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:v1.5.0 -t ./README.md.gotmpl -o ../../README.md || code=$?;
yarn helm-docs || code=$?;
if [ "$code" != "0" ]; then
echo "Failed to run helm-docs!";
exit 1;
Expand All @@ -43,7 +43,7 @@ jobs:
git ls-files -m | grep -i readme.md || code=$?;
if [ "$code" == "0" ]; then
echo -e "Some of helm chart docs are required to be updated using the [helm-docs](https://github.com/norwoodj/helm-docs) tool. \n
Please run helm-docs (v1.5.0) at project root, review & commit docs changes and push a new commit.";
Please run helm-docs (v1.11.0) at project root, review & commit docs changes and push a new commit.";
exit 1;
else
echo -e "helm docs check passed. helm docs update is not required.";
Expand Down
14 changes: 14 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 3.0.0

- Upgrade express to v4.21.2
- Upgrade @magda/ci-utils to v1.0.5
- Upgrade @magda/docker-utils to v5.0.0
- Upgrade @magda/auth-api-client to v5.0.0
- Upgrade @magda/authentication-plugin-sdk to v5.0.0
- Upgrade passport to 0.7.0
- Upgrade yargs to 17.7.2
- Build as ESM module
- Upgrade to Node 18
- Code adjustment for yargs upgrade
- fixes: Use __dirname from @magda/esm-utils

# 2.0.1

- add support to allowedExternalRedirectDomains config options
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:14-alpine
FROM node:18-alpine

RUN mkdir -p /usr/src/app
COPY . /usr/src/app
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# magda-auth-google

![Version: 2.0.1](https://img.shields.io/badge/Version-2.0.1-informational?style=flat-square)
![Version: 3.0.0](https://img.shields.io/badge/Version-3.0.0-informational?style=flat-square)

A Magda Authentication Plugin for Google

Expand Down
2 changes: 1 addition & 1 deletion deploy/magda-auth-google/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: magda-auth-google
description: A Magda Authentication Plugin for Google
version: "2.0.1"
version: "3.0.0"
kubeVersion: ">= 1.14.0-0"
home: "https://github.com/magda-io/magda-auth-google"
sources: [ "https://github.com/magda-io/magda-auth-google" ]
Expand Down
57 changes: 35 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,54 @@
{
"name": "magda-auth-google",
"version": "2.0.1",
"version": "3.0.0",
"description": "A Magda Authentication Plugin for Google",
"repository": "https://github.com/magda-io/magda-auth-google.git",
"author": "Jacky Jiang <jacky.jiang@data61.csiro.au>",
"license": "Apache-2.0",
"type": "module",
"private": true,
"scripts": {
"prebuild": "rimraf dist tsconfig.tsbuildinfo",
"build": "tsc -b",
"watch": "tsc -b --watch",
"start": "node dist/index.js",
"dev": "run-typescript-in-nodemon src/index.ts",
"test": "mocha --require ts-node/register \"src/test/**/*.spec.ts\"",
"dev": "tsx src/index.ts",
"test": "mocha",
"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",
"helm-lint": "helm lint deploy/magda-auth-google -f deploy/test-deploy.yaml",
"helm-docs": "helm-docs -t ./README.md.gotmpl -o ../../README.md",
"retag-and-push": "retag-and-push",
"version": "yarn update-helm-chart-version && yarn update-all-charts && yarn add-all-chart-version-changes && yarn add-all-helm-docs-changes",
"helm-lint": "helm template deploy/magda-auth-google -f deploy/test-deploy.yaml 1>/dev/null",
"helm-docs": "docker run --rm -v \"$(pwd):/helm-docs\" -u $(id -u) jnorwood/helm-docs:v1.11.0 -t ./README.md.gotmpl -o ../../README.md",
"update-all-charts": "helm dep up ./deploy/magda-auth-google",
"add-all-chart-version-changes": "git ls-files -m | grep Chart.yaml | xargs git add && git ls-files -m | grep Chart.lock | xargs git add",
"add-all-helm-docs-changes": "yarn helm-docs && git ls-files -m | grep -i readme.md | xargs git add",
"update-all-charts": "helm dep up ./deploy/magda-auth-google"
"version": "yarn update-helm-chart-version && yarn update-all-charts && yarn add-all-chart-version-changes && yarn add-all-helm-docs-changes",
"retag-and-push": "retag-and-push"
},
"devDependencies": {
"@magda/ci-utils": "^1.0.2",
"@magda/docker-utils": "^0.0.60",
"@types/express": "^4.0.37",
"@magda/ci-utils": "^1.0.5",
"@magda/docker-utils": "^5.0.0",
"@types/express": "^4.17.21",
"@types/lodash": "^4.14.162",
"@types/mocha": "^9.1.1",
"@types/passport": "1.0.3",
"@types/passport": "1.0.17",
"@types/serve-static": "^1.15.7",
"@types/urijs": "^1.19.12",
"@types/yargs": "^15.0.9",
"mocha": "^10.0.0",
"@types/yargs": "^17.0.33",
"mocha": "^10.2.0",
"rimraf": "^3.0.2",
"ts-node": "^10.9.1",
"typescript": "^4.2.4"
"tsx": "^4.7.0",
"typescript": "^5.3.3"
},
"dependencies": {
"@magda/auth-api-client": "^2.1.1",
"@magda/authentication-plugin-sdk": "^2.1.1",
"express": "^4.15.4",
"lodash": "^4.17.20",
"passport": "0.2.2",
"@magda/auth-api-client": "^5.0.0",
"@magda/authentication-plugin-sdk": "^5.0.0",
"@magda/esm-utils": "^1.0.1",
"express": "^4.21.2",
"lodash": "^4.17.21",
"passport": "0.7.0",
"passport-google-oauth20": "^2.0.0",
"urijs": "^1.19.11",
"yargs": "^16.1.0"
"yargs": "^17.7.2"
},
"config": {
"docker": {
Expand All @@ -56,6 +59,16 @@
"SESSION_SECRET": "keyboard cat",
"userId": "00000000-0000-4000-8000-000000000000"
},
"mocha": {
"exit": true,
"import": "tsx/esm",
"spec": [
"src/test/**/*.spec.ts"
]
},
"engines": {
"node": ">=18.19.0"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/google.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import express, { Router } from "express";
import { Strategy as GoogleStrategy } from "passport-google-oauth20";
import { Authenticator, Profile } from "passport";
import { default as ApiClient } from "@magda/auth-api-client";
import ApiClient from "@magda/auth-api-client";
import urijs from "urijs";
import {
createOrGetUserToken,
Expand Down
11 changes: 7 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import express from "express";
import path from "path";
import yargs from "yargs";
import google from "./google";
import { hideBin } from "yargs/helpers";
import google from "./google.js";
import AuthApiClient, { UserToken } from "@magda/auth-api-client";
import {
createMagdaSessionRouter,
AuthPluginConfig
} from "@magda/authentication-plugin-sdk";
import { __dirname } from "@magda/esm-utils";

const coerceJson = (path?: string) => path && require(path);

const argv = yargs
const argv = yargs(hideBin(process.argv))
.config()
.help()
.option("listenPort", {
Expand Down Expand Up @@ -101,7 +103,8 @@ const argv = yargs
"The user id to use when making authenticated requests to the registry",
type: "string",
default: process.env.USER_ID || process.env.npm_package_config_userId
}).argv;
})
.parseSync();

const authPluginConfig = argv.authPluginConfigJson as any as AuthPluginConfig;
const allowedExternalRedirectDomains = argv
Expand All @@ -121,7 +124,7 @@ app.get("/healthz", (req, res) => res.send("OK"));
* a 36x36 size icon to be shown on frontend login page
*/
app.get("/icon.svg", (req, res) =>
res.sendFile(path.resolve(__dirname, "../assets/google-logo.svg"))
res.sendFile(path.resolve(__dirname(), "../assets/google-logo.svg"))
);

/**
Expand Down
4 changes: 2 additions & 2 deletions tsconfig-global.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "ES2015" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"module": "Node16" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"lib": [
"es2015",
"es2017",
Expand Down Expand Up @@ -45,7 +45,7 @@
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */

/* Module Resolution Options */
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
"moduleResolution": "node16" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
"baseUrl": "./src" /* Base directory to resolve non-absolute module names. */,
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
Expand Down
Loading
Loading