Skip to content

Commit

Permalink
Add --noauth option to pxt serve (#9725)
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders-ms authored Oct 17, 2023
1 parent 6c094bd commit 0a4f209
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2854,7 +2854,8 @@ export function serveAsync(parsed: commandParser.ParsedCommand) {
wsPort: parsed.flags["wsport"] as number || 0,
hostname: parsed.flags["hostname"] as string || "",
browser: parsed.flags["browser"] as string,
serial: !parsed.flags["noSerial"] && !globalConfig.noSerial
serial: !parsed.flags["noSerial"] && !globalConfig.noSerial,
noauth: parsed.flags["noauth"] as boolean || false,
}))
}

Expand Down Expand Up @@ -6922,6 +6923,10 @@ ${pxt.crowdin.KEY_VARIABLE} - crowdin key
aliases: ["w"],
type: "number",
argument: "wsport"
},
noauth: {
description: "disable localtoken-based authentication",
aliases: ["na"],
}
}
}, serveAsync);
Expand Down
3 changes: 2 additions & 1 deletion cli/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ export interface ServeOptions {
hostname?: string;
wsPort?: number;
serial?: boolean;
noauth?: boolean;
}

// can use http://localhost:3232/streams/nnngzlzxslfu for testing
Expand Down Expand Up @@ -1089,7 +1090,7 @@ export function serveAsync(options: ServeOptions) {
})
}

if (!isAuthorizedLocalRequest(req)) {
if (!options.noauth && !isAuthorizedLocalRequest(req)) {
error(403);
return null;
}
Expand Down

0 comments on commit 0a4f209

Please sign in to comment.