Skip to content

Commit 9a277ed

Browse files
committed
Adopt identity 0.7 and change logout link
1 parent c002ebc commit 9a277ed

File tree

6 files changed

+48
-53
lines changed

6 files changed

+48
-53
lines changed

.env.sample

Lines changed: 0 additions & 31 deletions
This file was deleted.

README.md

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,10 @@ Write your app like this once, and the same implementation will support 4x2=8 sc
1515

1616
### Prerequisites
1717

18-
1. Register your web application in the Microsoft Entra admin center,
19-
by following step 1, 2 and 3 of this
20-
[Quickstart: Add sign-in with Microsoft to a Python web app](https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-web-app-python-sign-in?tabs=windows)
21-
(Note: There will be articles on how to register your app with External ID, etc..)
2218
1. Have [Python](https://python.org) 3.8+ installed
2319
1. Clone from
2420
[its repo](https://github.com/Azure-Samples/ms-identity-python-webapp-django)
2521
or download its zip package, and then start using it or build on top of it.
26-
(Alternatively, you can follow our [tutorial](#tutorial) to learn
27-
how to build this from scratch, or how to add auth to your existing project.)
2822
1. `cd project_name`
2923
1. Run `pip install -r requirements.txt` to install dependencies
3024
1. Run `python manage.py migrate` to initialize your Django project
@@ -42,6 +36,33 @@ Write your app like this once, and the same implementation will support 4x2=8 sc
4236
<th>Microsoft Entra External ID with Custom Domain</th>
4337
<th>Azure AD B2C</th>
4438
</tr>
39+
40+
<tr>
41+
<th>App Registration</th>
42+
<td><!-- See https://github.com/github/cmark-gfm/issues/12 -->
43+
44+
Following only the step 1, 2 and 3 of this
45+
[Quickstart: Add sign-in with Microsoft to a Python web app](https://learn.microsoft.com/entra/identity-platform/quickstart-web-app-python-sign-in?tabs=windows)
46+
47+
</td>
48+
<td>
49+
50+
Follow only the page 1 of this [Tutorial: Prepare your customer tenant ...](https://learn.microsoft.com/entra/external-id/customers/tutorial-web-app-python-flask-prepare-tenant)
51+
52+
</td>
53+
<td>
54+
55+
Coming soon.
56+
57+
</td>
58+
<td>
59+
60+
Following only the step 1 and 2 (including 2.1 and 2.2) of this
61+
[Configure authentication in a sample Python web app by using Azure AD B2C](https://learn.microsoft.com/azure/active-directory-b2c/configure-authentication-sample-python-web-app?tabs=linux)
62+
63+
</td>
64+
</tr>
65+
4566
<tr>
4667
<th rowspan=2>Configuration</th>
4768
<td><!-- See https://github.com/github/cmark-gfm/issues/12 -->
@@ -58,7 +79,7 @@ as `.env` and then modify `.env` with your app's settings.
5879
</td>
5980
<td>
6081

61-
Copy this [CIAM Custom Domain template](.env.sample.ciam-custom-domain)
82+
Copy this [External ID with Custom Domain template](.env.sample.external-id-custom-domain)
6283
as `.env` and then modify `.env` with your app's settings.
6384

6485
</td>
@@ -108,21 +129,26 @@ Now restart this sample and try its "Call API" experience.
108129

109130
</td>
110131
</tr>
111-
</table>
112132

113-
### Deployment
133+
<tr>
134+
<th>
135+
136+
Deploy to
137+
[Azure App Service](https://azure.microsoft.com/en-us/products/app-service)
114138

115-
Once you finish testing this web app locally, you can deploy it to your production.
116-
You may choose any web app hosting services you want.
117-
Here we will describe how to deploy it to
118-
[Azure App Service](https://azure.microsoft.com/en-us/products/app-service).
139+
</th>
140+
<td colspan=4>
119141

120142
* Follow the ["Quickstart: Deploy a Python (Django or Flask) web app to Azure App Service"](https://learn.microsoft.com/en-us/azure/app-service/quickstart-python),
121143
but replace its sample app (which does not do user sign-in) with this web app.
122-
123144
* [Configure your app's settings](https://learn.microsoft.com/en-us/azure/app-service/configure-common?tabs=portal#configure-app-settings)
124-
to define
125-
[these environment variables](https://github.com/Azure-Samples/ms-identity-python-webapp-django/blob/main/.env.sample).
145+
to define environment variables mentioned in the **Configuration** row of this table.
146+
147+
</td>
148+
</tr>
149+
150+
</table>
151+
126152

127153
## How to build this sample (or a new web project) from scratch
128154

mysite/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
import requests
77

88

9-
__version__ = "0.4.0"
9+
__version__ = "0.5.0"
1010

1111

1212
@settings.AUTH.login_required
1313
def index(request, *, context):
1414
return render(request, 'index.html', dict(
1515
user=context['user'],
16-
version=__version__,
1716
edit_profile_url=settings.AUTH.get_edit_profile_url(),
1817
api_endpoint=os.getenv("ENDPOINT"),
18+
title=f"Microsoft Entra ID Django Web App Sample v{__version__}",
1919
))
2020

2121
@settings.AUTH.login_required(scopes=os.getenv("SCOPE", "").split())

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
# See https://docs.djangoproject.com/en/5.0/faq/install/#what-python-version-can-i-use-with-django
33
django>=3.2,<6
44

5-
identity>=0.6,<0.7
5+
identity>=0.7,<0.8
66
python-dotenv<0.22
77
requests>=2,<3

templates/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>Microsoft Entra ID Django Web App Sample: Index</title>
5+
<title>{{ title }}</title>
66
</head>
77
<body>
8-
<h1>Microsoft Entra ID Django Web App Sample {{version}}</h1>
8+
<h1>{{ title }}</h1>
99
<h2>Welcome {{ user.name }}!</h2>
1010

1111
<!-- There is much hussle to get the local static image to show up on App Service.
@@ -23,7 +23,7 @@ <h2>Welcome {{ user.name }}!</h2>
2323
<li><a href='{{ edit_profile_url }}'>Edit Profile</a></li>
2424
{% endif %}
2525

26-
<li><a href="{% url 'identity.django.logout' %}">Logout</a></li>
26+
<li><a href="{% url 'identity.logout' %}">Logout</a></li>
2727
</ul>
2828
</body>
2929
</html>

0 commit comments

Comments
 (0)