-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add allowedIpRanges widgets config #833
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Adds widgets config (`allowedIpRanges`) option to control which IPs are allowed to access widgets. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,6 +340,7 @@ interface BridgeWidgetConfigYAML { | |
addOnInvite?: boolean; | ||
}; | ||
disallowedIpRanges?: string[]; | ||
allowedIpRanges?: string[]; | ||
branding?: { | ||
widgetTitle: string, | ||
} | ||
|
@@ -357,6 +358,8 @@ export class BridgeWidgetConfig { | |
addOnInvite?: boolean; | ||
}; | ||
public readonly disallowedIpRanges?: string[]; | ||
public readonly allowedIpRanges?: string[]; | ||
|
||
public readonly branding: { | ||
widgetTitle: string, | ||
} | ||
|
@@ -366,10 +369,14 @@ export class BridgeWidgetConfig { | |
constructor(yaml: BridgeWidgetConfigYAML) { | ||
this.addToAdminRooms = yaml.addToAdminRooms || false; | ||
this.disallowedIpRanges = yaml.disallowedIpRanges; | ||
this.allowedIpRanges = yaml.allowedIpRanges; | ||
this.roomSetupWidget = yaml.roomSetupWidget; | ||
if (yaml.disallowedIpRanges !== undefined && (!Array.isArray(yaml.disallowedIpRanges) || !yaml.disallowedIpRanges.every(s => typeof s === "string"))) { | ||
throw new ConfigError("widgets.disallowedIpRanges", "must be a string array"); | ||
} | ||
if (yaml.allowedIpRanges !== undefined && (!Array.isArray(yaml.allowedIpRanges) || !yaml.allowedIpRanges.every(s => typeof s === "string"))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. N.B. An empty array would skip this, would we allow empty values for allowedIpRanges (effectively blocking the feature entirely, seems a bit pointless :) ) |
||
throw new ConfigError("widgets.allowedIpRanges", "must be a string array"); | ||
} | ||
try { | ||
this.parsedPublicUrl = makePrefixedUrl(yaml.publicUrl) | ||
this.publicUrl = () => { return this.parsedPublicUrl.href; } | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ export const DefaultConfigRoot: BridgeConfigRoot = { | |
roomSetupWidget: { | ||
addOnInvite: false, | ||
}, | ||
allowedIpRanges: [], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wondering if we want this to actually show up as a default, because the default value would block everything currently :) |
||
disallowedIpRanges: DefaultDisallowedIpRanges, | ||
branding: { | ||
widgetTitle: "Hookshot Configuration" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we would put in some examples of values here?