MCPcopy Index your code
hub / github.com/coder/code-server / authenticated

Function authenticated

src/node/http.ts:117–139  ·  view source on GitHub ↗
(req: express.Request)

Source from the content-addressed store, hash-verified

115 * Return true if authenticated via cookies.
116 */
117export const authenticated = async (req: express.Request): Promise<boolean> => {
118 switch (req.args.auth) {
119 case AuthType.None: {
120 return true
121 }
122 case AuthType.Password: {
123 // The password is stored in the cookie after being hashed.
124 const hashedPasswordFromArgs = req.args["hashed-password"]
125 const passwordMethod = getPasswordMethod(hashedPasswordFromArgs)
126 const isCookieValidArgs: IsCookieValidArgs = {
127 passwordMethod,
128 cookieKey: sanitizeString(req.cookies[req.cookieSessionName]),
129 passwordFromArgs: req.args.password || "",
130 hashedPasswordFromArgs: req.args["hashed-password"],
131 }
132
133 return await isCookieValid(isCookieValidArgs)
134 }
135 default: {
136 throw new Error(`Unsupported auth type ${req.args.auth}`)
137 }
138 }
139}
140
141/**
142 * Get the relative path that will get us to the root of the page. For each

Callers 5

domainProxy.tsFile · 0.90
login.tsFile · 0.90
vscode.tsFile · 0.90
proxyFunction · 0.90
ensureAuthenticatedFunction · 0.85

Calls 3

getPasswordMethodFunction · 0.90
sanitizeStringFunction · 0.90
isCookieValidFunction · 0.90

Tested by

no test coverage detected