Skip to content

Commit 7d4c2e7

Browse files
Servicing release for dotnet-aspnet-codegenerator and dotnet-msidentity (#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]>
1 parent b71737e commit 7d4c2e7

17 files changed

Lines changed: 164 additions & 141 deletions

File tree

eng/Versions.MSIdentity.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<UsingToolNetFrameworkReferenceAssemblies>true</UsingToolNetFrameworkReferenceAssemblies>
77
</PropertyGroup>
88
<PropertyGroup>
9-
<VersionPrefix>1.0.1</VersionPrefix>
9+
<VersionPrefix>1.0.2</VersionPrefix>
1010
<PreReleaseVersionLabel>rtm</PreReleaseVersionLabel>
1111
<IsServicingBuild Condition="'$(PreReleaseVersionLabel)' == 'servicing'">true</IsServicingBuild>
1212
<!--

eng/Versions.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<!-- Ref packages -->
1414
</PropertyGroup>
1515
<PropertyGroup>
16-
<VersionPrefix>6.0.1</VersionPrefix>
16+
<VersionPrefix>6.0.2</VersionPrefix>
1717
<PreReleaseVersionLabel>rtm</PreReleaseVersionLabel>
1818
<IsServicingBuild Condition="'$(PreReleaseVersionLabel)' == 'servicing'">true</IsServicingBuild>
1919
<!--
@@ -114,7 +114,7 @@
114114
<XunitRunnerVisualStudioPackageVersion>2.4.2-pre.9</XunitRunnerVisualStudioPackageVersion>
115115
</PropertyGroup>
116116
<PropertyGroup>
117-
<SystemCollectionsImmutableVersion>7.0.0-preview.1.22076.8</SystemCollectionsImmutableVersion>
117+
<SystemCollectionsImmutableVersion>6.0.0</SystemCollectionsImmutableVersion>
118118
<SystemNetHttpVersion>4.3.4</SystemNetHttpVersion>
119119
<SystemPrivateUriVersion>4.3.2</SystemPrivateUriVersion>
120120
</PropertyGroup>

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"tools": {
3-
"dotnet": "6.0.200"
3+
"dotnet": "6.0.101"
44
},
55
"msbuild-sdks": {
66
"Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.21552.1"
77
},
88
"sdk": {
9-
"version": "6.0.200",
9+
"version": "6.0.101",
1010
"allowPrerelease": true
1111
}
1212
}

scripts/install-aspnet-codegenerator.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set VERSION=6.0.1
1+
set VERSION=6.0.2
22
set DEFAULT_NUPKG_PATH=%userprofile%\.nuget\packages
33
set SRC_DIR=%cd%
44
set NUPKG=artifacts/packages/Debug/Shipping/
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@page "/callwebapi"
2+
3+
@using Microsoft.Identity.Web
4+
5+
@inject IDownstreamWebApi downstreamAPI
6+
@inject MicrosoftIdentityConsentAndConditionalAccessHandler ConsentHandler
7+
8+
<h1>Call an API</h1>
9+
10+
<p>This component demonstrates fetching data from a Web API.</p>
11+
12+
@if (apiResult == null)
13+
{
14+
<p><em>Loading...</em></p>
15+
}
16+
else
17+
{
18+
<h2>API Result</h2>
19+
@apiResult
20+
}
21+
22+
@code {
23+
private HttpResponseMessage response;
24+
private string apiResult;
25+
26+
protected override async Task OnInitializedAsync()
27+
{
28+
try
29+
{
30+
response = await downstreamAPI.CallWebApiForUserAsync(
31+
"DownstreamApi",
32+
options => options.RelativePath = "");
33+
34+
if (response.StatusCode == System.Net.HttpStatusCode.OK)
35+
{
36+
apiResult = await response.Content.ReadAsStringAsync();
37+
}
38+
else
39+
{
40+
apiResult = "Failed to call the web API";
41+
}
42+
}
43+
catch (Exception ex)
44+
{
45+
ConsentHandler.HandleException(ex);
46+
}
47+
}
48+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<AuthorizeView>
2+
<Authorized>
3+
Hello, @context.User.Identity?.Name!
4+
<a href="MicrosoftIdentity/Account/SignOut">Log out</a>
5+
</Authorized>
6+
<NotAuthorized>
7+
<a href="MicrosoftIdentity/Account/SignIn">Log in</a>
8+
</NotAuthorized>
9+
</AuthorizeView>

src/MSIdentityScaffolding/Microsoft.DotNet.MSIdentity/CodeReaderWriter/CodeFiles/Blazor/Server/ShowProfile.razor

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,60 +24,21 @@ else
2424
<td>Name</td>
2525
<td>@user.DisplayName</td>
2626
</tr>
27-
<tr>
28-
<td>Photo</td>
29-
<td>
30-
@{
31-
if (photo != null)
32-
{
33-
<img style="margin: 5px 0; width: 150px" src="data:image/jpeg;base64, @photo" />
34-
}
35-
else
36-
{
37-
<h3>NO PHOTO</h3>
38-
<p>Check user profile in Azure Active Directory to add a photo.</p>
39-
}
40-
}
41-
</td>
42-
</tr>
4327
</table>
4428
}
4529

4630
@code {
47-
User user;
48-
string photo;
31+
User? user;
4932

5033
protected override async Task OnInitializedAsync()
5134
{
5235
try
5336
{
5437
user = await GraphServiceClient.Me.Request().GetAsync();
55-
photo = await GetPhoto();
5638
}
5739
catch (Exception ex)
5840
{
5941
ConsentHandler.HandleException(ex);
6042
}
6143
}
62-
63-
protected async Task<string> GetPhoto()
64-
{
65-
string photo;
66-
67-
try
68-
{
69-
using (var photoStream = await GraphServiceClient.Me.Photo.Content.Request().GetAsync())
70-
{
71-
byte[] photoByte = ((System.IO.MemoryStream)photoStream).ToArray();
72-
photo = Convert.ToBase64String(photoByte);
73-
this.StateHasChanged();
74-
}
75-
76-
}
77-
catch (Exception)
78-
{
79-
photo = null;
80-
}
81-
return photo;
82-
}
8344
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@page "/authentication/{action}"
2+
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
3+
<RemoteAuthenticatorView Action="@Action" />
4+
5+
@code{
6+
[Parameter] public string? Action { get; set; }
7+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@using Microsoft.AspNetCore.Components.Authorization
2+
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
3+
4+
@inject NavigationManager Navigation
5+
@inject SignOutSessionStateManager SignOutManager
6+
7+
<AuthorizeView>
8+
<Authorized>
9+
Hello, @context.User.Identity?.Name!
10+
<button class="nav-link btn btn-link" @onclick="BeginLogout">Log out</button>
11+
</Authorized>
12+
<NotAuthorized>
13+
<a href="authentication/login">Log in</a>
14+
</NotAuthorized>
15+
</AuthorizeView>
16+
17+
@code{
18+
private async Task BeginLogout(MouseEventArgs args)
19+
{
20+
await SignOutManager.SetSignOutState();
21+
Navigation.NavigateTo("authentication/logout");
22+
}
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@inject NavigationManager Navigation
2+
3+
@code {
4+
protected override void OnInitialized()
5+
{
6+
Navigation.NavigateTo($"authentication/login?returnUrl={Uri.EscapeDataString(Navigation.Uri)}");
7+
}
8+
}

0 commit comments

Comments
 (0)