-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
1,867 additions
and
1,867 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 23 additions & 23 deletions
46
...is/BlazorAzureADWithApis/Client/App.razor → ...MicrosoftEntraIDWithApis/Client/App.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
<CascadingAuthenticationState> | ||
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true"> | ||
<Found Context="routeData"> | ||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"> | ||
<NotAuthorized> | ||
@if (!context.User.Identity.IsAuthenticated) | ||
{ | ||
<RedirectToLogin /> | ||
} | ||
else | ||
{ | ||
<p>You are not authorized to access this resource.</p> | ||
} | ||
</NotAuthorized> | ||
</AuthorizeRouteView> | ||
</Found> | ||
<NotFound> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p>Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> | ||
</CascadingAuthenticationState> | ||
<CascadingAuthenticationState> | ||
<Router AppAssembly="@typeof(Program).Assembly" PreferExactMatches="@true"> | ||
<Found Context="routeData"> | ||
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"> | ||
<NotAuthorized> | ||
@if (!context.User.Identity.IsAuthenticated) | ||
{ | ||
<RedirectToLogin /> | ||
} | ||
else | ||
{ | ||
<p>You are not authorized to access this resource.</p> | ||
} | ||
</NotAuthorized> | ||
</AuthorizeRouteView> | ||
</Found> | ||
<NotFound> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p>Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> | ||
</CascadingAuthenticationState> |
52 changes: 26 additions & 26 deletions
52
...lient/BlazorAzureADWithApis.Client.csproj → ...zorMicrosoftEntraIDWithApis.Client.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" /> | ||
<PackageReference Include="Microsoft.Authentication.WebAssembly.Msal" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" /> | ||
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Shared\BlazorAzureADWithApis.Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" /> | ||
<PackageReference Include="Microsoft.Authentication.WebAssembly.Msal" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" /> | ||
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Shared\BlazorMicrosoftEntraIDWithApis.Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" /> | ||
</ItemGroup> | ||
|
||
</Project> |
14 changes: 7 additions & 7 deletions
14
...ithApis/Client/Pages/Authentication.razor → ...ithApis/Client/Pages/Authentication.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
@page "/authentication/{action}" | ||
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication | ||
<RemoteAuthenticatorView Action="@Action" /> | ||
|
||
@code{ | ||
[Parameter] public string Action { get; set; } | ||
} | ||
@page "/authentication/{action}" | ||
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication | ||
<RemoteAuthenticatorView Action="@Action" /> | ||
|
||
@code{ | ||
[Parameter] public string Action { get; set; } | ||
} |
94 changes: 47 additions & 47 deletions
94
.../Client/Pages/DelegatedUserApiCalls.razor → .../Client/Pages/DelegatedUserApiCalls.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
@page "/delegateduserapicall" | ||
@using Microsoft.AspNetCore.Authorization | ||
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication | ||
@attribute [Authorize] | ||
@inject HttpClient Http | ||
|
||
<h1>Data from Delegated User API</h1> | ||
|
||
@if (apiData == null) | ||
{ | ||
<p><em>Loading...</em></p> | ||
} | ||
else | ||
{ | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Data</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var data in apiData) | ||
{ | ||
<tr> | ||
<td>@data</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
} | ||
|
||
@code { | ||
private string[]? apiData; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
try | ||
{ | ||
apiData = await Http.GetFromJsonAsync<string[]>("DelegatedUserApiCalls"); | ||
} | ||
catch (AccessTokenNotAvailableException exception) | ||
{ | ||
exception.Redirect(); | ||
} | ||
} | ||
|
||
} | ||
@page "/delegateduserapicall" | ||
@using Microsoft.AspNetCore.Authorization | ||
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication | ||
@attribute [Authorize] | ||
@inject HttpClient Http | ||
|
||
<h1>Data from Delegated User API</h1> | ||
|
||
@if (apiData == null) | ||
{ | ||
<p><em>Loading...</em></p> | ||
} | ||
else | ||
{ | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Data</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var data in apiData) | ||
{ | ||
<tr> | ||
<td>@data</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
} | ||
|
||
@code { | ||
private string[]? apiData; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
try | ||
{ | ||
apiData = await Http.GetFromJsonAsync<string[]>("DelegatedUserApiCalls"); | ||
} | ||
catch (AccessTokenNotAvailableException exception) | ||
{ | ||
exception.Redirect(); | ||
} | ||
} | ||
|
||
} |
94 changes: 47 additions & 47 deletions
94
...reADWithApis/Client/Pages/DirectApi.razor → ...raIDWithApis/Client/Pages/DirectApi.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
@page "/directapi" | ||
@using Microsoft.AspNetCore.Authorization | ||
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication | ||
@attribute [Authorize] | ||
@inject HttpClient Http | ||
|
||
<h1>Data from Direct API</h1> | ||
|
||
@if (apiData == null) | ||
{ | ||
<p><em>Loading...</em></p> | ||
} | ||
else | ||
{ | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Data</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var data in apiData) | ||
{ | ||
<tr> | ||
<td>@data</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
} | ||
|
||
@code { | ||
private string[]? apiData; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
try | ||
{ | ||
apiData = await Http.GetFromJsonAsync<string[]>("DirectApi"); | ||
} | ||
catch (AccessTokenNotAvailableException exception) | ||
{ | ||
exception.Redirect(); | ||
} | ||
} | ||
|
||
} | ||
@page "/directapi" | ||
@using Microsoft.AspNetCore.Authorization | ||
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication | ||
@attribute [Authorize] | ||
@inject HttpClient Http | ||
|
||
<h1>Data from Direct API</h1> | ||
|
||
@if (apiData == null) | ||
{ | ||
<p><em>Loading...</em></p> | ||
} | ||
else | ||
{ | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Data</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var data in apiData) | ||
{ | ||
<tr> | ||
<td>@data</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
} | ||
|
||
@code { | ||
private string[]? apiData; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
try | ||
{ | ||
apiData = await Http.GetFromJsonAsync<string[]>("DirectApi"); | ||
} | ||
catch (AccessTokenNotAvailableException exception) | ||
{ | ||
exception.Redirect(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.