Skip to content

Commit 8feab47

Browse files
authored
[App Service] Easy Auth V2 Commands (Azure#3502)
* my changes batch 1 * upgrade mostly works now too * finished all the built in providers * oidc done * more work * secret prompts added * finish work * style fixes * more style fixes * pylint passed * address some of chris' comments * address PR comments, clean up * address some CI concerns * more fixes * linter should pass * fix codeowners * linter should pass * linter should pass * really hope this passes the ci * fix credscan * address Sisira's comments * fix static analysis * address Sisira's comments * try now * try now * try now * try now * revert * please * now
1 parent 3e161b6 commit 8feab47

18 files changed

+3339
-1
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,6 @@
200200

201201
/src/serial-console/ @adrianabedon
202202

203-
/src/dataprotection/ @sambitratha
203+
/src/dataprotection/ @sambitratha
204+
205+
/src/authV2/ @mkarmark

src/authV2/HISTORY.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.. :changelog:
2+
3+
Release History
4+
===============
5+
6+
0.1.0
7+
++++++
8+
* Initial release.

src/authV2/README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Microsoft Azure CLI 'authV2' Extension
2+
==========================================
3+
4+
This package is for the 'authV2' extension.
5+
i.e. 'az authV2'
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
from azure.cli.core import AzCommandsLoader
7+
8+
from azext_authV2._help import helps # pylint: disable=unused-import
9+
10+
11+
class Authv2CommandsLoader(AzCommandsLoader):
12+
13+
def __init__(self, cli_ctx=None):
14+
from azure.cli.core.commands import CliCommandType
15+
authV2_custom = CliCommandType(operations_tmpl='azext_authV2.custom#{}')
16+
super().__init__(cli_ctx=cli_ctx, custom_command_type=authV2_custom)
17+
18+
def load_command_table(self, args):
19+
from azext_authV2.commands import load_command_table
20+
load_command_table(self, args)
21+
return self.command_table
22+
23+
def load_arguments(self, command):
24+
from azext_authV2._params import load_arguments
25+
load_arguments(self, command)
26+
27+
28+
COMMAND_LOADER_CLS = Authv2CommandsLoader

src/authV2/azext_authV2/_help.py

Lines changed: 311 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,311 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# --------------------------------------------------------------------------------------------
6+
7+
from knack.help_files import helps # pylint: disable=unused-import
8+
9+
helps['webapp auth'] = """
10+
type: group
11+
short-summary: Manage webapp authentication and authorization in the v2 format.
12+
"""
13+
14+
helps['webapp auth show'] = """
15+
type: command
16+
short-summary: Show the authentication settings for the webapp in the v2 format.
17+
examples:
18+
- name: Show the authentication settings for the webapp. (autogenerated)
19+
text: az webapp auth show --name MyWebApp --resource-group MyResourceGroup
20+
crafted: true
21+
"""
22+
23+
helps['webapp auth update'] = """
24+
type: command
25+
short-summary: Update the authentication settings for the webapp in the v2 format.
26+
examples:
27+
- name: Update the client ID of the AAD provider already configured
28+
text: >
29+
az webapp auth update -g myResourceGroup --name MyWebApp --set identityProviders.azureActiveDirectory.registration.clientId=my-client-id
30+
- name: Pin the runtime version of the app to 1.4.7
31+
text: >
32+
az webapp auth update -g myResourceGroup --name MyWebApp --runtime-version 1.4.7
33+
- name: Configure the app with file based authentication by setting the config file path
34+
text: >
35+
az webapp auth update -g myResourceGroup --name MyWebApp --config-file-path D:\\home\\site\\wwwroot\\auth.json
36+
- name: Configure the app to allow unauthenticated requests to hit the app.
37+
text: >
38+
az webapp auth update -g myResourceGroup --name MyWebApp --unauthenticated-client-action AllowAnonymous
39+
- name: Configure the app to redirect unauthenticated requests to the Facebook provider
40+
text: >
41+
az webapp auth update -g myResourceGroup --name MyWebApp --redirect-provider Facebook
42+
- name: Configure the app to listen to the forward headers X-FORWARDED-HOST and X-FORWARDED-PROTO
43+
text: >
44+
az webapp auth update -g myResourceGroup --name MyWebApp --proxy-convention Standard
45+
"""
46+
47+
helps['webapp auth set'] = """
48+
type: command
49+
short-summary: Sets the authentication settings for the webapp in the v2 format, overwriting any existing settings.
50+
examples:
51+
- name: Set the json saved in file auth.json as the auth settings for the web app, overwriting any existing settings.
52+
text: >
53+
az webapp auth set -g myResourceGroup --name MyWebApp --body @auth.json
54+
"""
55+
56+
helps['webapp auth config-version'] = """
57+
type: group
58+
short-summary: Manage the state of the configuration version for the authentication settings for the webapp. Configuration version v1 refers to the /authSettings endpoints whereas v2 refers to the /authSettingsV2 endpoints.
59+
"""
60+
61+
helps['webapp auth config-version show'] = """
62+
type: command
63+
short-summary: Show the configuration version of the authentication settings for the webapp. Configuration version v1 refers to the /authSettings endpoints whereas v2 refers to the /authSettingsV2 endpoints.
64+
examples:
65+
- name: Show the configuration version of the authentication settings for the webapp (autogenerated)
66+
text: >
67+
az webapp auth config-version show --name MyWebApp --resource-group MyResourceGroup
68+
"""
69+
70+
helps['webapp auth config-version revert'] = """
71+
type: command
72+
short-summary: Reverts the configuration version of the authentication settings for the webapp from v2 to v1 (classic).
73+
examples:
74+
- name: Revert the configuration version of the authentication settings for the webapp from v2 to v1 (classic) (autogenerated)
75+
text: >
76+
az webapp auth config-version revert --name MyWebApp --resource-group MyResourceGroup
77+
"""
78+
79+
helps['webapp auth config-version upgrade'] = """
80+
type: command
81+
short-summary: Upgrades the configuration version of the authentication settings for the webapp from v1 (classic) to v2.
82+
examples:
83+
- name: Upgrades the configuration version of the authentication settings for the webapp from v1 (classic) to v2 (autogenerated)
84+
text: >
85+
az webapp auth config-version upgrade --name MyWebApp --resource-group MyResourceGroup
86+
"""
87+
88+
helps['webapp auth-classic'] = """
89+
type: group
90+
short-summary: Manage webapp authentication and authorization in the classic format.
91+
"""
92+
93+
helps['webapp auth-classic show'] = """
94+
type: command
95+
short-summary: Show the authentication settings for the webapp in the classic format.
96+
examples:
97+
- name: Show the authentication settings for the webapp. (autogenerated)
98+
text: az webapp auth-classic show --name MyWebApp --resource-group MyResourceGroup
99+
crafted: true
100+
"""
101+
102+
helps['webapp auth-classic update'] = """
103+
type: command
104+
short-summary: Update the authentication settings for the webapp in the classic format.
105+
examples:
106+
- name: Enable Azure Active Directory by enabling authentication and setting Azure Active Directory-associated parameters. Default provider is set to AAD. Must have created a AAD service principal beforehand.
107+
text: >
108+
az webapp auth-classic update -g myResourceGroup --name MyWebApp --enabled true \\
109+
--action LoginWithAzureActiveDirectory \\
110+
--aad-allowed-token-audiences https://webapp_name.azurewebsites.net/.auth/login/aad/callback \\
111+
--aad-client-id my-client-id --aad-client-secret very_secret_password \\
112+
--aad-token-issuer-url https://sts.windows.net/54826b22-38d6-4fb2-bad9-b7983a3e9c5a/
113+
- name: Enable Facebook authentication by setting FB-associated parameters and turning on public-profile and email scopes; allow anonymous users
114+
text: >
115+
az webapp auth-classic update -g myResourceGroup --name MyWebApp --action AllowAnonymous \\
116+
--facebook-app-id my_fb_id --facebook-app-secret my_fb_secret \\
117+
--facebook-oauth-scopes public_profile email
118+
"""
119+
120+
helps['webapp auth apple'] = """
121+
type: group
122+
short-summary: Manage webapp authentication and authorization of the Apple identity provider.
123+
"""
124+
125+
helps['webapp auth apple show'] = """
126+
type: command
127+
short-summary: Show the authentication settings for the Apple identity provider.
128+
examples:
129+
- name: Show the authentication settings for the Apple identity provider. (autogenerated)
130+
text: az webapp auth apple show --name MyWebApp --resource-group MyResourceGroup
131+
crafted: true
132+
"""
133+
134+
helps['webapp auth apple update'] = """
135+
type: command
136+
short-summary: Update the client id and client secret for the Apple identity provider.
137+
examples:
138+
- name: Update the client id and client secret for the Apple identity provider.
139+
text: >
140+
az webapp auth apple update -g myResourceGroup --name MyWebApp \\
141+
--client-id my-client-id --client-secret very_secret_password
142+
"""
143+
144+
helps['webapp auth facebook'] = """
145+
type: group
146+
short-summary: Manage webapp authentication and authorization of the Facebook identity provider.
147+
"""
148+
149+
helps['webapp auth facebook show'] = """
150+
type: command
151+
short-summary: Show the authentication settings for the Facebook identity provider.
152+
examples:
153+
- name: Show the authentication settings for the Facebook identity provider. (autogenerated)
154+
text: az webapp auth facebook show --name MyWebApp --resource-group MyResourceGroup
155+
crafted: true
156+
"""
157+
158+
helps['webapp auth facebook update'] = """
159+
type: command
160+
short-summary: Update the app id and app secret for the Facebook identity provider.
161+
examples:
162+
- name: Update the app id and app secret for the Facebook identity provider.
163+
text: >
164+
az webapp auth facebook update -g myResourceGroup --name MyWebApp \\
165+
--app-id my-client-id --app-secret very_secret_password
166+
"""
167+
168+
helps['webapp auth github'] = """
169+
type: group
170+
short-summary: Manage webapp authentication and authorization of the GitHub identity provider.
171+
"""
172+
173+
helps['webapp auth github show'] = """
174+
type: command
175+
short-summary: Show the authentication settings for the GitHub identity provider.
176+
examples:
177+
- name: Show the authentication settings for the GitHub identity provider. (autogenerated)
178+
text: az webapp auth github show --name MyWebApp --resource-group MyResourceGroup
179+
crafted: true
180+
"""
181+
182+
helps['webapp auth github update'] = """
183+
type: command
184+
short-summary: Update the client id and client secret for the GitHub identity provider.
185+
examples:
186+
- name: Update the client id and client secret for the GitHub identity provider.
187+
text: >
188+
az webapp auth github update -g myResourceGroup --name MyWebApp \\
189+
--client-id my-client-id --client-secret very_secret_password
190+
"""
191+
192+
helps['webapp auth google'] = """
193+
type: group
194+
short-summary: Manage webapp authentication and authorization of the Google identity provider.
195+
"""
196+
197+
helps['webapp auth google show'] = """
198+
type: command
199+
short-summary: Show the authentication settings for the Google identity provider.
200+
examples:
201+
- name: Show the authentication settings for the Google identity provider. (autogenerated)
202+
text: az webapp auth google show --name MyWebApp --resource-group MyResourceGroup
203+
crafted: true
204+
"""
205+
206+
helps['webapp auth google update'] = """
207+
type: command
208+
short-summary: Update the client id and client secret for the Google identity provider.
209+
examples:
210+
- name: Update the client id and client secret for the Google identity provider.
211+
text: >
212+
az webapp auth google update -g myResourceGroup --name MyWebApp \\
213+
--client-id my-client-id --client-secret very_secret_password
214+
"""
215+
216+
helps['webapp auth microsoft'] = """
217+
type: group
218+
short-summary: Manage webapp authentication and authorization of the Microsoft identity provider.
219+
"""
220+
221+
helps['webapp auth microsoft show'] = """
222+
type: command
223+
short-summary: Show the authentication settings for the Azure Active Directory identity provider.
224+
examples:
225+
- name: Show the authentication settings for the Azure Active Directory identity provider. (autogenerated)
226+
text: az webapp auth microsoft show --name MyWebApp --resource-group MyResourceGroup
227+
crafted: true
228+
"""
229+
230+
helps['webapp auth microsoft update'] = """
231+
type: command
232+
short-summary: Update the client id and client secret for the Azure Active Directory identity provider.
233+
examples:
234+
- name: Update the open id issuer, client id and client secret for the Azure Active Directory identity provider.
235+
text: >
236+
az webapp auth microsoft update -g myResourceGroup --name MyWebApp \\
237+
--client-id my-client-id --client-secret very_secret_password \\
238+
--issuer https://sts.windows.net/54826b22-38d6-4fb2-bad9-b7983a3e9c5a/
239+
"""
240+
241+
helps['webapp auth openid-connect'] = """
242+
type: group
243+
short-summary: Manage webapp authentication and authorization of the custom OpenID Connect identity providers.
244+
"""
245+
246+
helps['webapp auth openid-connect show'] = """
247+
type: command
248+
short-summary: Show the authentication settings for the custom OpenID Connect identity provider.
249+
examples:
250+
- name: Show the authentication settings for the custom OpenID Connect identity provider. (autogenerated)
251+
text: az webapp auth openid-connect show --name MyWebApp --resource-group MyResourceGroup \\
252+
--provider-name myOpenIdConnectProvider
253+
crafted: true
254+
"""
255+
256+
helps['webapp auth openid-connect add'] = """
257+
type: command
258+
short-summary: Configure a new custom OpenID Connect identity provider.
259+
examples:
260+
- name: Configure a new custom OpenID Connect identity provider.
261+
text: >
262+
az webapp auth openid-connect add -g myResourceGroup --name MyWebApp \\
263+
--provider-name myOpenIdConnectProvider --client-id my-client-id \\
264+
--client-secret-setting-name MY_SECRET_APP_SETTING \\
265+
--openid-configuration https://myopenidprovider.net/.well-known/openid-configuration
266+
"""
267+
268+
helps['webapp auth openid-connect update'] = """
269+
type: command
270+
short-summary: Update the client id and client secret setting name for an existing custom OpenID Connect identity provider.
271+
examples:
272+
- name: Update the client id and client secret setting name for an existing custom OpenID Connect identity provider.
273+
text: >
274+
az webapp auth openid-connect update -g myResourceGroup --name MyWebApp \\
275+
--provider-name myOpenIdConnectProvider --client-id my-client-id \\
276+
--client-secret-setting-name MY_SECRET_APP_SETTING
277+
"""
278+
279+
helps['webapp auth openid-connect remove'] = """
280+
type: command
281+
short-summary: Removes an existing custom OpenID Connect identity provider.
282+
examples:
283+
- name: Removes an existing custom OpenID Connect identity provider.
284+
text: >
285+
az webapp auth openid-connect remove --name MyWebApp --resource-group MyResourceGroup \\
286+
--provider-name myOpenIdConnectProvider
287+
"""
288+
289+
helps['webapp auth twitter'] = """
290+
type: group
291+
short-summary: Manage webapp authentication and authorization of the Twitter identity provider.
292+
"""
293+
294+
helps['webapp auth twitter show'] = """
295+
type: command
296+
short-summary: Show the authentication settings for the Twitter identity provider.
297+
examples:
298+
- name: Show the authentication settings for the Twitter identity provider. (autogenerated)
299+
text: az webapp auth twitter show --name MyWebApp --resource-group MyResourceGroup
300+
crafted: true
301+
"""
302+
303+
helps['webapp auth twitter update'] = """
304+
type: command
305+
short-summary: Update the consumer key and consumer secret for the Twitter identity provider.
306+
examples:
307+
- name: Update the consumer key and consumer secret for the Twitter identity provider.
308+
text: >
309+
az webapp auth twitter update -g myResourceGroup --name MyWebApp \\
310+
--consumer-key my-client-id --consumer-secret very_secret_password
311+
"""

0 commit comments

Comments
 (0)