Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d7c588536 | |||
| b6debcbb59 | |||
| 5847bc5795 | |||
| e662415137 | |||
| 580b087e8a | |||
| ac3c405cb2 |
@@ -28,6 +28,7 @@ jobs:
|
|||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node_version: 20
|
node_version: 20
|
||||||
|
cache: 'pnpm'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
@@ -68,6 +69,7 @@ jobs:
|
|||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node_version: 20
|
node_version: 20
|
||||||
|
cache: 'pnpm'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
@@ -79,12 +81,28 @@ jobs:
|
|||||||
pnpm release:tag
|
pnpm release:tag
|
||||||
|
|
||||||
build-images:
|
build-images:
|
||||||
name: 🐳 Build & Push Images
|
name: 🐳 Build ${{ matrix.name }}
|
||||||
needs: qa
|
needs: qa
|
||||||
if: startsWith(github.ref, 'refs/tags/v')
|
if: startsWith(github.ref, 'refs/tags/v')
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:act-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- image: nextjs
|
||||||
|
file: packages/infra/docker/Dockerfile.nextjs
|
||||||
|
name: Build-Base
|
||||||
|
- image: runtime
|
||||||
|
file: packages/infra/docker/Dockerfile.runtime
|
||||||
|
name: Production Runtime
|
||||||
|
- image: gatekeeper
|
||||||
|
file: packages/infra/docker/Dockerfile.gatekeeper
|
||||||
|
name: Gatekeeper (Product)
|
||||||
|
- image: directus
|
||||||
|
file: packages/infra/docker/Dockerfile.directus
|
||||||
|
name: Directus (Base)
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -99,58 +117,19 @@ jobs:
|
|||||||
username: ${{ secrets.REGISTRY_USER }}
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
password: ${{ secrets.REGISTRY_PASS }}
|
password: ${{ secrets.REGISTRY_PASS }}
|
||||||
|
|
||||||
- name: 🏗️ Build & Push Nextjs Build-Base
|
- name: 🏗️ Build & Push ${{ matrix.name }}
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
file: packages/infra/docker/Dockerfile.nextjs
|
file: ${{ matrix.file }}
|
||||||
platforms: linux/arm64
|
platforms: linux/arm64
|
||||||
pull: true
|
pull: true
|
||||||
push: true
|
push: true
|
||||||
secrets: |
|
secrets: |
|
||||||
NPM_TOKEN=${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN=${{ secrets.NPM_TOKEN }}
|
||||||
tags: |
|
tags: |
|
||||||
registry.infra.mintel.me/mintel/nextjs:${{ github.ref_name }}
|
registry.infra.mintel.me/mintel/${{ matrix.image }}:${{ github.ref_name }}
|
||||||
registry.infra.mintel.me/mintel/nextjs:latest
|
registry.infra.mintel.me/mintel/${{ matrix.image }}:latest
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
- name: 🏗️ Build & Push Production Runtime
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: packages/infra/docker/Dockerfile.runtime
|
|
||||||
platforms: linux/arm64
|
|
||||||
pull: true
|
|
||||||
push: true
|
|
||||||
secrets: |
|
|
||||||
NPM_TOKEN=${{ secrets.NPM_TOKEN }}
|
|
||||||
tags: |
|
|
||||||
registry.infra.mintel.me/mintel/runtime:${{ github.ref_name }}
|
|
||||||
registry.infra.mintel.me/mintel/runtime:latest
|
|
||||||
|
|
||||||
- name: 🏗️ Build & Push Gatekeeper (Product)
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: packages/infra/docker/Dockerfile.gatekeeper
|
|
||||||
platforms: linux/arm64
|
|
||||||
pull: true
|
|
||||||
push: true
|
|
||||||
secrets: |
|
|
||||||
NPM_TOKEN=${{ secrets.NPM_TOKEN }}
|
|
||||||
tags: |
|
|
||||||
registry.infra.mintel.me/mintel/gatekeeper:${{ github.ref_name }}
|
|
||||||
registry.infra.mintel.me/mintel/gatekeeper:latest
|
|
||||||
|
|
||||||
- name: 🏗️ Build & Push Directus (Base)
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
file: packages/infra/docker/Dockerfile.directus
|
|
||||||
platforms: linux/arm64
|
|
||||||
pull: true
|
|
||||||
push: true
|
|
||||||
secrets: |
|
|
||||||
NPM_TOKEN=${{ secrets.NPM_TOKEN }}
|
|
||||||
tags: |
|
|
||||||
registry.infra.mintel.me/mintel/directus:${{ github.ref_name }}
|
|
||||||
registry.infra.mintel.me/mintel/directus:latest
|
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,6 +1,7 @@
|
|||||||
# dependencies
|
# dependencies
|
||||||
node_modules
|
node_modules
|
||||||
.pnpm-debug.log*
|
.pnpm-debug.log*
|
||||||
|
.pnpm-store/
|
||||||
|
|
||||||
# next.js
|
# next.js
|
||||||
.next/
|
.next/
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
"@mintel/husky-config": "workspace:*",
|
"@mintel/husky-config": "workspace:*",
|
||||||
"@testing-library/jest-dom": "^6.9.1",
|
"@testing-library/jest-dom": "^6.9.1",
|
||||||
"@testing-library/react": "^16.3.2",
|
"@testing-library/react": "^16.3.2",
|
||||||
|
"@types/node": "^20.17.16",
|
||||||
"@types/react": "^19.2.10",
|
"@types/react": "^19.2.10",
|
||||||
"@types/react-dom": "^19.2.3",
|
"@types/react-dom": "^19.2.3",
|
||||||
"@vitejs/plugin-react": "^5.1.2",
|
"@vitejs/plugin-react": "^5.1.2",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"mintel": "./dist/index.js"
|
"mintel": "./dist/index.js"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsup src/index.ts --format esm --target es2020",
|
"build": "tsup",
|
||||||
"start": "node dist/index.js",
|
"start": "node dist/index.js",
|
||||||
"dev": "tsup src/index.ts --format esm --watch --target es2020",
|
"dev": "tsup src/index.ts --format esm --watch --target es2020",
|
||||||
"test": "vitest run"
|
"test": "vitest run"
|
||||||
@@ -28,4 +28,4 @@
|
|||||||
"@types/prompts": "^2.4.4",
|
"@types/prompts": "^2.4.4",
|
||||||
"@mintel/tsconfig": "workspace:*"
|
"@mintel/tsconfig": "workspace:*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
11
packages/cli/tsup.config.ts
Normal file
11
packages/cli/tsup.config.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { defineConfig } from 'tsup';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
entry: ['src/index.ts'],
|
||||||
|
format: ['esm'],
|
||||||
|
target: 'es2020',
|
||||||
|
clean: true,
|
||||||
|
banner: {
|
||||||
|
js: '#!/usr/bin/env node',
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -1,40 +1,41 @@
|
|||||||
import { dirname } from "path";
|
import nextPlugin from "@next/eslint-plugin-next";
|
||||||
import { fileURLToPath } from "url";
|
import reactPlugin from "eslint-plugin-react";
|
||||||
import { FlatCompat } from "@eslint/eslintrc";
|
import hooksPlugin from "eslint-plugin-react-hooks";
|
||||||
|
import tseslint from "typescript-eslint";
|
||||||
|
import js from "@eslint/js";
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
/**
|
||||||
const __dirname = dirname(__filename);
|
* Mintel Next.js ESLint Configuration (Flat Config)
|
||||||
|
*
|
||||||
const compat = new FlatCompat({
|
* This configuration replaces the legacy 'eslint-config-next' which
|
||||||
baseDirectory: __dirname,
|
* relies on @rushstack/eslint-patch and causes issues in ESLint 9.
|
||||||
});
|
*/
|
||||||
|
export const nextConfig = tseslint.config(
|
||||||
export const nextConfig = [
|
|
||||||
{
|
|
||||||
ignores: [
|
|
||||||
"**/dist/**",
|
|
||||||
"**/build/**",
|
|
||||||
"**/out/**",
|
|
||||||
"**/coverage/**",
|
|
||||||
"**/.next/**",
|
|
||||||
"**/node_modules/**",
|
|
||||||
"**/.gitea/**",
|
|
||||||
"**/.changeset/**",
|
|
||||||
"**/.vercel/**",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
...compat.extends("next/core-web-vitals", "next/typescript"),
|
|
||||||
{
|
{
|
||||||
|
plugins: {
|
||||||
|
"react": reactPlugin,
|
||||||
|
"react-hooks": hooksPlugin,
|
||||||
|
"@next/next": nextPlugin,
|
||||||
|
},
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
// Add common browser/node globals if needed,
|
||||||
|
// though usually handled by base configs
|
||||||
|
},
|
||||||
|
},
|
||||||
rules: {
|
rules: {
|
||||||
"@typescript-eslint/no-explicit-any": "off",
|
...reactPlugin.configs.recommended.rules,
|
||||||
"@typescript-eslint/no-unused-vars": [
|
...hooksPlugin.configs.recommended.rules,
|
||||||
"warn",
|
...nextPlugin.configs.recommended.rules,
|
||||||
{ argsIgnorePattern: "^_" },
|
...nextPlugin.configs["core-web-vitals"].rules,
|
||||||
],
|
"react/react-in-jsx-scope": "off",
|
||||||
"@typescript-eslint/no-require-imports": "off",
|
|
||||||
"prefer-const": "warn",
|
|
||||||
"react/no-unescaped-entities": "off",
|
"react/no-unescaped-entities": "off",
|
||||||
"@next/next/no-img-element": "warn",
|
"@next/next/no-img-element": "warn",
|
||||||
},
|
},
|
||||||
},
|
settings: {
|
||||||
];
|
react: {
|
||||||
|
version: "detect",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|||||||
@@ -20,7 +20,10 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint/eslintrc": "^3.0.0",
|
"@eslint/eslintrc": "^3.0.0",
|
||||||
"@eslint/js": "^9.39.2",
|
"@eslint/js": "^9.39.2",
|
||||||
|
"@next/eslint-plugin-next": "15.1.6",
|
||||||
"eslint-config-next": "15.1.6",
|
"eslint-config-next": "15.1.6",
|
||||||
|
"eslint-plugin-react": "^7.37.5",
|
||||||
|
"eslint-plugin-react-hooks": "^7.0.1",
|
||||||
"typescript-eslint": "^8.54.0"
|
"typescript-eslint": "^8.54.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import mintelNextConfig from "@mintel/next-config";
|
|||||||
import { NextConfig } from "next";
|
import { NextConfig } from "next";
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
// Gatekeeper specific overrides
|
basePath: '/gatekeeper',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default mintelNextConfig(nextConfig);
|
export default mintelNextConfig(nextConfig);
|
||||||
|
|||||||
@@ -9,6 +9,45 @@ export async function GET(req: NextRequest) {
|
|||||||
|
|
||||||
const session = cookieStore.get(authCookieName);
|
const session = cookieStore.get(authCookieName);
|
||||||
|
|
||||||
|
// 1. URL Parameter Bypass (for automated tests/staging)
|
||||||
|
const originalUrl = req.headers.get("x-forwarded-uri") || "/";
|
||||||
|
const host =
|
||||||
|
req.headers.get("x-forwarded-host") || req.headers.get("host") || "";
|
||||||
|
const proto = req.headers.get("x-forwarded-proto") || "https";
|
||||||
|
|
||||||
|
try {
|
||||||
|
const url = new URL(originalUrl, `${proto}://${host}`);
|
||||||
|
if (url.searchParams.get("gk_bypass") === password) {
|
||||||
|
// Remove the bypass parameter from the redirect URL
|
||||||
|
url.searchParams.delete("gk_bypass");
|
||||||
|
const cleanUrl = url.pathname + url.search;
|
||||||
|
const absoluteCleanUrl = `${proto}://${host}${cleanUrl}`;
|
||||||
|
|
||||||
|
const response = NextResponse.redirect(absoluteCleanUrl);
|
||||||
|
|
||||||
|
// Set the session cookie so the bypass is persistent
|
||||||
|
const isDev = process.env.NODE_ENV === "development";
|
||||||
|
const cookieDomain = process.env.COOKIE_DOMAIN;
|
||||||
|
const sessionValue = JSON.stringify({
|
||||||
|
identity: "Bypass",
|
||||||
|
timestamp: Date.now(),
|
||||||
|
});
|
||||||
|
|
||||||
|
response.cookies.set(authCookieName, sessionValue, {
|
||||||
|
httpOnly: true,
|
||||||
|
secure: !isDev,
|
||||||
|
path: "/",
|
||||||
|
maxAge: 30 * 24 * 60 * 60, // 30 days
|
||||||
|
sameSite: "lax",
|
||||||
|
...(cookieDomain ? { domain: cookieDomain } : {}),
|
||||||
|
});
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// URL parsing failed, proceed with normal logic
|
||||||
|
}
|
||||||
|
|
||||||
let isAuthenticated = false;
|
let isAuthenticated = false;
|
||||||
let identity = "Guest";
|
let identity = "Guest";
|
||||||
|
|
||||||
@@ -38,11 +77,6 @@ export async function GET(req: NextRequest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Traefik ForwardAuth headers
|
// Traefik ForwardAuth headers
|
||||||
const originalUrl = req.headers.get("x-forwarded-uri") || "/";
|
|
||||||
const host =
|
|
||||||
req.headers.get("x-forwarded-host") || req.headers.get("host") || "";
|
|
||||||
const proto = req.headers.get("x-forwarded-proto") || "https";
|
|
||||||
|
|
||||||
const gatekeeperUrl =
|
const gatekeeperUrl =
|
||||||
process.env.NEXT_PUBLIC_BASE_URL || `${proto}://gatekeeper.${host}`;
|
process.env.NEXT_PUBLIC_BASE_URL || `${proto}://gatekeeper.${host}`;
|
||||||
const absoluteOriginalUrl = `${proto}://${host}${originalUrl}`;
|
const absoluteOriginalUrl = `${proto}://${host}${originalUrl}`;
|
||||||
|
|||||||
@@ -79,9 +79,11 @@ export default async function LoginPage({ searchParams }: LoginPageProps) {
|
|||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isDev = process.env.NODE_ENV === "development";
|
||||||
|
|
||||||
cookieStore.set(authCookieName, sessionValue, {
|
cookieStore.set(authCookieName, sessionValue, {
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
secure: true,
|
secure: !isDev,
|
||||||
path: "/",
|
path: "/",
|
||||||
maxAge: 30 * 24 * 60 * 60, // 30 days
|
maxAge: 30 * 24 * 60 * 60, // 30 days
|
||||||
sameSite: "lax",
|
sameSite: "lax",
|
||||||
|
|||||||
14
pnpm-lock.yaml
generated
14
pnpm-lock.yaml
generated
@@ -29,6 +29,9 @@ importers:
|
|||||||
'@testing-library/react':
|
'@testing-library/react':
|
||||||
specifier: ^16.3.2
|
specifier: ^16.3.2
|
||||||
version: 16.3.2(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.10))(@types/react@19.2.10)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
|
version: 16.3.2(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.10))(@types/react@19.2.10)(react-dom@19.2.4(react@19.2.4))(react@19.2.4)
|
||||||
|
'@types/node':
|
||||||
|
specifier: ^20.17.16
|
||||||
|
version: 20.19.30
|
||||||
'@types/react':
|
'@types/react':
|
||||||
specifier: ^19.2.10
|
specifier: ^19.2.10
|
||||||
version: 19.2.10
|
version: 19.2.10
|
||||||
@@ -166,9 +169,18 @@ importers:
|
|||||||
'@eslint/js':
|
'@eslint/js':
|
||||||
specifier: ^9.39.2
|
specifier: ^9.39.2
|
||||||
version: 9.39.2
|
version: 9.39.2
|
||||||
|
'@next/eslint-plugin-next':
|
||||||
|
specifier: 15.1.6
|
||||||
|
version: 15.1.6
|
||||||
eslint-config-next:
|
eslint-config-next:
|
||||||
specifier: 15.1.6
|
specifier: 15.1.6
|
||||||
version: 15.1.6(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3)
|
version: 15.1.6(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3)
|
||||||
|
eslint-plugin-react:
|
||||||
|
specifier: ^7.37.5
|
||||||
|
version: 7.37.5(eslint@9.39.2(jiti@2.6.1))
|
||||||
|
eslint-plugin-react-hooks:
|
||||||
|
specifier: ^7.0.1
|
||||||
|
version: 7.0.1(eslint@9.39.2(jiti@2.6.1))
|
||||||
typescript-eslint:
|
typescript-eslint:
|
||||||
specifier: ^8.54.0
|
specifier: ^8.54.0
|
||||||
version: 8.54.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3)
|
version: 8.54.0(eslint@9.39.2(jiti@2.6.1))(typescript@5.9.3)
|
||||||
@@ -8566,7 +8578,7 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
array-union: 2.1.0
|
array-union: 2.1.0
|
||||||
dir-glob: 3.0.1
|
dir-glob: 3.0.1
|
||||||
fast-glob: 3.3.1
|
fast-glob: 3.3.3
|
||||||
ignore: 5.3.2
|
ignore: 5.3.2
|
||||||
merge2: 1.4.1
|
merge2: 1.4.1
|
||||||
slash: 3.0.0
|
slash: 3.0.0
|
||||||
|
|||||||
Reference in New Issue
Block a user