Skip to content

Commit

Permalink
Servicing release for dotnet-aspnet-codegenerator and dotnet-msidenti…
Browse files Browse the repository at this point in the history
…ty (#1816)

* Code updates for blazor server Downstream API option (#1767)

* Add blazor server, and some code refactors

* updating System package versions due to security vulnerabilities (#1781)

* updating System package versions due to security vulnerabilities

* revert package version for test.

* potential fix?

* fixed all compliance issues.

* clean up

* Refactor ProjectModifier and remove calls to Directory.EnumerateFiles (#1782)

* Removing EnumerateDirectories, other refactors

* Create and Update Blazor Wasm App Registrations (#1793)

* scripts and gitignore

* Update redirect uris

* create and update Blazor Wasm apps

* Process callback paths for remote URIs

* Add comments and refactor for better readability

* String updates

* Fix updating bug, update strings

* Blazor Server: Code updates for Microsoft Graph and Downstream API options (#1798)

Adding code updates for blazor server non-auth templates

* Blazor Wasm: Code Updates and AppSettings updates (#1805)

* Blazor Wasm: Code Updates and AppSettings updates

* App Settings and Code Modification updates

* App Settings and Code Modification updates

* App Settings and Code Modification updates

* App Settings and Code Modification updates

* Update AzureAdProperties logic
Address PR comments
Refactor tests

* Update version to 1.0.2, add reference to Nuget package

* Refactor projectDescriptionReader logic

* Downstream API fixes

* Add AppSettings modification to CodeUpdate option

* not throwing exception on invalid bootstrap versions. (#1814)

* not throwing exception on invalid bootstrap .

* minor fix

* bump up dotnet-aspnet-codegenerator version.

Co-authored-by: zahalzel <[email protected]>
  • Loading branch information
deepchoudhery and zahalzel authored Feb 4, 2022
1 parent 75892f6 commit 1abb136
Show file tree
Hide file tree
Showing 51 changed files with 1,777 additions and 912 deletions.
6 changes: 5 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

<PropertyGroup Label="Package and Assembly Metadata">
<Product>Microsoft ASP.NET Core</Product>
</PropertyGroup>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.Private.Uri" Version="$(SystemPrivateUriVersion)" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion eng/Versions.MSIdentity.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UsingToolNetFrameworkReferenceAssemblies>true</UsingToolNetFrameworkReferenceAssemblies>
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>1.0.1</VersionPrefix>
<VersionPrefix>1.0.2</VersionPrefix>
<PreReleaseVersionLabel>rtm</PreReleaseVersionLabel>
<IsServicingBuild Condition="'$(PreReleaseVersionLabel)' == 'servicing'">true</IsServicingBuild>
<!--
Expand Down
4 changes: 3 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<!-- Ref packages -->
</PropertyGroup>
<PropertyGroup>
<VersionPrefix>6.0.1</VersionPrefix>
<VersionPrefix>6.0.2</VersionPrefix>
<PreReleaseVersionLabel>rtm</PreReleaseVersionLabel>
<IsServicingBuild Condition="'$(PreReleaseVersionLabel)' == 'servicing'">true</IsServicingBuild>
<!--
Expand Down Expand Up @@ -115,6 +115,8 @@
</PropertyGroup>
<PropertyGroup>
<SystemCollectionsImmutableVersion>6.0.0</SystemCollectionsImmutableVersion>
<SystemNetHttpVersion>4.3.4</SystemNetHttpVersion>
<SystemPrivateUriVersion>4.3.2</SystemPrivateUriVersion>
</PropertyGroup>
<!-- Package versions for MSIdentity projects-->
<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"tools": {
"dotnet": "6.0.100-rc.1.21430.12"
"dotnet": "6.0.101"
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.21552.1"
},
"sdk": {
"version": "6.0.100-rc.1.21430.12",
"version": "6.0.101",
"allowPrerelease": true
}
}
2 changes: 1 addition & 1 deletion scripts/install-aspnet-codegenerator.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set VERSION=6.0.1
set VERSION=6.0.2
set DEFAULT_NUPKG_PATH=%userprofile%\.nuget\packages
set SRC_DIR=%cd%
set NUPKG=artifacts/packages/Debug/Shipping/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public string? Domain1
/// <summary>
/// The project is a blazor web assembly.
/// </summary>
public bool? IsBlazorWasm { get; set; }
public bool IsBlazorWasm { get; set; }

/// <summary>
/// The app calls Microsoft Graph.
Expand Down Expand Up @@ -155,7 +155,7 @@ public string? Domain1
public List<string> PasswordCredentials { get; } = new List<string>();

/// <summary>
/// Identitier URIs for web APIs.
/// Identifier URIs for web APIs.
/// </summary>
public string? AppIdUri { set; get; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.DotNet.MSIdentity.AuthenticationParameters
{
public class AzureAdProperties
public class PropertyNames
{
public string? Domain { get; set; }
public string? TenantId { get; set; }
public string? ClientId { get; set; }
public string? ClientSecret { get; set; }
public string? CallbackPath { get; set; }
public string? Instance { get; set; }
public const string Domain = nameof(Domain);
public const string TenantId = nameof(TenantId);
public const string ClientId = nameof(ClientId);
public const string ClientSecret = nameof(ClientSecret);
public const string ClientCertificates = nameof(ClientCertificates);
public const string CallbackPath = nameof(CallbackPath);
public const string Instance = nameof(Instance);

public const string Authority = nameof(Authority);
public const string ValidateAuthority = nameof(ValidateAuthority);

public const string BaseUrl = nameof(BaseUrl);
public const string Scopes = nameof(Scopes);
}

//getting default properties from https://github.com/dotnet/aspnetcore/blob/6bc4b79f4ee7af00edcbb435e5ee4c1de349a110/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/appsettings.json
public static class AzureAdDefaultProperties
// getting default properties from
// https://github.com/dotnet/aspnetcore/blob/6bc4b79f4ee7af00edcbb435e5ee4c1de349a110/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/appsettings.json
public static class DefaultProperties
{
public const string Domain = "qualified.domain.name";
public const string TenantId = "22222222-2222-2222-2222-222222222222";
public const string ClientId = "11111111-1111-1111-11111111111111111";
public const string Instance = "https://login.microsoftonline.com/";
public const string CallbackPath = "/signin-oidc";
public const string ClientSecret = "Client secret from app-registration. Check user secrets/azure portal.";

public const string Authority = "https://login.microsoftonline.com/22222222-2222-2222-2222-222222222222";
public const string ValidateAuthority = "true";

public const string MicrosoftGraphBaseUrl = "https://graph.microsoft.com/v1.0";
public const string MicrosoftGraphScopes = "user.read";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
@page "/callwebapi"

@using Microsoft.Identity.Web

@inject IDownstreamWebApi downstreamAPI
@inject MicrosoftIdentityConsentAndConditionalAccessHandler ConsentHandler

<h1>Call an API</h1>

<p>This component demonstrates fetching data from a Web API.</p>

@if (apiResult == null)
{
<p><em>Loading...</em></p>
}
else
{
<h2>API Result</h2>
@apiResult
}

@code {
private HttpResponseMessage response;
private string apiResult;

protected override async Task OnInitializedAsync()
{
try
{
response = await downstreamAPI.CallWebApiForUserAsync(
"DownstreamApi",
options => options.RelativePath = "");

if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
apiResult = await response.Content.ReadAsStringAsync();
}
else
{
apiResult = "Failed to call the web API";
}
}
catch (Exception ex)
{
ConsentHandler.HandleException(ex);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<AuthorizeView>
<Authorized>
Hello, @context.User.Identity?.Name!
<a href="MicrosoftIdentity/Account/SignOut">Log out</a>
</Authorized>
<NotAuthorized>
<a href="MicrosoftIdentity/Account/SignIn">Log in</a>
</NotAuthorized>
</AuthorizeView>
Original file line number Diff line number Diff line change
Expand Up @@ -24,60 +24,21 @@ else
<td>Name</td>
<td>@user.DisplayName</td>
</tr>
<tr>
<td>Photo</td>
<td>
@{
if (photo != null)
{
<img style="margin: 5px 0; width: 150px" src="data:image/jpeg;base64, @photo" />
}
else
{
<h3>NO PHOTO</h3>
<p>Check user profile in Azure Active Directory to add a photo.</p>
}
}
</td>
</tr>
</table>
}

@code {
User user;
string photo;
User? user;

protected override async Task OnInitializedAsync()
{
try
{
user = await GraphServiceClient.Me.Request().GetAsync();
photo = await GetPhoto();
}
catch (Exception ex)
{
ConsentHandler.HandleException(ex);
}
}

protected async Task<string> GetPhoto()
{
string photo;

try
{
using (var photoStream = await GraphServiceClient.Me.Photo.Content.Request().GetAsync())
{
byte[] photoByte = ((System.IO.MemoryStream)photoStream).ToArray();
photo = Convert.ToBase64String(photoByte);
this.StateHasChanged();
}

}
catch (Exception)
{
photo = null;
}
return photo;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
<RemoteAuthenticatorView Action="@Action" />

@code{
[Parameter] public string? Action { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication

@inject NavigationManager Navigation
@inject SignOutSessionStateManager SignOutManager

<AuthorizeView>
<Authorized>
Hello, @context.User.Identity?.Name!
<button class="nav-link btn btn-link" @onclick="BeginLogout">Log out</button>
</Authorized>
<NotAuthorized>
<a href="authentication/login">Log in</a>
</NotAuthorized>
</AuthorizeView>

@code{
private async Task BeginLogout(MouseEventArgs args)
{
await SignOutManager.SetSignOutState();
Navigation.NavigateTo("authentication/logout");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@inject NavigationManager Navigation

@code {
protected override void OnInitialized()
{
Navigation.NavigateTo($"authentication/login?returnUrl={Uri.EscapeDataString(Navigation.Uri)}");
}
}
Loading

0 comments on commit 1abb136

Please sign in to comment.