Skip to content

Commit d1c6c26

Browse files
committed
feat: add uiRouteAuth setting to config
1 parent 86784f0 commit d1c6c26

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

config.schema.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@
8888
"cert": { "type": "string" }
8989
},
9090
"required": ["enabled", "key", "cert"]
91+
},
92+
"uiRouteAuth": {
93+
"description": "UI routes that require authentication (logged in or admin)",
94+
"type": "object",
95+
"properties": {
96+
"enabled": { "type": "boolean" },
97+
"rules": {
98+
"type": "array",
99+
"items": {
100+
"$ref": "#/definitions/routeAuthRule"
101+
}
102+
}
103+
}
91104
}
92105
},
93106
"definitions": {
@@ -119,6 +132,14 @@
119132
"options": { "type": "object" }
120133
},
121134
"required": ["type", "enabled"]
135+
},
136+
"routeAuthRule": {
137+
"type": "object",
138+
"properties": {
139+
"pattern": { "type": "string" },
140+
"adminOnly": { "type": "boolean" },
141+
"loginRequired": { "type": "boolean" }
142+
}
122143
}
123144
},
124145
"additionalProperties": false

proxy.config.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,5 +102,20 @@
102102
"enabled": true,
103103
"key": "certs/key.pem",
104104
"cert": "certs/cert.pem"
105+
},
106+
"uiRouteAuth": {
107+
"enabled": false,
108+
"rules": [
109+
{
110+
"pattern": "/dashboard/*",
111+
"adminOnly": false,
112+
"loginRequired": true
113+
},
114+
{
115+
"pattern": "/admin/*",
116+
"adminOnly": true,
117+
"loginRequired": true
118+
}
119+
]
105120
}
106121
}

src/config/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ let _domains: Record<string, unknown> = defaultSettings.domains;
3434
let _tlsEnabled = defaultSettings.tls.enabled;
3535
let _tlsKeyPemPath = defaultSettings.tls.key;
3636
let _tlsCertPemPath = defaultSettings.tls.cert;
37+
let _uiRouteAuth: Record<string, unknown> = defaultSettings.uiRouteAuth;
3738

3839
// Get configured proxy URL
3940
export const getProxyUrl = () => {
@@ -217,3 +218,10 @@ export const getDomains = () => {
217218
}
218219
return _domains;
219220
};
221+
222+
export const getUIRouteAuth = () => {
223+
if (_userSettings && _userSettings.uiRouteAuth) {
224+
_uiRouteAuth = _userSettings.uiRouteAuth;
225+
}
226+
return _uiRouteAuth;
227+
};

0 commit comments

Comments
 (0)