Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vscode-dts/vscode.proposed.authenticationChallenges.d.ts
5251 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
declare module 'vscode' {
7
8
// https://github.com/microsoft/vscode/issues/267992
9
// and historically: https://github.com/microsoft/vscode/issues/260156
10
11
/**********
12
* "Extension providing auth" API
13
* NOTE: This doesn't need to be finalized with the above
14
*******/
15
16
/**
17
* Represents an authentication challenge from a WWW-Authenticate header.
18
* This is used to handle cases where additional authentication steps are required,
19
* such as when mandatory multi-factor authentication (MFA) is enforced.
20
*
21
* @note For more information on WWW-Authenticate please see https://developer.mozilla.org/docs/Web/HTTP/Reference/Headers/WWW-Authenticate
22
*/
23
export interface AuthenticationChallenge {
24
/**
25
* The authentication scheme (e.g., 'Bearer').
26
*/
27
readonly scheme: string;
28
29
/**
30
* Parameters for the authentication challenge.
31
* For Bearer challenges, this may include 'claims', 'scope', 'realm', etc.
32
*/
33
readonly params: Record<string, string>;
34
}
35
36
/**
37
* Represents constraints for authentication, including challenges and optional scopes.
38
* This is used when creating or retrieving sessions that must satisfy specific authentication
39
* requirements from WWW-Authenticate headers.
40
*
41
* @note For more information on WWW-Authenticate please see https://developer.mozilla.org/docs/Web/HTTP/Reference/Headers/WWW-Authenticate
42
*/
43
export interface AuthenticationConstraint {
44
/**
45
* Array of authentication challenges parsed from WWW-Authenticate headers.
46
*/
47
readonly challenges: readonly AuthenticationChallenge[];
48
49
/**
50
* Optional scopes for the session. If not provided, the authentication provider
51
* may extract scopes from the challenges or use default scopes.
52
*/
53
readonly fallbackScopes?: readonly string[];
54
}
55
56
/**
57
* An authentication provider that supports challenge-based authentication.
58
* This extends the base AuthenticationProvider with methods to handle authentication
59
* challenges from WWW-Authenticate headers.
60
*
61
* TODO: Enforce that both of these functions should be defined by creating a new AuthenticationProviderWithChallenges interface.
62
* But this can be done later since this part doesn't need finalization.
63
*/
64
export interface AuthenticationProvider {
65
/**
66
* Get existing sessions that match the given authentication constraints.
67
*
68
* @param constraint The authentication constraint containing challenges and optional scopes
69
* @param options Options for the session request
70
* @returns A thenable that resolves to an array of existing authentication sessions
71
*/
72
getSessionsFromChallenges?(constraint: AuthenticationConstraint, options: AuthenticationProviderSessionOptions): Thenable<readonly AuthenticationSession[]>;
73
74
/**
75
* Create a new session based on authentication constraints.
76
* This is called when no existing session matches the constraint requirements.
77
*
78
* @param constraint The authentication constraint containing challenges and optional scopes
79
* @param options Options for the session creation
80
* @returns A thenable that resolves to a new authentication session
81
*/
82
createSessionFromChallenges?(constraint: AuthenticationConstraint, options: AuthenticationProviderSessionOptions): Thenable<AuthenticationSession>;
83
}
84
85
export interface AuthenticationProviderOptions {
86
supportsChallenges?: boolean;
87
}
88
}
89
90