Require publicUrl to be an origin URL and detect Slack OIDC by hostname - #156
Open
salluexez wants to merge 1 commit into
Open
Require publicUrl to be an origin URL and detect Slack OIDC by hostname#156salluexez wants to merge 1 commit into
salluexez wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR tightens configuration validation to prevent misconfigured base URLs and to treat Slack OIDC issuers more robustly by identifying Slack issuers via hostname rather than a single literal issuer string.
Changes:
- Enforce
publicUrlas an HTTP(S) origin-only URL during CLI config validation (no credentials, paths, query/fragment, or trailing hostname dot). - Detect Slack OIDC issuers by hostname (
slack.com/*.slack.com) instead of exact string comparison when deciding whether JWKS configuration is required. - Add unit tests covering the new
publicUrlorigin validation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| plugins/portal/src/index.ts | Updates runtime boot checks to treat Slack issuers by hostname via a new isSlackIssuer helper. |
| cli/src/config.ts | Tightens publicUrl validation and updates portal trust validation to use hostname-based Slack issuer detection. |
| cli/test/config.test.ts | Adds tests ensuring publicUrl is validated as an HTTP(S) origin and normalized consistently. |
Suppressed comments (1)
cli/src/config.ts:509
publicUrlorigin validation doesn’t reject URLs with an empty hostname (e.g.https:///).new URL("https:///")parses with protocolhttps:and pathname/, so this currently passes validation and then normalizes tohttps://, which is not a usable public origin. Add an explicit non-empty hostname check (and consider keepingapiUrlvalidation in sync, since it uses the same pattern).
const parsed = new URL(publicUrl);
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") throw new Error("protocol");
if (parsed.pathname !== "/" || parsed.search || parsed.hash || parsed.username || parsed.password)
throw new Error("origin");
if (parsed.hostname.endsWith(".")) throw new Error("trailing dot");
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+804
to
+811
| function isSlackIssuer(issuer: string): boolean { | ||
| try { | ||
| const host = new URL(issuer).hostname; | ||
| return host === "slack.com" || host.endsWith(".slack.com"); | ||
| } catch { | ||
| return false; | ||
| } | ||
| } |
Comment on lines
+91
to
+99
| for (const publicUrl of [ | ||
| "", | ||
| "not a url", | ||
| "ftp://acme.example", | ||
| "https://acme.example/subpath", | ||
| "https://acme.example?x=1", | ||
| "https://user:pw@acme.example", | ||
| "https://acme.example.", | ||
| ]) { |
Comment on lines
500
to
504
| const publicUrl = o["publicUrl"]; | ||
| if (typeof publicUrl !== "string" || !publicUrl.trim()) { | ||
| throw new CliError(`${path}: "publicUrl" must be a non-empty http(s) URL`); | ||
| throw new CliError(`${path}: "publicUrl" must be a non-empty http(s) origin URL`); | ||
| } | ||
| try { |
Comment on lines
+121
to
+128
| function isSlackIssuer(issuer: string): boolean { | ||
| try { | ||
| const host = new URL(issuer).hostname; | ||
| return host === "slack.com" || host.endsWith(".slack.com"); | ||
| } catch { | ||
| return false; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
publicUrlto be an HTTP(S) origin URL (without credentials, subpaths, queries, fragments, or trailing dots) across all target environments during CLI configuration validation.slack.comor*.slack.com) rather than an exact literal string comparison.cli/test/config.test.ts.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.