You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-resource-server/README.md
+39-64Lines changed: 39 additions & 64 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,26 +3,22 @@
3
3
## Key concepts
4
4
This sample illustrates how to protect a Java web API by restricting access to its resources to authorized accounts only.
5
5
6
-
1. The bearer token is obtained from the request header.
7
-
2.`JwtDecoder` is used to parse the token into `Jwt`.
8
-
3. Claims, headers etc in `Jwt` will be extracted, they will be wrapped in `AzureOAuth2AuthenticatedPrincipal` object.
9
-
4.`AzureOAuth2AuthenticatedPrincipal` will eventually be set into SecurityContext.
6
+
1. Obtain the access token from the HTTP request header.
7
+
2. Use `JwtDecoder` to parse the access token into `Jwt`.
8
+
3. Verify `aud`, `iss`, `nbf`, `exp` claims in access token.
9
+
4. Extract information from JWT in `AADOAuth2AuthenticatedPrincipal` object after a successful verification.
10
+
5. Save the `AADOAuth2AuthenticatedPrincipal` into SecurityContext.
10
11
12
+
### Protocol diagram
13
+

11
14
12
15
## Getting started
13
-
14
16
### Environment checklist
15
17
We need to ensure that this [environment checklist][ready-to-run-checklist] is completed before the run.
16
18
17
-
To run this sample, you'll need:
18
-
- An Azure Active Directory (Azure AD) tenant. For more information on how to get an Azure AD tenant, see [How to get an Azure AD tenant][How to get an Azure AD tenant]
19
-
- You register your web APP in App registrations in the Azure portal.
20
-
- A Web APP runtime that requires access to a Web API.
In this section, you register your web API in App registrations in the Azure portal.
43
-
44
-
### Choose your Azure AD tenant
45
-
46
-
To register your apps manually, choose the Azure Active Directory (Azure AD) tenant where you want to create your apps.
47
-
48
-
1. Sign in to the [Azure portal](https://portal.azure.com/) with either a work or school account or a personal Microsoft account.
49
-
2. If your account is present in more than one Azure AD tenant, select your profile at the upper right, and then select **Switch directory**.
50
-
3. Change your portal session to the Azure AD tenant you want to use.
51
-
52
-
### Register the web API
53
-
54
-
1. Go to the Microsoft identity platform for developers App registrations portal.
37
+
### Configure Web API
38
+
1. In this section, you register your web API in App registrations in the Azure portal.
39
+
2. Search for and select your tenant in **Azure Active Directory**.
40
+
3. Under **Manage** In the same tenant, select **App registrations** -> **New registration**.
41
+
4. The registered application name is filled into `webapi`, select **Accounts in this organizational directory only**, click the **register** button.
42
+
5. Under **webapi** application, select **Certificates & secrets** -> **new client secret**, expires select **Never**, click the **add** button, remember to save the secrets here and use them later.
43
+
6. Under **webapi** application, select **Expose an API** -> **Add a scope**, Use the default Application ID URI, click **Save and continue** button.
44
+
7. After step five, the page will refresh again. Then set the **Scope name** to `File.Read`.
45
+
8. Finally, the api exposed in `webapi`.
55
46
56
-
2. Select New registration.
57
-

58
-
59
-
3. When the Register an application page opens, enter your application's registration information:
60
-

61
-
62
-
4. In the **Expose an API** section, select **Add a scope**, accept the proposed Application ID URI `(api://{clientId})` (back up the Application ID URI here, which will be used in the properties file) by selecting **Save and Continue**.
If you still don't understand, you can look at this [register app or web api][Register app or web API] and another [expose scoped permission to web api][Expose scoped permission to web API]. I believe it will also help you.
47
+
See [Expose scoped permission to web api] for more information about web api.
0 commit comments