Skip to content

Commit c91199f

Browse files
authored
Update for MFA shapes, remove unneeded proposed, confirmed CUD behaves as expected (#4714)
* Update for MFA shapes, remove unneeded proposed, confirmed CUD behaves as expected * Add typing files in order to appease compiler
1 parent 8174d0d commit c91199f

File tree

7 files changed

+318
-111
lines changed

7 files changed

+318
-111
lines changed

package-lock.json

Lines changed: 111 additions & 100 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,12 +1481,12 @@
14811481
"@azure/core-client": "^1.7.3",
14821482
"@azure/core-rest-pipeline": "^1.11.0",
14831483
"@azure/storage-blob": "^12.5.0",
1484-
"@microsoft/vscode-azext-azureappservice": "^3.6.4",
1485-
"@microsoft/vscode-azext-azureappsettings": "^0.2.8",
1486-
"@microsoft/vscode-azext-azureutils": "^3.4.10",
1487-
"@microsoft/vscode-azext-utils": "^3.3.3",
1488-
"@microsoft/vscode-azureresources-api": "^2.5.1",
1489-
"@microsoft/vscode-container-client": "^0.1.2",
1484+
"@microsoft/vscode-azext-azureappservice": "^3.6.7",
1485+
"@microsoft/vscode-azext-azureappsettings": "^0.2.11",
1486+
"@microsoft/vscode-azext-azureutils": "^3.5.2",
1487+
"@microsoft/vscode-azext-utils": "^3.5.0",
1488+
"@microsoft/vscode-azureresources-api": "^2.6.2",
1489+
"@microsoft/vscode-container-client": "^0.4.3",
14901490
"cross-fetch": "^4.0.0",
14911491
"escape-string-regexp": "^4.0.0",
14921492
"extract-zip": "^2.0.1",

src/commands/createFunctionApp/FunctionAppCreateStep.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStepWithActivityOut
105105
},
106106
scaleAndConcurrency: {
107107
maximumInstanceCount: context.newFlexMaximumInstanceCount ?? sku.maximumInstanceCount.defaultValue,
108-
instanceMemoryMB: context.newFlexInstanceMemoryMB ?? sku.instanceMemoryMB.find(im => im.isDefault)?.size ?? 2048,
108+
instanceMemoryMB: context.newFlexInstanceMemoryMB ?? Number.parseInt(sku.instanceMemoryMB.find(im => im.isDefault)?.size ?? '2048'),
109109
alwaysReady: [],
110110
triggers: undefined
111111
},
112-
}
112+
};
113113

114114
return site;
115115

src/commands/createFunctionApp/flex/InstanceMemoryMBPromptStep.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ export class InstanceMemoryMBPromptStep extends AzureWizardPromptStep<IFlexFunct
2525
public configureBeforePrompt(context: IFlexFunctionAppWizardContext): void | Promise<void> {
2626
// use default instance memory size if not using advanced creation
2727
if (!context.advancedCreation) {
28-
context.newFlexInstanceMemoryMB = context.newFlexSku?.instanceMemoryMB.find(im => im.isDefault)?.size;
28+
context.newFlexInstanceMemoryMB = Number.parseInt(context.newFlexSku?.instanceMemoryMB.find(im => im.isDefault)?.size ?? '2048');
2929
}
3030
}
3131

3232
private getPicks(flexSku: Sku): IAzureQuickPickItem<number>[] {
33-
const picks = flexSku.instanceMemoryMB.map(im => { return { label: im.size.toString(), data: im.size, description: im.isDefault ? 'Default' : undefined } });
33+
const picks = flexSku.instanceMemoryMB.map(im => { return { label: im.size.toString(), data: Number.parseInt(im.size), description: im.isDefault ? 'Default' : undefined } });
3434
return picks.sort((a, b) => Number(!!b.description) - Number(!!a.description));
3535
}
3636
}

src/commands/createFunctionApp/stacks/models/FlexSkuModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface Sku {
1616
}
1717

1818
interface InstanceMemoryMB {
19-
size: number;
19+
size: string;
2020
isDefault: boolean;
2121
}
2222

vscode.proposed.authLearnMore.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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/206587
9+
10+
export interface AuthenticationGetSessionPresentationOptions {
11+
/**
12+
* An optional Uri to open in the browser to learn more about this authentication request.
13+
*/
14+
learnMore?: Uri;
15+
}
16+
}
17+
18+
// this proposed api is only included because vscode.proposed.authenticationChallenges.d.ts depends on it
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
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/260156
9+
10+
/**********
11+
* "Extension asking for auth" API
12+
*******/
13+
14+
/**
15+
* Represents parameters for creating a session based on a WWW-Authenticate header value.
16+
* This is used when an API returns a 401 with a WWW-Authenticate header indicating
17+
* that additional authentication is required. The details of which will be passed down
18+
* to the authentication provider to create a session.
19+
*
20+
* @note The authorization provider must support handling challenges and specifically
21+
* the challenges in this WWW-Authenticate value.
22+
* @note For more information on WWW-Authenticate please see https://developer.mozilla.org/docs/Web/HTTP/Reference/Headers/WWW-Authenticate
23+
*/
24+
export interface AuthenticationWwwAuthenticateRequest {
25+
/**
26+
* The raw WWW-Authenticate header value that triggered this challenge.
27+
* This will be parsed by the authentication provider to extract the necessary
28+
* challenge information.
29+
*/
30+
readonly wwwAuthenticate: string;
31+
32+
/**
33+
* The fallback scopes to use if no scopes are found in the WWW-Authenticate header.
34+
*/
35+
readonly fallbackScopes?: readonly string[];
36+
37+
/**
38+
* @deprecated Use `fallbackScopes` instead.
39+
*/
40+
readonly scopes?: readonly string[];
41+
}
42+
43+
export namespace authentication {
44+
/**
45+
* Get an authentication session matching the desired scopes or satisfying the WWW-Authenticate request. Rejects if
46+
* a provider with providerId is not registered, or if the user does not consent to sharing authentication information
47+
* with the extension. If there are multiple sessions with the same scopes, the user will be shown a quickpick to
48+
* select which account they would like to use.
49+
*
50+
* Built-in auth providers include:
51+
* * 'github' - For GitHub.com
52+
* * 'microsoft' For both personal & organizational Microsoft accounts
53+
* * (less common) 'github-enterprise' - for alternative GitHub hostings, GHE.com, GitHub Enterprise Server
54+
* * (less common) 'microsoft-sovereign-cloud' - for alternative Microsoft clouds
55+
*
56+
* @param providerId The id of the provider to use
57+
* @param scopeListOrRequest A scope list of permissions requested or a WWW-Authenticate request. These are dependent on the authentication provider.
58+
* @param options The {@link AuthenticationGetSessionOptions} to use
59+
* @returns A thenable that resolves to an authentication session
60+
*/
61+
export function getSession(providerId: string, scopeListOrRequest: ReadonlyArray<string> | AuthenticationWwwAuthenticateRequest, options: AuthenticationGetSessionOptions & { /** */createIfNone: true | AuthenticationGetSessionPresentationOptions }): Thenable<AuthenticationSession>;
62+
63+
/**
64+
* Get an authentication session matching the desired scopes or request. Rejects if a provider with providerId is not
65+
* registered, or if the user does not consent to sharing authentication information with the extension. If there
66+
* are multiple sessions with the same scopes, the user will be shown a quickpick to select which account they would like to use.
67+
*
68+
* Built-in auth providers include:
69+
* * 'github' - For GitHub.com
70+
* * 'microsoft' For both personal & organizational Microsoft accounts
71+
* * (less common) 'github-enterprise' - for alternative GitHub hostings, GHE.com, GitHub Enterprise Server
72+
* * (less common) 'microsoft-sovereign-cloud' - for alternative Microsoft clouds
73+
*
74+
* @param providerId The id of the provider to use
75+
* @param scopeListOrRequest A scope list of permissions requested or a WWW-Authenticate request. These are dependent on the authentication provider.
76+
* @param options The {@link AuthenticationGetSessionOptions} to use
77+
* @returns A thenable that resolves to an authentication session
78+
*/
79+
export function getSession(providerId: string, scopeListOrRequest: ReadonlyArray<string> | AuthenticationWwwAuthenticateRequest, options: AuthenticationGetSessionOptions & { /** literal-type defines return type */forceNewSession: true | AuthenticationGetSessionPresentationOptions | AuthenticationForceNewSessionOptions }): Thenable<AuthenticationSession>;
80+
81+
/**
82+
* Get an authentication session matching the desired scopes or request. Rejects if a provider with providerId is not
83+
* registered, or if the user does not consent to sharing authentication information with the extension. If there
84+
* are multiple sessions with the same scopes, the user will be shown a quickpick to select which account they would like to use.
85+
*
86+
* Built-in auth providers include:
87+
* * 'github' - For GitHub.com
88+
* * 'microsoft' For both personal & organizational Microsoft accounts
89+
* * (less common) 'github-enterprise' - for alternative GitHub hostings, GHE.com, GitHub Enterprise Server
90+
* * (less common) 'microsoft-sovereign-cloud' - for alternative Microsoft clouds
91+
*
92+
* @param providerId The id of the provider to use
93+
* @param scopeListOrRequest A scope list of permissions requested or a WWW-Authenticate request. These are dependent on the authentication provider.
94+
* @param options The {@link AuthenticationGetSessionOptions} to use
95+
* @returns A thenable that resolves to an authentication session or undefined if a silent flow was used and no session was found
96+
*/
97+
export function getSession(providerId: string, scopeListOrRequest: ReadonlyArray<string> | AuthenticationWwwAuthenticateRequest, options?: AuthenticationGetSessionOptions): Thenable<AuthenticationSession | undefined>;
98+
}
99+
100+
101+
/**********
102+
* "Extension providing auth" API
103+
* NOTE: This doesn't need to be finalized with the above
104+
*******/
105+
106+
/**
107+
* Represents an authentication challenge from a WWW-Authenticate header.
108+
* This is used to handle cases where additional authentication steps are required,
109+
* such as when mandatory multi-factor authentication (MFA) is enforced.
110+
*
111+
* @note For more information on WWW-Authenticate please see https://developer.mozilla.org/docs/Web/HTTP/Reference/Headers/WWW-Authenticate
112+
*/
113+
export interface AuthenticationChallenge {
114+
/**
115+
* The authentication scheme (e.g., 'Bearer').
116+
*/
117+
readonly scheme: string;
118+
119+
/**
120+
* Parameters for the authentication challenge.
121+
* For Bearer challenges, this may include 'claims', 'scope', 'realm', etc.
122+
*/
123+
readonly params: Record<string, string>;
124+
}
125+
126+
/**
127+
* Represents constraints for authentication, including challenges and optional scopes.
128+
* This is used when creating or retrieving sessions that must satisfy specific authentication
129+
* requirements from WWW-Authenticate headers.
130+
*
131+
* @note For more information on WWW-Authenticate please see https://developer.mozilla.org/docs/Web/HTTP/Reference/Headers/WWW-Authenticate
132+
*/
133+
export interface AuthenticationConstraint {
134+
/**
135+
* Array of authentication challenges parsed from WWW-Authenticate headers.
136+
*/
137+
readonly challenges: readonly AuthenticationChallenge[];
138+
139+
/**
140+
* Optional scopes for the session. If not provided, the authentication provider
141+
* may extract scopes from the challenges or use default scopes.
142+
*/
143+
readonly fallbackScopes?: readonly string[];
144+
}
145+
146+
/**
147+
* An authentication provider that supports challenge-based authentication.
148+
* This extends the base AuthenticationProvider with methods to handle authentication
149+
* challenges from WWW-Authenticate headers.
150+
*
151+
* TODO: Enforce that both of these functions should be defined by creating a new AuthenticationProviderWithChallenges interface.
152+
* But this can be done later since this part doesn't need finalization.
153+
*/
154+
export interface AuthenticationProvider {
155+
/**
156+
* Get existing sessions that match the given authentication constraints.
157+
*
158+
* @param constraint The authentication constraint containing challenges and optional scopes
159+
* @param options Options for the session request
160+
* @returns A thenable that resolves to an array of existing authentication sessions
161+
*/
162+
getSessionsFromChallenges?(constraint: AuthenticationConstraint, options: AuthenticationProviderSessionOptions): Thenable<readonly AuthenticationSession[]>;
163+
164+
/**
165+
* Create a new session based on authentication constraints.
166+
* This is called when no existing session matches the constraint requirements.
167+
*
168+
* @param constraint The authentication constraint containing challenges and optional scopes
169+
* @param options Options for the session creation
170+
* @returns A thenable that resolves to a new authentication session
171+
*/
172+
createSessionFromChallenges?(constraint: AuthenticationConstraint, options: AuthenticationProviderSessionOptions): Thenable<AuthenticationSession>;
173+
}
174+
175+
export interface AuthenticationProviderOptions {
176+
supportsChallenges?: boolean;
177+
}
178+
}

0 commit comments

Comments
 (0)