Skip to content
Closed
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
21 changes: 0 additions & 21 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -416,19 +416,6 @@
}
}
},
"uiRouteAuth": {
"description": "UI routes that require authentication (logged in or admin)",
"type": "object",
"properties": {
"enabled": { "type": "boolean" },
"rules": {
"type": "array",
"items": {
"$ref": "#/definitions/routeAuthRule"
}
}
}
},
"ssh": {
"description": "SSH proxy server configuration. The proxy uses SSH agent forwarding to authenticate with remote Git servers (GitHub, GitLab, etc.) using the client's SSH keys. The proxy's own host key is auto-generated and only used to identify the proxy to connecting clients.",
"type": "object",
Expand Down Expand Up @@ -809,14 +796,6 @@
}
]
},
"routeAuthRule": {
"type": "object",
"properties": {
"pattern": { "type": "string" },
"adminOnly": { "type": "boolean" },
"loginRequired": { "type": "boolean" }
}
},
"roleMapping": {
"type": "object",
"description": "Mapping of application roles to JWT claims. Each key is a role name, and its value is an object mapping claim names to expected values.",
Expand Down
11 changes: 6 additions & 5 deletions cypress/e2e/navigation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('Navigation & Shell', () => {
cy.get('[data-testid="dashboard-nav-desktop-repositories"]').should('be.visible');
cy.get('[data-testid="dashboard-nav-desktop-activity"]').should('be.visible');
cy.get('[data-testid="dashboard-nav-desktop-users"]').should('be.visible');
cy.get('[data-testid="dashboard-header-settings"]').should('be.visible');
});

it('Navbar links navigate correctly', () => {
Expand All @@ -42,9 +41,6 @@ describe('Navigation & Shell', () => {
cy.get('[data-testid="dashboard-nav-desktop-users"]').click();
cy.url().should('include', '/dashboard/admin/user');

cy.get('[data-testid="dashboard-header-settings"]').click();
cy.url().should('include', '/dashboard/admin/settings');

cy.get('[data-testid="dashboard-nav-desktop-repositories"]').click();
cy.url().should('include', '/dashboard/repo');
});
Expand Down Expand Up @@ -78,10 +74,15 @@ describe('Navigation & Shell', () => {
});

describe('Unauthenticated access', () => {
it('Unauthenticated user is redirected to /login from the profile page', () => {
it('Unauthenticated user is redirected to /login from dashboard pages', () => {
cy.logout();
cy.visit('/dashboard/profile');
cy.url().should('include', '/login');

cy.visit('/dashboard/repo');
cy.url().should('include', '/login');

cy.visit('/dashboard/admin/user');
cy.url().should('include', '/login');
});
});
6 changes: 2 additions & 4 deletions cypress/e2e/repo.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ describe('Repo', () => {
cy.visit('/dashboard/repo');
});

it('Prevents anonymous users from adding repos', () => {
cy.get('[data-testid="repo-list-view"]')
.find('[data-testid="add-repo-button"]')
.should('not.exist');
it('Redirects anonymous users to /login', () => {
cy.url().should('include', '/login');
});
});

Expand Down
69 changes: 0 additions & 69 deletions cypress/e2e/settings.cy.js

This file was deleted.

12 changes: 10 additions & 2 deletions cypress/e2e/user-list.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,18 @@ describe('User List (Admin)', () => {
cy.get('[data-testid="profile-name"]').should('contain', listedUser.username);
});

it('Non-admin access follows the configured route rules', () => {
it('Non-admin users are redirected to /not-authorized', () => {
cy.login(listedUser.username, listedUser.password);
cy.visit('/dashboard/admin/user');

cy.url().should('match', /\/(dashboard\/admin\/user|not-authorized|login)/);
cy.url().should('include', '/not-authorized');
});

it('Non-admin users do not see the Users nav link', () => {
cy.login(listedUser.username, listedUser.password);
cy.visit('/dashboard/repo');

cy.get('[data-testid="dashboard-nav-desktop-repositories"]').should('be.visible');
cy.get('[data-testid="dashboard-nav-desktop-users"]').should('not.exist');
});
});
15 changes: 0 additions & 15 deletions proxy.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,21 +206,6 @@
"key": "certs/key.pem",
"cert": "certs/cert.pem"
},
"uiRouteAuth": {
"enabled": false,
"rules": [
{
"pattern": "/dashboard/*",
"adminOnly": false,
"loginRequired": true
},
{
"pattern": "/admin/*",
"adminOnly": true,
"loginRequired": true
}
]
},
"ssh": {
"enabled": false,
"port": 2222,
Expand Down
36 changes: 0 additions & 36 deletions src/config/generated/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ export interface GitProxyConfig {
* GIT_PROXY_UI_PORT environment variable, which takes precedence over this value.
*/
uiPort?: number;
/**
* UI routes that require authentication (logged in or admin)
*/
uiRouteAuth?: UIRouteAuth;
/**
* Configuration for routing outbound requests to upstream Git hosts via an HTTP(S) proxy.
*/
Expand Down Expand Up @@ -827,22 +823,6 @@ export interface TLS {
[property: string]: any;
}

/**
* UI routes that require authentication (logged in or admin)
*/
export interface UIRouteAuth {
enabled?: boolean;
rules?: RouteAuthRule[];
[property: string]: any;
}

export interface RouteAuthRule {
adminOnly?: boolean;
loginRequired?: boolean;
pattern?: string;
[property: string]: any;
}

/**
* Configuration for routing outbound requests to upstream Git hosts via an HTTP(S) proxy.
*/
Expand Down Expand Up @@ -1121,7 +1101,6 @@ const typeMap: any = {
{ json: 'tls', js: 'tls', typ: u(undefined, r('TLS')) },
{ json: 'uiHost', js: 'uiHost', typ: u(undefined, '') },
{ json: 'uiPort', js: 'uiPort', typ: u(undefined, 3.14) },
{ json: 'uiRouteAuth', js: 'uiRouteAuth', typ: u(undefined, r('UIRouteAuth')) },
{ json: 'upstreamProxy', js: 'upstreamProxy', typ: u(undefined, r('UpstreamProxy')) },
{ json: 'urlShortener', js: 'urlShortener', typ: u(undefined, '') },
],
Expand Down Expand Up @@ -1382,21 +1361,6 @@ const typeMap: any = {
],
'any',
),
UIRouteAuth: o(
[
{ json: 'enabled', js: 'enabled', typ: u(undefined, true) },
{ json: 'rules', js: 'rules', typ: u(undefined, a(r('RouteAuthRule'))) },
],
'any',
),
RouteAuthRule: o(
[
{ json: 'adminOnly', js: 'adminOnly', typ: u(undefined, true) },
{ json: 'loginRequired', js: 'loginRequired', typ: u(undefined, true) },
{ json: 'pattern', js: 'pattern', typ: u(undefined, '') },
],
'any',
),
UpstreamProxy: o(
[
{ json: 'auth', js: 'auth', typ: u(undefined, r('Auth')) },
Expand Down
6 changes: 0 additions & 6 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const REQUIRED_TOP_LEVEL_CONFIG_KEYS = [
'tls',
'uiHost',
'uiPort',
'uiRouteAuth',
'upstreamProxy',
'urlShortener',
] as const satisfies readonly RequiredTopLevelConfigKey[];
Expand Down Expand Up @@ -520,11 +519,6 @@ export const getDomains = () => {
return config.domains;
};

export const getUIRouteAuth = () => {
const config = loadFullConfiguration();
return config.uiRouteAuth;
};

export const getRateLimit = () => {
const config = loadFullConfiguration();
return config.rateLimit;
Expand Down
30 changes: 7 additions & 23 deletions src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,72 +22,56 @@ import User from './ui/views/User/UserProfile';
import UserList from './ui/views/UserList/UserList';
import RepoDetails from './ui/views/RepoDetails/RepoDetails';
import RepoList from './ui/views/RepoList/RepoList';
import SettingsView from './ui/views/Settings/Settings';

import { Route } from './ui/types';

const dashboardRoutes: Route[] = [
{
path: '/repo',
name: 'Repositories',
component: (props) => <RouteGuard component={RepoList} fullRoutePath={`/dashboard/repo`} />,
component: () => <RouteGuard component={RepoList} />,
layout: '/dashboard',
visible: true,
},
{
path: '/repo/:id',
name: 'Repo Details',
component: (props) => (
<RouteGuard component={RepoDetails} fullRoutePath={`/dashboard/repo/:id`} />
),
component: () => <RouteGuard component={RepoDetails} />,
layout: '/dashboard',
visible: false,
},
{
path: '/push',
name: 'Activity',
component: (props) => <RouteGuard component={PushRequests} fullRoutePath={`/dashboard/push`} />,
component: () => <RouteGuard component={PushRequests} />,
layout: '/dashboard',
visible: true,
},
{
path: '/push/:id',
name: 'Open Push Requests',
component: (props) => (
<RouteGuard component={PushDetails} fullRoutePath={`/dashboard/push/:id`} />
),
component: () => <RouteGuard component={PushDetails} />,
layout: '/dashboard',
visible: false,
},
{
path: '/profile',
name: 'My Account',
component: (props) => <RouteGuard component={User} fullRoutePath={`/dashboard/profile`} />,
component: () => <RouteGuard component={User} />,
layout: '/dashboard',
visible: false,
},
{
path: '/admin/user',
name: 'Users',
component: (props) => (
<RouteGuard component={UserList} fullRoutePath={`/dashboard/admin/user`} />
),
component: () => <RouteGuard component={UserList} />,
layout: '/dashboard',
visible: true,
},
{
path: '/user/:id',
name: 'User',
component: (props) => <RouteGuard component={User} fullRoutePath={`/dashboard/user/:id`} />,
layout: '/dashboard',
visible: false,
},
{
path: '/admin/settings',
name: 'Settings',
component: (props) => (
<RouteGuard component={SettingsView} fullRoutePath={`/dashboard/admin/settings`} />
),
component: () => <RouteGuard component={User} />,
layout: '/dashboard',
visible: false,
},
Expand Down
4 changes: 0 additions & 4 deletions src/service/routes/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ router.get('/contactEmail', (_req: Request, res: Response) => {
res.send(config.getContactEmail());
});

router.get('/uiRouteAuth', (_req: Request, res: Response) => {
res.send(config.getUIRouteAuth());
});

router.get('/scmProviders', (_req: Request, res: Response) => {
res.send(getProviders().map(({ name, type, host }) => ({ name, type, host })));
});
Expand Down
Loading
Loading