Skip to content

Commit f5161e3

Browse files
pamelafoxrayluo
andcommitted
Suggestions to deploy branch (#98)
* Pamelas suggestions * Update requirements.txt Co-authored-by: Ray Luo <[email protected]> * Update templates/login.html Co-authored-by: Ray Luo <[email protected]> * Ul changes, back button back * Update templates/login.html Co-authored-by: Ray Luo <[email protected]> --------- Co-authored-by: Ray Luo <[email protected]>
1 parent 984a301 commit f5161e3

File tree

10 files changed

+42
-27
lines changed

10 files changed

+42
-27
lines changed

.env.sample

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Note: If you are using Azure App Service, go to your app's Configuration,
22
# and then set the following values into your app's "Application settings".
33

4-
FLASK_DEBUG=True
4+
CLIENT_ID=<client id>
5+
CLIENT_SECRET=<client secret>
6+
57
# Expects a full tenant id such as "contoso.onmicrosoft.com", or its GUID
68
# Or leave it undefined if you are building a multi-tenant app
79
#TENANT_ID=<tenant id>
8-
CLIENT_ID=<client id>
9-
CLIENT_SECRET=<client secret>

.env.sample.b2c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# Note: If you are using Azure App Service, go to your app's Configuration,
22
# and then set the following values into your app's "Application settings".
3-
4-
FLASK_DEBUG=True
5-
# Expects the display name such as "contoso"
6-
TENANT_NAME=<tenant name>
73
CLIENT_ID=<client id>
84
CLIENT_SECRET=<client secret>
5+
# Expects the display name such as "contoso"
6+
TENANT_NAME=<tenant name>
97
SIGNUPSIGNIN_USER_FLOW=B2C_1_profile_editing
108
EDITPROFILE_USER_FLOW=B2C_1_reset_password
11-
RESETPASSWORD_USER_FLOW=B2C_1_signupsignin1
9+
RESETPASSWORD_USER_FLOW=B2C_1_signupsignin1

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,7 @@ Here we will describe how to deploy it to
3232
will be automatically created with the shape as `your_app_name\$your_app_name`.
3333
But your actual git username is only the `$your_app_name` part.
3434

35-
* Do not forget to setup
36-
[several environment variables](https://github.com/Azure-Samples/ms-identity-python-webapp/blob/master/.env.sample)
37-
needed by this sample.
38-
Otherwise your website will usually render a blank "Internal Error" page
39-
(Flask's debug mode output does not seem to be relayed by App Service).
35+
* [Configure your app's settings](https://learn.microsoft.com/en-us/azure/app-service/configure-common?tabs=portal#configure-app-settings) to define [these environment variables](https://github.com/Azure-Samples/ms-identity-python-webapp/blob/master/.env.sample).
4036

4137

4238
## Contributing

app.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,7 @@ def index():
5151
if not (app.config["CLIENT_ID"] and app.config["CLIENT_SECRET"]):
5252
# This check is not strictly necessary.
5353
# You can remove this check from your production code.
54-
return """Almost there. Did you forget to set up
55-
<a target=_blank
56-
href="https://github.com/Azure-Samples/ms-identity-python-webapp/blob/master/.env.sample">
57-
necessary environment variables</a> for your deployment?"""
54+
return render_template('config_error.html')
5855
if not auth.get_user():
5956
return redirect(url_for("login"))
6057
return render_template('index.html', user=auth.get_user(), version=identity.__version__)

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Flask>=2
1+
# Our how-to docs will use --debug parameter which is only available in Flask 2.2+
2+
Flask>=2.2
23
# If Flask-Session is not maintained in future, Flask-Session2 should work as well
34
Flask-Session>=0.3.2,<0.5
45
werkzeug>=2

templates/auth_error.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
65
{% if config.get("B2C_RESET_PASSWORD_AUTHORITY") and "AADB2C90118" in result.get("error_description") %} <!-- This will be reached when user forgot their password -->
76
<!-- See also https://docs.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-reference-policies#linking-user-flows -->
87
<meta http-equiv="refresh" content='0;{{config.get("B2C_RESET_PASSWORD_AUTHORITY")}}?client_id={{config.get("CLIENT_ID")}}'>
98
{% endif %}
9+
<title>Microsoft Identity Python Web App: Error</title>
1010
</head>
1111
<body>
1212
<h2>Login Failure</h2>
@@ -18,4 +18,3 @@ <h2>Login Failure</h2>
1818
<a href="{{ url_for('index') }}">Homepage</a>
1919
</body>
2020
</html>
21-

templates/config_error.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Microsoft Identity Python Web App: Error</title>
6+
</head>
7+
<body>
8+
<h2>Config Missing</h2>
9+
<p>
10+
Almost there. Did you forget to set up
11+
<a target=_blank
12+
href="https://learn.microsoft.com/azure/active-directory/develop/web-app-quickstart?pivots=devlang-python#step-5-configure-the-sample-app">
13+
necessary environment variables</a> for your deployment?
14+
</p>
15+
<hr>
16+
<a href="{{ url_for('index') }}">Homepage</a>
17+
</body>
18+
</html>

templates/display.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5+
<title>Microsoft Identity Python Web App: API</title>
56
</head>
67
<body>
78
<a href="javascript:window.history.go(-1)">Back</a> <!-- Displayed on top of a potentially large JSON response, so it will remain visible -->

templates/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5+
<title>Microsoft Identity Python Web App: Index</title>
56
</head>
67
<body>
78
<h1>Microsoft Identity Python Web App</h1>
89
<h2>Welcome {{ user.get("name") }}!</h2>
910

11+
<ul>
1012
{% if config.get("ENDPOINT") %}
1113
<li><a href='/call_downstream_api'>Call a downstream API</a></li>
1214
{% endif %}
@@ -16,6 +18,8 @@ <h2>Welcome {{ user.get("name") }}!</h2>
1618
{% endif %}
1719

1820
<li><a href="/logout">Logout</a></li>
21+
</ul>
22+
1923
<hr>
2024
<footer style="text-align: right">Powered by Identity Web {{ version }}</footer>
2125
</body>

templates/login.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,25 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5+
<title>Microsoft Identity Python Web App: Login</title>
56
</head>
67
<body>
78
<h1>Microsoft Identity Python Web App</h1>
89

910
{% if user_code %}
1011
<ol>
11-
<li>To sign in, type <b>{{ user_code }}</b> into
12-
<a href='{{ auth_uri }}' target=_blank>{{ auth_uri }}</a>
13-
to authenticate.
14-
</li>
15-
<li>And then <a href="{{ url_for('auth_response') }}">proceed</a>.</li>
12+
<li>To sign in, type <b>{{ user_code }}</b> into
13+
<a href='{{ auth_uri }}' target=_blank>{{ auth_uri }}</a>
14+
to authenticate.
15+
</li>
16+
<li>And then <a href="{{ url_for('auth_response') }}">proceed</a>.</li>
1617
</ol>
1718
{% else %}
18-
<li><a href='{{ auth_uri }}'>Sign In</a></li>
19+
<ul><li><a href='{{ auth_uri }}'>Sign In</a></li></ul>
1920
{% endif %}
2021

2122
{% if config.get("B2C_RESET_PASSWORD_AUTHORITY") %}
22-
<li><a href="{{config.get('B2C_RESET_PASSWORD_AUTHORITY')}}?client_id={{config.get('CLIENT_ID')}}">Reset Password</a></li>
23+
<a href="{{config.get('B2C_RESET_PASSWORD_AUTHORITY')}}?client_id={{config.get('CLIENT_ID')}}">Reset Password</a>
2324
{% endif %}
2425

2526
<hr>

0 commit comments

Comments
 (0)