Skip to content

Commit c4a4423

Browse files
committed
Merge branch 'main' into 1150-vitest-migration-from-service
2 parents 7a198e3 + b198b31 commit c4a4423

File tree

8 files changed

+326
-133
lines changed

8 files changed

+326
-133
lines changed

config.schema.json

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"properties": {
88
"proxyUrl": {
99
"type": "string",
10-
"description": "Used in early versions of git proxy to configure the remote host that traffic is proxied to. In later versions, the repository URL is used to determine the domain proxied, allowing multiple hosts to be proxied by one instance.",
10+
"description": "Deprecated: Used in early versions of git proxy to configure the remote host that traffic is proxied to. In later versions, the repository URL is used to determine the domain proxied, allowing multiple hosts to be proxied by one instance.",
1111
"deprecated": true
1212
},
1313
"cookieSecret": { "type": "string" },
@@ -27,19 +27,34 @@
2727
"https://somedomain.com/some/path/checkUserGroups?domain=<domain>&name=<name>&id=<id>"
2828
]
2929
}
30-
}
30+
},
31+
"additionalProperties": false
3132
},
3233
"github": {
3334
"type": "object",
35+
"description": "Deprecated: Defunct property that was used to provide the API URL for GitHub. No longer referenced in the codebase.",
3436
"properties": {
3537
"baseUrl": {
3638
"type": "string",
3739
"format": "uri",
38-
"examples": ["https://api.github.com"]
40+
"examples": ["https://api.github.com"],
41+
"deprecated": true
3942
}
43+
},
44+
"additionalProperties": false
45+
},
46+
"gitleaks": {
47+
"type": "object",
48+
"description": "Configuration for the gitleaks (https://github.com/gitleaks/gitleaks) plugin",
49+
"properties": {
50+
"enabled": { "type": "boolean" },
51+
"ignoreGitleaksAllow": { "type": "boolean" },
52+
"noColor": { "type": "boolean" },
53+
"configPath": { "type": "string" }
4054
}
4155
}
42-
}
56+
},
57+
"additionalProperties": false
4358
},
4459
"commitConfig": {
4560
"description": "Enforce rules and patterns on commits including e-mail and message",

cypress/e2e/login.cy.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,4 @@ describe('Login page', () => {
4040
.should('be.visible')
4141
.and('contain', 'You entered an invalid username or password...');
4242
});
43-
44-
describe('OIDC login button', () => {
45-
it('should exist', () => {
46-
cy.get('[data-test="oidc-login"]').should('exist');
47-
});
48-
49-
// Validates that OIDC is configured correctly
50-
it('should redirect to /oidc', () => {
51-
// Set intercept first, since redirect on click can be quick
52-
cy.intercept('GET', '/api/auth/oidc').as('oidcRedirect');
53-
cy.get('[data-test="oidc-login"]').click();
54-
cy.wait('@oidcRedirect');
55-
});
56-
});
5743
});

src/config/generated/config.ts

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ export interface GitProxyConfig {
6363
*/
6464
privateOrganizations?: any[];
6565
/**
66-
* Used in early versions of git proxy to configure the remote host that traffic is proxied
67-
* to. In later versions, the repository URL is used to determine the domain proxied,
68-
* allowing multiple hosts to be proxied by one instance.
66+
* Deprecated: Used in early versions of git proxy to configure the remote host that traffic
67+
* is proxied to. In later versions, the repository URL is used to determine the domain
68+
* proxied, allowing multiple hosts to be proxied by one instance.
6969
*/
7070
proxyUrl?: string;
7171
/**
@@ -108,18 +108,39 @@ export interface GitProxyConfig {
108108
* Third party APIs
109109
*/
110110
export interface API {
111+
/**
112+
* Deprecated: Defunct property that was used to provide the API URL for GitHub. No longer
113+
* referenced in the codebase.
114+
*/
111115
github?: Github;
116+
/**
117+
* Configuration for the gitleaks (https://github.com/gitleaks/gitleaks) plugin
118+
*/
119+
gitleaks?: Gitleaks;
112120
/**
113121
* Configuration used in conjunction with ActiveDirectory auth, which relates to a REST API
114122
* used to check user group membership, as opposed to direct querying via LDAP.<br />If this
115123
* configuration is set direct querying of group membership via LDAP will be disabled.
116124
*/
117125
ls?: Ls;
118-
[property: string]: any;
119126
}
120127

128+
/**
129+
* Deprecated: Defunct property that was used to provide the API URL for GitHub. No longer
130+
* referenced in the codebase.
131+
*/
121132
export interface Github {
122133
baseUrl?: string;
134+
}
135+
136+
/**
137+
* Configuration for the gitleaks (https://github.com/gitleaks/gitleaks) plugin
138+
*/
139+
export interface Gitleaks {
140+
configPath?: string;
141+
enabled?: boolean;
142+
ignoreGitleaksAllow?: boolean;
143+
noColor?: boolean;
123144
[property: string]: any;
124145
}
125146

@@ -139,7 +160,6 @@ export interface Ls {
139160
* membership of.</li><li>"&lt;id&gt;": The username to check group membership for.</li></ul>
140161
*/
141162
userInADGroup?: string;
142-
[property: string]: any;
143163
}
144164

145165
/**
@@ -540,12 +560,22 @@ const typeMap: any = {
540560
API: o(
541561
[
542562
{ json: 'github', js: 'github', typ: u(undefined, r('Github')) },
563+
{ json: 'gitleaks', js: 'gitleaks', typ: u(undefined, r('Gitleaks')) },
543564
{ json: 'ls', js: 'ls', typ: u(undefined, r('Ls')) },
544565
],
566+
false,
567+
),
568+
Github: o([{ json: 'baseUrl', js: 'baseUrl', typ: u(undefined, '') }], false),
569+
Gitleaks: o(
570+
[
571+
{ json: 'configPath', js: 'configPath', typ: u(undefined, '') },
572+
{ json: 'enabled', js: 'enabled', typ: u(undefined, true) },
573+
{ json: 'ignoreGitleaksAllow', js: 'ignoreGitleaksAllow', typ: u(undefined, true) },
574+
{ json: 'noColor', js: 'noColor', typ: u(undefined, true) },
575+
],
545576
'any',
546577
),
547-
Github: o([{ json: 'baseUrl', js: 'baseUrl', typ: u(undefined, '') }], 'any'),
548-
Ls: o([{ json: 'userInADGroup', js: 'userInADGroup', typ: u(undefined, '') }], 'any'),
578+
Ls: o([{ json: 'userInADGroup', js: 'userInADGroup', typ: u(undefined, '') }], false),
549579
AuthenticationElement: o(
550580
[
551581
{ json: 'enabled', js: 'enabled', typ: true },

src/service/routes/auth.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ const loginSuccessHandler = () => async (req: Request, res: Response) => {
7373
}
7474
};
7575

76+
router.get('/config', (req, res) => {
77+
const usernamePasswordMethod = getLoginStrategy();
78+
res.send({
79+
// enabled username /password auth method
80+
usernamePasswordMethod: usernamePasswordMethod,
81+
// other enabled auth methods
82+
otherMethods: getAuthMethods()
83+
.map((am) => am.type.toLowerCase())
84+
.filter((authType) => authType !== usernamePasswordMethod),
85+
});
86+
});
87+
7688
// TODO: provide separate auth endpoints for each auth strategy or chain compatibile auth strategies
7789
// TODO: if providing separate auth methods, inform the frontend so it has relevant UI elements and appropriate client-side behavior
7890
router.post(
@@ -89,9 +101,9 @@ router.post(
89101
loginSuccessHandler(),
90102
);
91103

92-
router.get('/oidc', passport.authenticate(authStrategies['openidconnect'].type));
104+
router.get('/openidconnect', passport.authenticate(authStrategies['openidconnect'].type));
93105

94-
router.get('/oidc/callback', (req: Request, res: Response, next: NextFunction) => {
106+
router.get('/openidconnect/callback', (req: Request, res: Response, next: NextFunction) => {
95107
passport.authenticate(authStrategies['openidconnect'].type, (err: any, user: any, info: any) => {
96108
if (err) {
97109
console.error('Authentication error:', err);

src/ui/services/auth.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const getAxiosConfig = () => {
3232
return {
3333
withCredentials: true,
3434
headers: {
35-
'X-CSRF-TOKEN': getCookie('csrf'),
35+
'X-CSRF-TOKEN': getCookie('csrf') || '',
3636
Authorization: jwtToken ? `Bearer ${jwtToken}` : undefined,
3737
},
3838
};
@@ -43,9 +43,9 @@ export const getAxiosConfig = () => {
4343
* @param {Object} error - The error object
4444
* @return {string} The error message
4545
*/
46-
export const processAuthError = (error) => {
46+
export const processAuthError = (error, jwtAuthEnabled = false) => {
4747
let errorMessage = `Failed to authorize user: ${error.response.data.trim()}. `;
48-
if (!localStorage.getItem('ui_jwt_token')) {
48+
if (jwtAuthEnabled && !localStorage.getItem('ui_jwt_token')) {
4949
errorMessage +=
5050
'Set your JWT token in the settings page or disable JWT auth in your app configuration.';
5151
} else {

0 commit comments

Comments
 (0)