Skip to content

Commit 07371f6

Browse files
authored
Merge pull request #462 from immobiliare/next
Next
2 parents 1f76565 + 4d497f0 commit 07371f6

File tree

8 files changed

+2747
-1846
lines changed

8 files changed

+2747
-1846
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [6.5.1-alpha.0](https://github.com/immobiliare/backstage-plugin-gitlab/compare/v6.5.0...v6.5.1-alpha.0) (2024-05-16)
7+
8+
**Note:** Version bump only for package root
9+
610
# [6.5.0](https://github.com/immobiliare/backstage-plugin-gitlab/compare/v6.5.0-alpha.0...v6.5.0) (2024-04-11)
711

812
**Note:** Version bump only for package root

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"useNx": true,
44
"useWorkspaces": true,
55
"npmClient": "yarn",
6-
"version": "6.5.0"
6+
"version": "6.5.1-alpha.0"
77
}

packages/gitlab-backend/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [6.5.1-alpha.0](https://github.com/immobiliare/backstage-plugin-gitlab/compare/v6.5.0...v6.5.1-alpha.0) (2024-05-16)
7+
8+
**Note:** Version bump only for package @immobiliarelabs/backstage-plugin-gitlab-backend
9+
610
# [6.5.0](https://github.com/immobiliare/backstage-plugin-gitlab/compare/v6.5.0-alpha.0...v6.5.0) (2024-04-11)
711

812
**Note:** Version bump only for package @immobiliarelabs/backstage-plugin-gitlab-backend

packages/gitlab-backend/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@immobiliarelabs/backstage-plugin-gitlab-backend",
3-
"version": "6.5.0",
3+
"version": "6.5.1-alpha.0",
44
"main": "dist/index.cjs.js",
55
"types": "dist/index.d.ts",
66
"license": "Apache-2.0",
@@ -36,10 +36,10 @@
3636
"postpack": "backstage-cli package postpack"
3737
},
3838
"dependencies": {
39-
"@backstage/backend-common": "^0.20.1",
40-
"@backstage/backend-plugin-api": "^0.6.7",
41-
"@backstage/config": "^1.1.1",
42-
"@backstage/integration": "^1.7.0",
39+
"@backstage/backend-common": "^0.22.0",
40+
"@backstage/backend-plugin-api": "^0.6.18",
41+
"@backstage/config": "^1.2.0",
42+
"@backstage/integration": "^1.11.0",
4343
"body-parser": "^1.20.2",
4444
"express": "^4.17.3",
4545
"express-promise-router": "^4.1.0",
@@ -48,11 +48,11 @@
4848
"yn": "^4.0.0"
4949
},
5050
"devDependencies": {
51-
"@backstage/backend-test-utils": "^0.2.8",
52-
"@backstage/catalog-model": "^1.4.0",
53-
"@backstage/cli": "^0.22.8",
54-
"@backstage/plugin-catalog-common": "^1.0.14",
55-
"@backstage/plugin-catalog-node": "^1.3.7",
51+
"@backstage/backend-test-utils": "^0.3.8",
52+
"@backstage/catalog-model": "^1.5.0",
53+
"@backstage/cli": "^0.26.5",
54+
"@backstage/plugin-catalog-common": "^1.0.23",
55+
"@backstage/plugin-catalog-node": "^1.12.0",
5656
"@types/express": "^4.17.21",
5757
"@types/supertest": "^2.0.12",
5858
"msw": "^1.0.0",

packages/gitlab-backend/src/service/router.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { Logger } from 'winston';
1010
import { createProxyMiddleware } from 'http-proxy-middleware';
1111
import { Request } from 'http-proxy-middleware/dist/types';
1212
import bodyParser from 'body-parser';
13+
import { IncomingHttpHeaders } from 'http';
1314

1415
function getBasePath(config: Config) {
1516
const baseUrl = config.getOptionalString('backend.baseUrl');
@@ -19,6 +20,16 @@ function getBasePath(config: Config) {
1920
return new URL(baseUrl).pathname.replace(/\/$/, '');
2021
}
2122

23+
function headersManipulation(headers: IncomingHttpHeaders) {
24+
// Remove Backstage authorization before forwarding to GitLab
25+
if (headers['authorization']) delete headers['authorization'];
26+
// Forward authorization, this header is defined when gitlab.useOAuth is true
27+
if (headers['gitlab-authorization']) {
28+
headers['authorization'] = headers['gitlab-authorization'] as string;
29+
delete headers['gitlab-authorization'];
30+
}
31+
}
32+
2233
export interface RouterOptions {
2334
logger: Logger;
2435
config: Config;
@@ -49,26 +60,12 @@ export async function createRouter(
4960
// fires _after_ the agent has already sent the headers to the proxy
5061
// target, causing a ERR_HTTP_HEADERS_SENT crash
5162
const filter = (_pathname: string, req: Request): boolean => {
52-
if (req.headers['authorization']) delete req.headers['authorization'];
53-
// Forward authorization, this header is defined when gitlab.useOAuth is true
54-
if (req.headers['gitlab-authorization']) {
55-
req.headers['authorization'] = req.headers[
56-
'gitlab-authorization'
57-
] as string;
58-
delete req.headers['gitlab-authorization'];
59-
}
63+
headersManipulation(req.headers);
6064
return req.method === 'GET';
6165
};
6266

6367
const graphqlFilter = (_pathname: string, req: Request): boolean => {
64-
if (req.headers['authorization']) delete req.headers['authorization'];
65-
// Forward authorization, this header is defined when gitlab.useOAuth is true
66-
if (req.headers['gitlab-authorization']) {
67-
req.headers['authorization'] = req.headers[
68-
'gitlab-authorization'
69-
] as string;
70-
delete req.headers['gitlab-authorization'];
71-
}
68+
headersManipulation(req.headers);
7269
return req.method === 'POST' && !req.body.query?.includes('mutation');
7370
};
7471

packages/gitlab/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [6.5.1-alpha.0](https://github.com/immobiliare/backstage-plugin-gitlab/compare/v6.5.0...v6.5.1-alpha.0) (2024-05-16)
7+
8+
**Note:** Version bump only for package @immobiliarelabs/backstage-plugin-gitlab
9+
610
# [6.5.0](https://github.com/immobiliare/backstage-plugin-gitlab/compare/v6.5.0-alpha.0...v6.5.0) (2024-04-11)
711

812
**Note:** Version bump only for package @immobiliarelabs/backstage-plugin-gitlab

packages/gitlab/package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@immobiliarelabs/backstage-plugin-gitlab",
3-
"version": "6.5.0",
3+
"version": "6.5.1-alpha.0",
44
"main": "dist/index.esm.js",
55
"types": "dist/index.d.ts",
66
"license": "Apache-2.0",
@@ -35,10 +35,10 @@
3535
"postpack": "backstage-cli package postpack"
3636
},
3737
"dependencies": {
38-
"@backstage/core-components": "^0.13.8",
39-
"@backstage/core-plugin-api": "^1.8.0",
40-
"@backstage/plugin-catalog-react": "^1.9.0",
41-
"@backstage/theme": "^0.4.4",
38+
"@backstage/core-components": "^0.14.7",
39+
"@backstage/core-plugin-api": "^1.9.2",
40+
"@backstage/plugin-catalog-react": "^1.12.0",
41+
"@backstage/theme": "^0.5.4",
4242
"@material-ui/core": "^4.12.2",
4343
"@material-ui/icons": "^4.9.1",
4444
"@material-ui/lab": "4.0.0-alpha.61",
@@ -54,14 +54,14 @@
5454
"react-router-dom": "6.0.0-beta.0 || ^6.20.0"
5555
},
5656
"devDependencies": {
57-
"@backstage/cli": "^0.24.0",
58-
"@backstage/core-app-api": "^1.11.0",
59-
"@backstage/dev-utils": "^1.0.24",
60-
"@backstage/plugin-catalog-react": "^1.9.1",
61-
"@backstage/test-utils": "^1.4.0",
57+
"@backstage/cli": "^0.26.5",
58+
"@backstage/core-app-api": "^1.12.5",
59+
"@backstage/dev-utils": "^1.0.32",
60+
"@backstage/plugin-catalog-react": "^1.12.0",
61+
"@backstage/test-utils": "^1.5.5",
6262
"@commitlint/cli": "^17.0.0",
6363
"@commitlint/config-conventional": "^17.0.0",
64-
"@gitbeaker/rest": "^39.0.0",
64+
"@gitbeaker/rest": "^40.0.2",
6565
"@nuxtjs/eslint-config-typescript": "^12.0.0",
6666
"@saithodev/semantic-release-backmerge": "^2.0.0",
6767
"@semantic-release/changelog": "^6.0.1",
@@ -70,7 +70,7 @@
7070
"@semantic-release/github": "^9.0.7",
7171
"@semantic-release/npm": "^9.0.0",
7272
"@semantic-release/release-notes-generator": "^10.0.2",
73-
"@testing-library/jest-dom": "^5.12.0",
73+
"@testing-library/jest-dom": "^6.4.5",
7474
"@testing-library/react": "^14.1.2",
7575
"@testing-library/user-event": "^14.3.0",
7676
"@types/jest": "^29.5.1",
@@ -82,7 +82,7 @@
8282
"eslint-config-prettier": "^8.5.0",
8383
"eslint-plugin-prettier": "^4.2.1",
8484
"husky": "^8.0.0",
85-
"prettier": "^2.0.5",
85+
"prettier": "^3.2.5",
8686
"react": "^18.0.2",
8787
"react-dom": "^18.0.2",
8888
"react-router": "^6.3.0",

0 commit comments

Comments
 (0)