forked from coder/code-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/ui-789-custom-auth' into 'main'
feat: pluggable authentication system See merge request ui/code-server!1
- Loading branch information
Showing
11 changed files
with
107 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { CodeServerCustomAuth } from "../../typings/customauth" | ||
|
||
let customAuth: CodeServerCustomAuth | undefined = undefined | ||
|
||
/** | ||
* Set the custom authentication module to use. | ||
* Only one such module can be used at a time. | ||
*/ | ||
export async function registerCustomAuth(auth: CodeServerCustomAuth) { | ||
await auth.initialize() | ||
customAuth = auth | ||
} | ||
|
||
/** | ||
* Get the last registered custom authentication module. | ||
*/ | ||
export function getCustomAuth(): CodeServerCustomAuth | undefined { | ||
return customAuth | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import type { Request, Response, Router } from "express" | ||
|
||
/** | ||
* Modules assigned to the custom-auth-module configuration option | ||
* must export a "customAuth" property implementing this interface. | ||
*/ | ||
export interface CodeServerCustomAuth { | ||
/** | ||
* A GET request to the "/" path of the loginRouter is made when the user needs to login. | ||
*/ | ||
readonly loginRouter: Router | ||
|
||
/** | ||
* A GET request to the "/" path of the logoutRouter is made when the user needs to logout. | ||
*/ | ||
readonly logoutRouter: Router | ||
|
||
/** | ||
* Runs once when code-server starts. It will block startup until the returned | ||
* promise resolves. | ||
*/ | ||
initialize(): Promise<void> | ||
|
||
/** | ||
* Tells if the user is authenticated and authorized. | ||
* | ||
* @param req the request that needs to be authorized. | ||
* @param res the current response. | ||
* @returns true if the user is authorized, false otherwise. | ||
*/ | ||
authenticated(req: Request, res: Response): Promise<boolean> | ||
} |