-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add GET authentication #2428
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
Add GET authentication #2428
Changes from all commits
ae1a57f
5069722
c757171
c26b8bf
bf03423
6f473cd
3961ce9
fe110da
b83c22a
f4ac75e
716f6bd
a28624d
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ import { | |
optionDescriptions, | ||
parse, | ||
readConfigFile, | ||
writeConfigFile, | ||
setDefaults, | ||
shouldOpenInExistingInstance, | ||
shouldRunVsCodeCli, | ||
|
@@ -19,7 +20,7 @@ import { coderCloudBind } from "./coder_cloud" | |
import { commit, version } from "./constants" | ||
import * as proxyAgent from "./proxy_agent" | ||
import { register } from "./routes" | ||
import { humanPath, isFile, open } from "./util" | ||
import { humanPath, isFile, open, generatePassword } from "./util" | ||
import { isChild, wrapper } from "./wrapper" | ||
|
||
export const runVsCodeCli = (args: DefaultedArgs): void => { | ||
|
@@ -125,6 +126,10 @@ const main = async (args: DefaultedArgs): Promise<void> => { | |
logger.info(` - Authentication is disabled ${args.link ? "(disabled by --link)" : ""}`) | ||
} | ||
|
||
if (args["enable-get-requests"]) { | ||
logger.info(` - Login via GET is enabled ${args.auth === AuthType.None ? "(however auth is disabled)" : ""}`) | ||
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. Should we just skip this output entirely if auth is disabled? 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. I thought that it might seem intrusive to people who are just using normal POST passwords. |
||
} | ||
|
||
if (args.cert) { | ||
logger.info(` - Using certificate for HTTPS: ${humanPath(args.cert.value)}`) | ||
} else { | ||
|
@@ -202,6 +207,55 @@ async function entry(): Promise<void> { | |
return | ||
} | ||
|
||
if (args.tokens) { | ||
args.tokens = args.tokens[0].split(",") | ||
} | ||
|
||
if (args["list-tokens"]) { | ||
console.log("code-server", version, commit) | ||
console.log("") | ||
if (!args.tokens) { | ||
return console.log("No tokens currently exist") | ||
} | ||
console.log("Tokens") | ||
args.tokens.forEach(token => { | ||
console.log(" -", token) | ||
}) | ||
return | ||
} | ||
|
||
if (args["generate-token"]) { | ||
console.log("code-server", version, commit) | ||
console.log("") | ||
|
||
if (!args.tokens) { | ||
args.tokens = [] | ||
} | ||
|
||
const token = await generatePassword() | ||
args.tokens.push(token) | ||
writeConfigFile(cliArgs.config, { tokens: args.tokens }) | ||
console.log("Generated token:", token) | ||
return | ||
} | ||
|
||
if (args["revoke-token"]) { | ||
console.log("code-server", version, commit) | ||
console.log("") | ||
|
||
if (args.tokens?.includes(args["revoke-token"])) { | ||
args.tokens = args.tokens.filter(token => { | ||
return token != args["revoke-token"] | ||
}) | ||
writeConfigFile(cliArgs.config, { tokens: args.tokens }) | ||
console.log("The token has successfully been revoked") | ||
} | ||
else { | ||
console.log("The token specified does not exist") | ||
} | ||
return | ||
} | ||
|
||
if (shouldRunVsCodeCli(args)) { | ||
return runVsCodeCli(args) | ||
} | ||
|
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.
What do you think about naming this
enable-get-auth
or something withauth
in the name?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.
If we went the token route we could call it
enable-token-auth
or something.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.
That seems quick and concise! I might try that. :) Yeah, I agree that tokens seem to be safer.