Skip to content

Fixed README s typos and broken links #201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ IF SUFFICIENT INFORMATION IS NOT PROVIDED VIA THE FOLLOWING TEMPLATE THE ISSUE M

Please add an 'x' for the scenario(s) where you found an issue

1. [ ] Web app that signs in users
1. Web app that signs in users
1. [ ] with a work and school account in your organization: [1-WebApp-OIDC/1-1-MyOrg](../blob/master/1-WebApp-OIDC/1-1-MyOrg)
1. [ ] with any work and school account: [/1-WebApp-OIDC/1-2-AnyOrg](../blob/master/1-WebApp-OIDC/1-2-AnyOrg)
1. [ ] with any work or school account or Microsoft personal account: [1-WebApp-OIDC/1-3-AnyOrgOrPersonal](../blob/master/1-WebApp-OIDC/1-3-AnyOrgOrPersonal)
Expand All @@ -27,7 +27,7 @@ Please add an 'x' for the scenario(s) where you found an issue
1. [ ] With specific token caches: [2-WebApp-graph-user/2-2-TokenCache](../blob/master/2-WebApp-graph-user/2-2-TokenCache)
1. [ ] Calling Microsoft Graph in national clouds: [2-WebApp-graph-user/2-4-Sovereign-Call-MSGraph](../blob/master/2-WebApp-graph-user/2-4-Sovereign-Call-MSGraph)
1. [ ] Web app calling several APIs [3-WebApp-multi-APIs](../blob/master/3-WebApp-multi-APIs)
1. [ ] Web app calling your own Web API
1. [ ] Web app calling your own Web API [4-WebApp-your-API](../blob/master/4-WebApp-your-API)
1. Web app restricting users
1. [ ] by Roles: [5-WebApp-AuthZ/5-1-Roles](../blob/master/5-WebApp-AuthZ/5-1-Roles)
1. [ ] by Groups: [5-WebApp-AuthZ/5-2-Groups](../blob/master/5-WebApp-AuthZ/5-2-Groups)
Expand Down
6 changes: 3 additions & 3 deletions 1-WebApp-OIDC/1-2-AnyOrg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This sample shows how to build a .NET Core 2.2 MVC Web app that uses OpenID Conn
![Sign in with Azure AD](ReadmeFiles/sign-in.png)

> This is the second chapter of the first phase of this ASP.NET Core Web App tutorial. Once you understand how to sign-in users in an ASP.NET Core Web App with Open Id Connect, can learn how to enable your [Web App to call a Web API on behalf of the signed-in user](../../2-WebApp-graph-user) in a later chapter.
> You can also sign-in users in your own Azure Active Directory organizations, and even with Microsoft personal accounts or social identities. For more details the parent directory's [Readme.md](../Readme.md)
> You can also sign-in users in your own Azure Active Directory organizations, and even with Microsoft personal accounts or social identities. For more details the parent directory's [Readme.md](../README.md)

## How to run this sample

Expand All @@ -42,7 +42,7 @@ There is one project in this sample. To register it, you can:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
```

3. Run the script to create your Azure AD application and configure the code of the sample application accordinly
3. Run the script to create your Azure AD application and configure the code of the sample application accordingly

```PowerShell
.\AppCreationScripts\Configure.ps1
Expand All @@ -69,7 +69,7 @@ As a first step you'll need to:
1. When the **Register an application page** appears, enter your application's registration information:
- In the **Name** section, enter a meaningful application name that will be displayed to users of the app, for example `WebApp`.
- In the **Supported account types** section, select **Accounts in any organizational directory**.
> Note that there are more than one redirect URIs. You'll need to add them from the **Authentication** tab later after the app has been created succesfully.
> Note that there are more than one redirect URIs. You'll need to add them from the **Authentication** tab later after the app has been created successfully.
1. Select **Register** to create the application.
1. On the app **Overview** page, find the **Application (client) ID** value and record it for later. You'll need it to configure the Visual Studio configuration file for this project.
1. In the list of pages for the app, select **Authentication**..
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ param(
[string] $tenantId
)

if ((Get-Module -ListAvailable -Name "AzureAD") -eq $null) {
if ($null -eq (Get-Module -ListAvailable -Name "AzureAD")) {
Install-Module "AzureAD" -Scope CurrentUser
}
Import-Module AzureAD
$ErrorActionPreference = 'Stop'
$ErrorActionPreference = "Stop"

Function Cleanup
{
Expand Down Expand Up @@ -44,20 +44,27 @@ This function removes the Azure AD applications for the sample. These applicatio
$tenantId = $creds.Tenant.Id
}
$tenant = Get-AzureADTenantDetail
$tenantName = ($tenant.VerifiedDomains | Where { $_._Default -eq $True }).Name
$tenantName = ($tenant.VerifiedDomains | Where-Object { $_._Default -eq $True }).Name

# Removes the applications
Write-Host "Cleaning-up applications from tenant '$tenantName'"

Write-Host "Removing 'webApp' (WebApp-OpenIDConnect-DotNet-code-v2) if needed"
$app=Get-AzureADApplication -Filter "DisplayName eq 'WebApp-OpenIDConnect-DotNet-code-v2'"
Get-AzureADApplication -Filter "DisplayName eq 'WebApp-OpenIDConnect-DotNet-code-v2'" | ForEach-Object {Remove-AzureADApplication -ObjectId $_.ObjectId }
$apps = Get-AzureADApplication -Filter "DisplayName eq 'WebApp-OpenIDConnect-DotNet-code-v2'"
if ($apps)
{
Remove-AzureADApplication -ObjectId $apps.ObjectId
}

if ($app)
foreach ($app in $apps)
{
Remove-AzureADApplication -ObjectId $app.ObjectId
Write-Host "Removed."
Write-Host "Removed WebApp-OpenIDConnect-DotNet-code-v2.."
}

# also remove service principals of this app
Get-AzureADServicePrincipal -filter "DisplayName eq 'WebApp-OpenIDConnect-DotNet-code-v2'" | ForEach-Object {Remove-AzureADServicePrincipal -ObjectId $_.Id -Confirm:$false}

}

Cleanup -Credential $Credential -tenantId $TenantId
Cleanup -Credential $Credential -tenantId $TenantId
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Function AddResourcePermission($requiredAccess, `
}

#
# Exemple: GetRequiredPermissions "Microsoft Graph" "Graph.Read|User.Read"
# Example: GetRequiredPermissions "Microsoft Graph" "Graph.Read|User.Read"
# See also: http://stackoverflow.com/questions/42164581/how-to-configure-a-new-azure-ad-application-through-powershell
Function GetRequiredPermissions([string] $applicationDisplayName, [string] $requiredDelegatedPermissions, [string]$requiredApplicationPermissions, $servicePrincipal)
{
Expand Down Expand Up @@ -137,13 +137,16 @@ Function UpdateTextFile([string] $configFilePath, [System.Collections.HashTable]
Set-Content -Value "<html><body><table>" -Path createdApps.html
Add-Content -Value "<thead><tr><th>Application</th><th>AppId</th><th>Url in the Azure portal</th></tr></thead><tbody>" -Path createdApps.html

$ErrorActionPreference = "Stop"

Function ConfigureApplications
{
<#.Description
This function creates the Azure AD applications for the sample in the provided Azure AD tenant and updates the
configuration files in the client and service project of the visual studio solution (App.Config and Web.Config)
so that they are consistent with the Applications parameters
#>
$commonendpoint = "common"

# $tenantId is the Active Directory Tenant. This is a GUID which represents the "Directory ID" of the AzureAD tenant
# into which you want to create the apps. Look it up in the Azure portal in the "Properties" of the Azure AD.
Expand Down Expand Up @@ -174,7 +177,7 @@ Function ConfigureApplications
$tenant = Get-AzureADTenantDetail
$tenantName = ($tenant.VerifiedDomains | Where { $_._Default -eq $True }).Name

# Get the user running the script
# Get the user running the script to add the user as the app owner
$user = Get-AzureADUser -ObjectId $creds.Account.Id

# Create the webApp AAD application
Expand All @@ -184,6 +187,7 @@ Function ConfigureApplications
$fromDate = [DateTime]::Now;
$key = CreateAppKey -fromDate $fromDate -durationInYears 2 -pw $pw
$webAppAppKey = $pw
# create the application
$webAppAadApplication = New-AzureADApplication -DisplayName "WebApp-OpenIDConnect-DotNet-code-v2" `
-HomePage "https://localhost:44321/" `
-LogoutUrl "https://localhost:44321/signout-oidc" `
Expand All @@ -194,17 +198,19 @@ Function ConfigureApplications
-Oauth2AllowImplicitFlow $true `
-PublicClient $False

# create the service principal of the newly created application
$currentAppId = $webAppAadApplication.AppId
$webAppServicePrincipal = New-AzureADServicePrincipal -AppId $currentAppId -Tags {WindowsAzureActiveDirectoryIntegratedApp}

# add the user running the script as an app owner if needed
$owner = Get-AzureADApplicationOwner -ObjectId $webAppAadApplication.ObjectId
if ($owner -eq $null)
{
Add-AzureADApplicationOwner -ObjectId $webAppAadApplication.ObjectId -RefObjectId $user.ObjectId
Write-Host "'$($user.UserPrincipalName)' added as an application owner to app '$($webAppServicePrincipal.DisplayName)'"
Add-AzureADApplicationOwner -ObjectId $webAppAadApplication.ObjectId -RefObjectId $user.ObjectId
Write-Host "'$($user.UserPrincipalName)' added as an application owner to app '$($webAppServicePrincipal.DisplayName)'"
}


Write-Host "Done creating the webApp application (WebApp-OpenIDConnect-DotNet-code-v2)"

# URL of the AAD application in the Azure portal
Expand All @@ -230,14 +236,15 @@ Function ConfigureApplications
Write-Host "Updating the sample code ($configFile)"
$dictionary = @{ "ClientId" = $webAppAadApplication.AppId;"TenantId" = $tenantId;"Domain" = $tenantName;"ClientSecret" = $webAppAppKey };
UpdateTextFile -configFilePath $configFile -dictionary $dictionary

Add-Content -Value "</tbody></table></body></html>" -Path createdApps.html
}

# Pre-requisites
if ((Get-Module -ListAvailable -Name "AzureAD") -eq $null) {
Install-Module "AzureAD" -Scope CurrentUser
}
}

Import-Module AzureAD

# Run interactively (will ask you for the tenant ID)
Expand Down
36 changes: 23 additions & 13 deletions 2-WebApp-graph-user/2-1-Call-MSGraph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ endpoint: Microsoft identity platform

## Scenario

Starting from a .NET Core 2.2 MVC Web app that uses OpenID Connect to sign in users, this phase of the tutorial shows how to call Microsoft Graph /me endpoint on behalf of the signed-in user. It leverages the ASP.NET Core OpenID Connect middleware and Microsoft Authentication Library for .NET (MSAL.NET). Their complexities where encapsultated into the `Microsoft.Identity.Web` reusable library project part of this tutorial. Once again the notion of ASP.NET services injected by dependency injection is heavily used.
Starting from a .NET Core 2.2 MVC Web app that uses OpenID Connect to sign in users, this phase of the tutorial shows how to call Microsoft Graph /me endpoint on behalf of the signed-in user. It leverages the ASP.NET Core OpenID Connect middleware and Microsoft Authentication Library for .NET (MSAL.NET). Their complexities where encapsulated into the `Microsoft.Identity.Web` reusable library project part of this tutorial. Once again the notion of ASP.NET services injected by dependency injection is heavily used.

![Sign in with the Microsoft identity platform](ReadmeFiles/sign-in.png)

Expand All @@ -28,17 +28,22 @@ To run this sample:

### Step 1: Register the sample with your Azure AD tenant

You first need to [register](https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/tree/aspnetcore2-2#step-1-register-the-sample-with-your-azure-ad-tenant) your app as described in [the first tutorial](https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/tree/aspnetcore2-2)
You first need to [register](../../1-WebApp-OIDC/1-1-MyOrg#step-1-register-the-sample-with-your-azure-ad-tenant) your app as described in [the first tutorial](../../1-WebApp-OIDC/1-1-MyOrg)

Then follow the following extra set of steps:

1. From the **Certificates & secrets** page, for your app registration, in the **Client secrets** section, choose **New client secret**:

- Type a key description (of instance `app secret`),
- Select a key duration of either **In 1 year**, **In 2 years**, or **Never Expires**.
- When you press the **Add** button, the key value will be displayed, copy, and save the value in a safe location.
- You'll need this key later to configure the project in Visual Studio. This key value will not be displayed again, nor retrievable by any other means.
1. In the list of pages for the app, select **API permissions**, and notice that a delegated permission is set by default to Microsoft Graph for the scope **User.Read**
1. In the app's registration screen, click on the **Certificates & secrets** blade in the left to open the page where we can generate secrets and upload certificates.
1. In the **Client secrets** section, click on **New client secret**:
- Type a key description (for instance `app secret`),
- Select one of the available key durations (**In 1 year**, **In 2 years**, or **Never Expires**) as per your security concerns.
- The generated key value will be displayed when you click the **Add** button. Copy the generated value for use in the steps later.
- 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.
1. In the app's registration screen, click on the **API permissions** blade in the left to open the page where we add access to the Apis that your application needs.
- Click the **Add permissions** button and then,
- Ensure that the **Microsoft APIs** tab is selected.
- In the *Commonly used Microsoft APIs* section, click on **Microsoft Graph**
- In the **Delegated permissions** section, select the **User.Read** in the list. Use the search box if necessary.
- Click on the **Add permissions** button in the bottom.

### Step 2: Download/Clone/Go to the folder containing the sample code and build the application

Expand All @@ -56,11 +61,16 @@ Go to the `"2-WebApp-graph-user\2-1-Call-MSGraph"` folder
cd "2-WebApp-graph-user\2-1-Call-MSGraph"
```

In the appsettings.json file, replace, if you have not already:
#### Configure the webApp app (WebApp-OpenIDConnect-DotNet-code-v2) to use your app registration

Open the project in your IDE (like Visual Studio) to configure the code.
>In the steps below, "ClientID" is the same as "Application ID" or "AppId".

- the `ClientID` value with the *Application ID* from the application you registered in Application Registration portal,
- the `TenantId` by `common`, as here you chose to sign-in users with their work or school or personal account. In case you want to sign-in different audiences, refer back to the first phase of the tutorial
- and the `ClientSecret` by the client secret you generated in Step 1.
1. Open the `appsettings.json` file
1. Find the app key `ClientId` and replace the existing value with the application ID (clientId) of the `WebApp-OpenIDConnect-DotNet-code-v2` application copied from the Azure portal.
1. Find the app key `TenantId` and replace by `common`, as here you chose to sign-in users with their work or school or personal account. In case you want to sign-in different audiences, refer back to the first phase of the tutorial.
1. Find the app key `Domain` and replace the existing value with your Azure AD tenant name.
1. Find the app key `ClientSecret` and replace the existing value with the key you saved during the creation of the `WebApp-OpenIDConnect-DotNet-code-v2` app, in the Azure portal.

- In case you want to deploy your app in Sovereign or national clouds, ensure the `GraphApiUrl` option matches the one you want. By default this is Microsoft Graph in the Azure public cloud

Expand Down
4 changes: 2 additions & 2 deletions 3-WebApp-multi-APIs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ To run this sample:

> Pre-requisites:
>
> This is the third phase of the tutorial. It's recommended that you have gone through the previous phases of the tutorial, in particular how the [WebApp signs-in users with Microsoft Identity (OIDC) / with work and school or personal accounts](../../1-WebApp-OIDC/1-3-AnyOrgOrPersonal) and [Web app calls the Microsoft Graph API on behalf of a user signing-in](../../2-WebApp-graph-user/2-1-Call-MSGraph).
> This is the third phase of the tutorial. It's recommended that you have gone through the previous phases of the tutorial, in particular how the [WebApp signs-in users with Microsoft Identity (OIDC) / with work and school or personal accounts](../1-WebApp-OIDC/1-3-AnyOrgOrPersonal) and [Web app calls the Microsoft Graph API on behalf of a user signing-in](../2-WebApp-graph-user/2-1-Call-MSGraph).
>
> This chapter shows the incremental changes required to call two Microsoft APIs other than Microsoft Graph (Azure Resource Management and Azure Storage).

### Step 1: Register the sample with your Azure AD tenant

You first need to [register](../../1-3-AnyOrgOrPersonal/README.md#step-1-register-the-sample-with-your-azure-ad-tenant/README.md) your app as described in [the first phase of the tutorial](https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/tree/master/1-WebApp-OIDC)
You first need to [register](../1-WebApp-OIDC/1-3-AnyOrgOrPersonal/README.md#step-1-register-the-sample-with-your-azure-ad-tenant/README.md) your app as described in [the first phase of the tutorial](../1-WebApp-OIDC)

Then, the follow the following extra set of steps:

Expand Down