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: README.md
+34-35
Original file line number
Diff line number
Diff line change
@@ -70,44 +70,44 @@ As a first step you'll need to:
70
70
1. Sign in to the [Azure portal](https://portal.azure.com) using either a work or school account or a personal Microsoft account.
71
71
1. If your account is present in more than one Azure AD tenant, select your profile at the top right corner in the menu on top of the page, and then **switch directory**.
72
72
Change your portal session to the desired Azure AD tenant.
73
-
1. In the portal menu click on **All services** and choose **Azure Active Directory**.
73
+
1. In the portal menu, click on **All services** and choose **Azure Active Directory**.
74
74
75
75
> In the next steps, you might need the tenant name (or directory name) or the tenant ID (or directory ID). These are presented in the **Properties** of the Azure Active Directory window respectively as *Name* and *Directory ID*
76
76
77
-
#### Register the Web Api app (java-webapi)
77
+
#### Register the Web Api app (Java-webapi)
78
78
79
79
1. Navigate to the Microsoft identity platform for developers [App registrations](https://go.microsoft.com/fwlink/?linkid=2083908) page.
80
-
1. Click **New registration** on top.
80
+
1. Click **New registration**.
81
81
1. In the **Register an application page** that appears, enter your application's registration information:
82
-
- In the **Name** section, enter a meaningful application name that will be displayed to users of the app, for example `java-webapi`.
82
+
- In the **Name** section, enter a meaningful application name that will be displayed to users of the app, for example `Java-webapi`.
83
83
- Change **Supported account types** to **Accounts in any organizational directory and personal Microsoft accounts (e.g. Skype, Xbox, Outlook.com)**.
84
-
1. Click on the **Register** button in bottom to create the application.
85
-
1. In the app's registration screen, find the **Application (client) ID** and **Directory (tenant) ID** value and record it for use later. You'll need it to configure the configuration file(s) later in your code.
86
-
1. Click the **Save** button on top to save the changes.
87
-
1. In the app's registration screen, click on the **Certificates & secrets** blade to open the page where we can generate secrets and upload certificates.
84
+
1. Click on the **Register** button to create the application.
85
+
1. In the app's registration **Overview** page, find the **Application (client) ID** and **Directory (tenant) ID** value and record it for use later. You'll need it to configure the configuration file(s) later in your code.
86
+
1. Click the **Save** button to save the changes.
87
+
1. In the Application menu blade, click on the **Certificates & secrets** to open the page where we can generate secrets and upload certificates.
88
88
1. In the **Client secrets** section, click on **New client secret**:
89
89
- Type a key description (for instance `app secret`),
90
90
- Select one of the available key durations (**In 1 year**, **In 2 years**, or **Never Expires**) as per your security concerns.
91
91
- The generated key value will be displayed when you click the **Add** button. Copy the generated value for use in the steps later.
92
92
- You'll need this key later in your code's configuration files. This key value will not be displayed again, and is not retrievable by any other means, so make sure to note it from the Azure portal before navigating to any other screen or blade.
93
-
1. In the app's registration screen, click on the **API permissions** blade to open the page where we add access to the Apis that your application needs.
93
+
1. In the Application menu blade, click on the **API permissions** to open the page where we add access to the Apis that your application needs.
94
94
- Click the **Add a permission** button and then,
95
95
- Ensure that the **Microsoft APIs** tab is selected.
96
96
- In the *Commonly used Microsoft APIs* section, click on **Microsoft Graph**
97
97
- In the **Delegated permissions** section, select the **User.Read** in the list. Use the search box if necessary.
98
98
- Click on the **Add permissions** button in the bottom.
99
-
1. In the app's registration screen, click on the **Expose an API** blade to open the page where declare the parameters to expose this app as an Api for which client applications can obtain [access tokens](https://docs.microsoft.com/azure/active-directory/develop/access-tokens) for.
99
+
1. In the Application menu blade, click on the **Expose an API** to open the page where declare the parameters to expose this app as an Api for which client applications can obtain [access tokens](https://docs.microsoft.com/azure/active-directory/develop/access-tokens) for.
100
100
The first thing that we need to do is to declare the unique [resource](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow) URI that the clients will be using to obtain access tokens for this Api. To declare an resource URI, follow the following steps:
101
-
- Click `Set` next to the **Application ID URI** to generate a URI thats unique for this app.
101
+
- Click `Set` next to the **Application ID URI** to generate a URI that is unique for this app.
102
102
- For this sample, accept the proposed Application ID URI (api://{clientId}) by selecting **Save**.
103
103
1. All Apis have to publish a minimum of one [scope](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-authorization-code) for the client's to obtain an access token successfully. To publish a scope, follow the following steps:
104
104
- Select **Add a scope** button open the **Add a scope** screen and Enter the values as indicated below:
105
105
- For **Scope name**, use `access_as_user`.
106
106
- Select **Admins and users** options for **Who can consent?**
107
-
- For **Admin consent display name** type `Access java-webapi`
108
-
- For **Admin consent description** type `Allows the app to access java-webapi as the signed-in user.`
109
-
- For **User consent display name** type `Access java-webapi`
110
-
- For **User consent description** type `Allow the application to access java-webapi on your behalf.`
107
+
- For **Admin consent display name** type `Access Java-webapi`
108
+
- For **Admin consent description** type `Allows the app to access Java-webapi as the signed-in user.`
109
+
- For **User consent display name** type `Access Java-webapi`
110
+
- For **User consent description** type `Allow the application to access Java-webapi on your behalf.`
111
111
- Keep **State** as **Enabled**
112
112
- Click on the **Add scope** button on the bottom to save this scope.
113
113
@@ -119,33 +119,32 @@ Open `application.properties` in the src/main/resources folder. Fill in with you
119
119
-*Enter_the_Application_Id_here* with the **Application (client) ID**.
120
120
-*Enter_the_Client_Secret_Here* with the **key value** noted earlier.
121
121
122
-
#### Register the client web app (java_webapp)
122
+
#### Register the client web app (Java_webapp)
123
123
124
124
1. Navigate to the Microsoft identity platform for developers [App registrations](https://go.microsoft.com/fwlink/?linkid=2083908) page.
125
-
1. Click **New registration** on top.
125
+
1. Click **New registration**.
126
126
1. In the **Register an application page** that appears, enter your application's registration information:
127
127
- In the **Name** section, enter a meaningful application name that will be displayed to users of the app, for example `java_webapp`.
128
128
- Change **Supported account types** to **Accounts in any organizational directory and personal Microsoft accounts (e.g. Skype, Xbox, Outlook.com)**.
129
129
> Note that there are more than one redirect URIs used in this sample. You'll need to add them from the **Authentication** tab later after the app has been created successfully.
130
-
1. Click on the **Register** button in bottom to create the application.
131
-
1. In the app's registration screen, find the **Application (client) ID** value and record it for later. You'll need it to configure the configuration file(s) later in your code.
132
-
1. In the app's registration screen, click on the **Authentication** blade.
130
+
1. Click on the **Register** button to create the application.
131
+
1. In the app's registration **Overview** page, find the **Application (client) ID** value and record it for later. You'll need it to configure the configuration file(s) later in your code.
132
+
1. In the Application menu blade, click on the **Authentication**.
133
133
- In the Redirect URIs section, select **Web** in the drop down and enter the following redirect URIs.
134
134
-`http://localhost:8080/msal4jsample/secure/aad`
135
135
-`http://localhost:8080/msal4jsample/graph/me`
136
-
- In the **Advanced settings** section, set **Logout URL** to `https://localhost:8080/msal4jsample/sign-out`.
137
136
138
-
1. Click the **Save** button on top to save the changes.
139
-
1. In the app's registration screen, click on the **Certificates & secrets** blade to open the page where we can generate secrets and upload certificates.
137
+
1. Click the **Save** button to save the changes.
138
+
1. In the Application menu blade, click on the **Certificates & secrets** to open the page where we can generate secrets and upload certificates.
140
139
1. In the **Client secrets** section, click on **New client secret**:
141
140
- Type a key description (for instance `app secret`),
142
141
- Select one of the available key durations (**In 1 year**, **In 2 years**, or **Never Expires**) as per your security concerns.
143
142
- The generated key value will be displayed when you click the **Add** button. Copy the generated value for use in the steps later.
144
143
- You'll need this key later in your code's configuration files. This key value will not be displayed again, and is not retrievable by any other means, so make sure to note it from the Azure portal before navigating to any other screen or blade.
145
-
1. In the app's registration screen, click on the **API permissions** blade to open the page where we add access to the Apis that your application needs.
144
+
1. In the Application menu blade, click on the **API permissions** to open the page where we add access to the Apis that your application needs.
146
145
- Click the **Add a permission** button and then,
147
146
- Ensure that the **My APIs** tab is selected.
148
-
- In the list of APIs, select the API `java-webapi`.
147
+
- In the list of APIs, select the API `Java-webapi`.
149
148
- In the **Delegated permissions** section, select the **access_as_user** in the list. Use the search box if necessary.
150
149
- Click on the **Add permissions** button in the bottom.
151
150
@@ -157,18 +156,18 @@ Open `application.properties` in the src/main/resources folder. Fill in with you
157
156
- Replace *Enter_the_Client_Secret_Here* with the **key value** noted earlier.
158
157
- Replace *OboApi* with the API exposed in the `Web Api app`**(api://{clientId})**.
159
158
160
-
#### Configure known client applications for service (java-webapi)
159
+
#### Configure known client applications for service (Java-webapi)
161
160
162
-
For a middle tier web API (`java-webapi`) to be able to call a downstream web API, the middle tier app needs to be granted the required permissions as well.
161
+
For a middle tier web API (`Java-webapi`) to be able to call a downstream web API, the middle tier app needs to be granted the required permissions as well.
163
162
However, since the middle tier cannot interact with the signed-in user, it needs to be explicitly bound to the client app in its Azure AD registration.
164
163
This binding merges the permissions required by both the client and the middle tier WebApi and and presents it to the end user in a single consent dialog. The user than then consent to this combined set of permissions.
165
164
166
-
To achieve this, you need to add the "Client ID" of the client app, in the manifest of the web API in the `knownClientApplications` property. Here's how:
165
+
To achieve this, you need to add the "Client ID" of the client app, in the manifest of the web API in the **knownClientApplications** property. Here's how:
167
166
168
-
In the [Azure portal](https://portal.azure.com), navigate to your `java-webapi` app registration:
167
+
In the [Azure portal](https://portal.azure.com), navigate to your `Java-webapi` app registration:
169
168
170
169
- In the Application menu blade, select **Manifest**.
171
-
- Find the attribute **knownClientApplications** and add your client application's(`java-webapp`) **Application (client) Id** as its element.
170
+
- Find the attribute **knownClientApplications** and add your client application's(`Java-webapp`) **Application (client) Id** as its element.
172
171
- Click **Save**.
173
172
174
173
### Step 4: Run the applications
@@ -241,7 +240,7 @@ If you would like to deploy the sample to Tomcat, you will need to make a couple
241
240
-This will generate a `msal-web-sample-0.1.0.war` file in your /targets directory.
242
241
-Renamethis file to `ROOT.war`
243
242
-Deploythis war file using Tomcat or any other J2EE container solution.
244
-
-To deploy on Tomcat container, copy the .war file to the webapps folder under your Tomcat installation and then start the Tomcat server.
243
+
-To deploy on Tomcat container, copy the .war file to the webapp's folder under your Tomcat installation and then start the Tomcat server.
245
244
- Repeat these steps for the `msal-obo-sample` also.
246
245
247
246
This WAR will automatically be hosted at `http:<yourserverhost>:<yourserverport>/`
@@ -273,7 +272,7 @@ There are many key points in this sample to make the On-Behalf-Of-(OBO) flow wor
273
272
274
273
A code snippet showing how to obtain auth result by silent flow.
@@ -307,7 +306,7 @@ There are many key points in this sample to make the On-Behalf-Of-(OBO) flow wor
307
306
308
307
Contains the api(graphMeApi) to trigger the obo flow. The graphMeApi method gets the obo access token using **MsalAuthHelper**.The `callMicrosoftGraphEndPoint` method calls the Microsoft graph API using obo token.
@@ -325,7 +324,7 @@ There are many key points in this sample to make the On-Behalf-Of-(OBO) flow wor
325
324
326
325
TokenValidation of the caller happens in this class, where the access token presented by the client app is validated and another access token is obtained using the on-behalf-of flow
0 commit comments