Skip to content

Minor ReadMe updates and config files for Secret Manager #379

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 3 commits into from
Jul 14, 2020
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
7 changes: 7 additions & 0 deletions 1-WebApp-OIDC/1-1-MyOrg/Properties/serviceDependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
}
}
}
7 changes: 7 additions & 0 deletions 1-WebApp-OIDC/1-2-AnyOrg/Properties/serviceDependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
}
}
}
13 changes: 7 additions & 6 deletions 1-WebApp-OIDC/1-2-AnyOrg/README-1-1-to-1-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ In the `Startup.cs` file, in the `ConfigureServices` method, after `services.Add
{
...
// Sign-in users with the Microsoft identity platform
services.AddMicrosoftWebAppAuthentication(Configuration, options =>
{
Configuration.Bind("AzureAd", options);
// Restrict users to specific belonging to specific tenants
options.TokenValidationParameters.IssuerValidator = ValidateSpecificIssuers;
}, options => Configuration.Bind("AzureAd", options));
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftWebApp(options =>
{
Configuration.Bind("AzureAd", options);
// Restrict users to specific belonging to specific tenants
options.TokenValidationParameters.IssuerValidator = ValidateSpecificIssuers;
});
...
```

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
}
}
}
10 changes: 4 additions & 6 deletions 1-WebApp-OIDC/1-3-AnyOrgOrPersonal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,15 @@ In the **appsettings.json** file:
.AddAzureAD(options => Configuration.Bind("AzureAd", options));
```

by this line:
- by this line:

```CSharp

services.AddMicrosoftWebAppAuthentication(Configuration);

services.AddMicrosoftWebAppAuthentication(Configuration);
```

This enables your application to use the Microsoft identity platform endpoint. This endpoint is capable of signing-in users both with their Work and School and Microsoft Personal accounts.
This enables your application to use the Microsoft identity platform endpoint. This endpoint is capable of signing-in users both with their Work and School and Microsoft Personal accounts.

1. Change the `Properties\launchSettings.json` file to ensure that you start your web app from <https://localhost:44321> as registered. For this:
1. Change the `Properties\launchSettings.json` file to ensure that you start your web app from <https://localhost:44321> as registered. For this:
- update the `sslPort` of the `iisSettings` section to be `44321`
- in the `applicationUrl` property of use `https://localhost:44321`

Expand Down
7 changes: 7 additions & 0 deletions 1-WebApp-OIDC/1-5-B2C/Properties/serviceDependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
}
}
}
6 changes: 3 additions & 3 deletions 2-WebApp-graph-user/2-3-Multi-Tenant/README-National-Cloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ These steps are encapsulated in the [Microsoft.Identity.Web](..\..\Microsoft.Ide
In order to be able to sign-in users from multiple tenants, the [/common endpoint](https://docs.microsoft.com/azure/active-directory/develop/howto-convert-app-to-be-multi-tenant#update-your-code-to-send-requests-to-common) must be used. In the sample, this endpoint is used as a result of setting the value for `TenantId` as `organizations` on the `appsettings.json` file, and configuring the middleware to read the values from it.

```csharp
services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
.AddAzureAD(options => configuration.Bind(configSectionName, options));
services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
.AddMicrosoftWebApp(Configuration)
```

You can read about the various endpoints of the Microsoft Identity Platform [here](https://docs.microsoft.com/azure/active-directory/develop/active-directory-v2-protocols#endpoints).
Expand Down Expand Up @@ -282,7 +282,7 @@ options.TokenValidationParameters.IssuerValidator = AadIssuerValidator.GetIssuer
To extend this validation to only Azure AD tenants registered in the application database, the event handler `OnTokenValidated` was configured to grab the `tenantId` from the token claims and check if it has an entry on the database. If it doesn't, a custom exception `UnauthorizedTenantException` is thrown, canceling the authentication, and the user is redirected to the `UnauthorizedTenant` view. At this stage, the user is not authenticated in the application.

```csharp
services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>
services.Configure<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme, options =>
{
options.Events.OnTokenValidated = async context =>
{
Expand Down
7 changes: 7 additions & 0 deletions 3-WebApp-multi-APIs/Properties/serviceDependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
}
}
}
7 changes: 7 additions & 0 deletions 3-WebApp-multi-APIs/Properties/serviceDependencies.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
}
}
}
7 changes: 7 additions & 0 deletions 5-WebApp-AuthZ/5-1-Roles/Properties/serviceDependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
}
}
}
7 changes: 7 additions & 0 deletions 5-WebApp-AuthZ/5-2-Groups/Properties/serviceDependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
}
}
}
13 changes: 1 addition & 12 deletions 5-WebApp-AuthZ/5-2-Groups/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,13 @@ public void ConfigureServices(IServiceCollection services)
// Sign-in users with the Microsoft identity platform
services.AddMicrosoftWebAppAuthentication(Configuration)
.AddMicrosoftWebAppCallsWebApi(Configuration, new string[] { "User.Read", "Directory.Read.All" })

// If you want to use group ids/names in the Authorize attribute then uncomment the following lines:
//services.Configure<OpenIdConnectOptions>(options =>
// {
// // Uncomment the following lines code instruct the asp.net core middleware to use the data in the "groups" claim in the [Authorize] attribute and for User.IsInrole()
// // See https://docs.microsoft.com/en-us/aspnet/core/security/authorization/roles for more info.
// // Use the groups claim for populating roles
// options.TokenValidationParameters.RoleClaimType = "groups";
// })

.AddInMemoryTokenCaches();

services.AddMSGraphService(Configuration);

services.Configure<OpenIdConnectOptions>(OpenIdConnectDefaults.AuthenticationScheme, options => {
// Uncomment the following lines code instruct the asp.net core middleware to use the data in the "groups" claim in the [Authorize] attribute and for User.IsInrole()
// The following code instructs the ASP.NET Core middleware to use the data in the "groups" claim in the [Authorize] attribute and for User.IsInRole()
// See https://docs.microsoft.com/en-us/aspnet/core/security/authorization/roles for more info.
// Use the groups claim for populating roles
options.TokenValidationParameters.RoleClaimType = "groups";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that given there is a groups claims we'd better offer in Microsoft identity we method to verify that things are in groups, rather than doing a hack of mapping the claim so that it can be used in the Authorize attribute?
What do you think, @pmaytak ? @jennyf19 ? @kalyankrishna1 @TiagoBrenck @Shama-K ?

});

Expand Down