File tree 2 files changed +12
-9
lines changed
2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ export interface UserProvidedArgs extends UserProvidedCodeArgs {
80
80
"bind-addr" ?: string
81
81
socket ?: string
82
82
"socket-mode" ?: string
83
+ "trusted-origins" ?: string [ ]
83
84
version ?: boolean
84
85
"proxy-domain" ?: string [ ]
85
86
"reuse-window" ?: boolean
@@ -165,12 +166,6 @@ export const options: Options<Required<UserProvidedArgs>> = {
165
166
"session-socket" : {
166
167
type : "string" ,
167
168
} ,
168
- "disable-authenticate-origin" : {
169
- type : "boolean" ,
170
- description :
171
- "Disable check that the origin of the request is the same as the host. Notice that this disables a safety feature. \n" +
172
- "(Useful when using a reverse proxy)" ,
173
- } ,
174
169
"disable-file-downloads" : {
175
170
type : "boolean" ,
176
171
description :
@@ -215,6 +210,11 @@ export const options: Options<Required<UserProvidedArgs>> = {
215
210
216
211
socket : { type : "string" , path : true , description : "Path to a socket (bind-addr will be ignored)." } ,
217
212
"socket-mode" : { type : "string" , description : "File mode of the socket." } ,
213
+ "trusted-origins" : {
214
+ type : "string[]" ,
215
+ description :
216
+ "Disables authenticate origin check for trusted origin. Useful if not able to access reverse proxy configuration." ,
217
+ } ,
218
218
version : { type : "boolean" , short : "v" , description : "Display version information." } ,
219
219
_ : { type : "string[]" } ,
220
220
Original file line number Diff line number Diff line change @@ -327,9 +327,7 @@ function getFirstHeader(req: http.IncomingMessage, headerName: string): string |
327
327
*/
328
328
export function ensureOrigin ( req : express . Request , _ ?: express . Response , next ?: express . NextFunction ) : void {
329
329
try {
330
- if ( ! req . args [ "disable-authenticate-origin" ] ) {
331
- authenticateOrigin ( req )
332
- }
330
+ authenticateOrigin ( req )
333
331
if ( next ) {
334
332
next ( )
335
333
}
@@ -357,6 +355,11 @@ export function authenticateOrigin(req: express.Request): void {
357
355
throw new Error ( `unable to parse malformed origin "${ originRaw } "` )
358
356
}
359
357
358
+ const trustedOrigins = req . args [ "trusted-origins" ] || [ ]
359
+ if ( trustedOrigins . includes ( origin ) || trustedOrigins . includes ( "*" ) ) {
360
+ return
361
+ }
362
+
360
363
const host = getHost ( req )
361
364
if ( typeof host === "undefined" ) {
362
365
// A missing host likely means the reverse proxy has not been configured to
You can’t perform that action at this time.
0 commit comments