Skip to content

Commit 95b6a27

Browse files
authored
Merge branch 'main' into react-conversion
2 parents f909c39 + 0ade87d commit 95b6a27

File tree

13 files changed

+82
-123
lines changed

13 files changed

+82
-123
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
strategy:
2121
matrix:
22-
node-version: [18.x]
22+
node-version: [20.x]
2323
mongodb-version: [4.4]
2424

2525
steps:
@@ -45,6 +45,12 @@ jobs:
4545
- name: Install dependencies
4646
run: npm i
4747

48+
# for now only check the types of the server
49+
# tsconfig isn't quite set up right to respect what vite accepts
50+
# for the frontend code
51+
- name: Check Types (Server)
52+
run: npm run check-types:server
53+
4854
- name: Test
4955
id: test
5056
run: |

.github/workflows/experimental-inventory-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
strategy:
2121
matrix:
22-
node-version: [18.x]
22+
node-version: [20.x]
2323
mongodb-version: [4.4]
2424

2525
steps:

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: Code Cleanliness
22

33
on: [pull_request]
44

5-
env: # environment variables (available in any part of the action)
6-
NODE_VERSION: 18
5+
env:
6+
NODE_VERSION: 20
77

88
permissions:
99
contents: read

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
# - uses: actions/checkout@8459bc0 # v4
5353
# - uses: actions/setup-node@c2ac33f # v4, Setup .npmrc file to publish to npm
5454
# with:
55-
# node-version: '18.x'
55+
# node-version: '20.x'
5656
# registry-url: 'https://registry.npmjs.org'
5757
# - run: npm ci
5858
# - run: npm publish --access=public

experimental/li-cli/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

experimental/li-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"devDependencies": {
2323
"@jest/globals": "^29.7.0",
24-
"@types/node": "^22.15.32",
24+
"@types/node": "^22.15.34",
2525
"@types/yargs": "^17.0.33",
2626
"jest": "^29.7.0",
2727
"rimraf": "^6.0.1",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@finos/git-proxy",
3-
"version": "1.18.0",
3+
"version": "1.18.2",
44
"description": "Deploy custom push protections and policies on top of Git.",
55
"scripts": {
66
"cli": "node ./packages/git-proxy-cli/index.js",
@@ -14,6 +14,7 @@
1414
"build-lib": "./scripts/build-for-publish.sh",
1515
"restore-lib": "./scripts/undo-build.sh",
1616
"check-types": "tsc",
17+
"check-types:server": "tsc --project tsconfig.publish.json --noEmit",
1718
"test": "NODE_ENV=test ts-mocha './test/**/*.test.js' --exit",
1819
"test-coverage": "nyc npm run test",
1920
"test-coverage-ci": "nyc --reporter=lcovonly --reporter=text npm run test",

src/config/ConfigLoader.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ export class ConfigLoader extends EventEmitter {
316316
const execOptions = {
317317
cwd: process.cwd(),
318318
env: {
319+
// dont wait for credentials; the command should be sufficiently authed
320+
// https://git-scm.com/docs/git#Documentation/git.txt-codeGITTERMINALPROMPTcode
321+
GIT_TERMINAL_PROMPT: 'false',
319322
...process.env,
320323
...(source.auth?.type === 'ssh'
321324
? {

src/service/routes/auth.js

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
const express = require('express');
22
const router = new express.Router();
33
const passport = require('../passport').getPassport();
4+
const { getAuthMethods } = require('../../config');
5+
const passportLocal = require('../passport/local');
6+
const passportAD = require('../passport/activeDirectory');
47
const authStrategies = require('../passport').authStrategies;
58
const db = require('../../db');
69
const { GIT_PROXY_UI_HOST: uiHost = 'http://localhost', GIT_PROXY_UI_PORT: uiPort = 3000 } =
@@ -23,25 +26,59 @@ router.get('/', (req, res) => {
2326
});
2427
});
2528

26-
router.post('/login', passport.authenticate(authStrategies['local'].type), async (req, res) => {
27-
try {
28-
const currentUser = { ...req.user };
29-
delete currentUser.password;
30-
console.log(
31-
`serivce.routes.auth.login: user logged in, username=${
32-
currentUser.username
33-
} profile=${JSON.stringify(currentUser)}`,
34-
);
35-
res.send({
36-
message: 'success',
37-
user: currentUser,
38-
});
39-
} catch (e) {
40-
console.log(`service.routes.auth.login: Error logging user in ${JSON.stringify(e)}`);
41-
res.status(500).send('Failed to login').end();
42-
return;
29+
// login strategies that will work with /login e.g. take username and password
30+
const appropriateLoginStrategies = [passportLocal.type, passportAD.type];
31+
// getLoginStrategy fetches the enabled auth methods and identifies if there's an appropriate
32+
// auth method for username and password login. If there isn't it returns null, if there is it
33+
// returns the first.
34+
const getLoginStrategy = () => {
35+
// returns only enabled auth methods
36+
// returns at least one enabled auth method
37+
const enabledAppropriateLoginStrategies = getAuthMethods().filter((am) =>
38+
appropriateLoginStrategies.includes(am.type.toLowerCase()),
39+
);
40+
// for where no login strategies which work for /login are enabled
41+
// just return null
42+
if (enabledAppropriateLoginStrategies.length === 0) {
43+
return null;
4344
}
44-
});
45+
// return the first enabled auth method
46+
return enabledAppropriateLoginStrategies[0].type.toLowerCase();
47+
};
48+
49+
// TODO: provide separate auth endpoints for each auth strategy or chain compatibile auth strategies
50+
// TODO: if providing separate auth methods, inform the frontend so it has relevant UI elements and appropriate client-side behavior
51+
router.post(
52+
'/login',
53+
(req, res, next) => {
54+
const authType = getLoginStrategy();
55+
if (authType === null) {
56+
res.status(403).send('Username and Password based Login is not enabled at this time').end();
57+
return;
58+
}
59+
console.log('going to auth with', authType);
60+
return passport.authenticate(authType)(req, res, next);
61+
},
62+
async (req, res) => {
63+
try {
64+
const currentUser = { ...req.user };
65+
delete currentUser.password;
66+
console.log(
67+
`serivce.routes.auth.login: user logged in, username=${
68+
currentUser.username
69+
} profile=${JSON.stringify(currentUser)}`,
70+
);
71+
res.send({
72+
message: 'success',
73+
user: currentUser,
74+
});
75+
} catch (e) {
76+
console.log(`service.routes.auth.login: Error logging user in ${JSON.stringify(e)}`);
77+
res.status(500).send('Failed to login').end();
78+
return;
79+
}
80+
},
81+
);
4582

4683
router.get('/oidc', passport.authenticate(authStrategies['openidconnect'].type));
4784

0 commit comments

Comments
 (0)