-
Notifications
You must be signed in to change notification settings - Fork 0
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
6 changed files
with
45 additions
and
27 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
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
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
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,9 +1,40 @@ | ||
@page "/" | ||
@page "/" | ||
|
||
@using Microsoft.AspNetCore.Components.Authorization | ||
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication | ||
@using System.Security.Claims | ||
|
||
@inject AuthenticationStateProvider AuthenticationStateProvider | ||
|
||
<PageTitle>Index</PageTitle> | ||
|
||
<h1>Hello, world!</h1> | ||
<h1>BlazorWASM Keycloak Authentication</h1> | ||
|
||
This application demonstrates how to integrate with Keycloak from BlazorWASM application. | ||
|
||
@if (claims.Count() > 0) | ||
{ | ||
<h2>User Claims:</h2> | ||
<ul> | ||
@foreach (var claim in claims) | ||
{ | ||
<li>@claim.Type: @claim.Value</li> | ||
} | ||
</ul> | ||
} | ||
|
||
@code { | ||
private IEnumerable<Claim> claims = Enumerable.Empty<Claim>(); | ||
|
||
Welcome to your new app. | ||
protected override Task OnInitializedAsync() => GetClaimsPrincipalData(); | ||
|
||
<SurveyPrompt Title="How is Blazor working for you?" /> | ||
private async Task GetClaimsPrincipalData() | ||
{ | ||
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); | ||
var user = authState.User; | ||
if (user.Identity?.IsAuthenticated ?? false) | ||
{ | ||
claims = user.Claims; | ||
} | ||
} | ||
} |
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
This file was deleted.
Oops, something went wrong.