Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
afedyanin committed Oct 25, 2023
1 parent 7d11610 commit 40a8128
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 76 deletions.
53 changes: 13 additions & 40 deletions src/BlazorApp/Pages/CurrentUser.razor
Original file line number Diff line number Diff line change
@@ -1,46 +1,19 @@
@page "/current-user"

@using BlazorShared;
@using BlazorShared.Authorization;
<h1>Current user</h1>

@inject HttpClient Http

@attribute [Authorize]

<PageTitle>Current User Info</PageTitle>

<h1>Current User Info</h1>

@if (user == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Claim Type</th>
<th>Claim Value</th>
</tr>
</thead>
<tbody>
@foreach (var claim in user.Claims!)
<AuthorizeView>
<Authorized>
<dl>
@foreach (var claim in @context.User.Claims)
{
<tr>
<td>@claim.Type</td>
<td>@claim.Value</td>
</tr>
<dt>@claim.Type</dt>
<dd>@claim.Value</dd>
}
</tbody>
</table>
}

@code {
private UserInfo? user;
</dl>
</Authorized>
<NotAuthorized>
<h3>No session</h3>
</NotAuthorized>
</AuthorizeView>

protected override async Task OnInitializedAsync()
{
user = await Http.GetFromJsonAsync<UserInfo>("User");
}
}
4 changes: 2 additions & 2 deletions src/BlazorBff/AuthorizationRegistrar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ internal static void AddOidcAuthentication(this IServiceCollection services, ICo
options.Authority = config.Authority;
options.ClientId = config.ClientId;
options.ClientSecret = config.ClientSecret;
options.MetadataAddress = config.MetadataUrl;
options.CallbackPath = config.CallbackPath;
//options.MetadataAddress = config.MetadataUrl;
//options.CallbackPath = config.CallbackPath;
options.ResponseType = OpenIdConnectResponseType.Code;
options.ResponseMode = OpenIdConnectResponseMode.Query;
options.MapInboundClaims = false;
Expand Down
4 changes: 1 addition & 3 deletions src/BlazorBff/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"OpenIDConnectSettings": {
"Authority": "http:https://localhost:8080/realms/myrealm",
"ClientId": "blazor-client",
"ClientSecret": "9y4B7MlwJn7dd7K9QRH2tQjQKrfTpE8x",
"MetadataUrl": "",
"CallbackPath": "/Account/Login-callback"
"ClientSecret": "TdNGcpOEEVggrMFhfne1OdSob2hqWGWB",
},
"AllowedHosts": "*"
}
17 changes: 0 additions & 17 deletions src/BlazorShared/Authorization/ClaimValue.cs

This file was deleted.

14 changes: 0 additions & 14 deletions src/BlazorShared/Authorization/UserInfo.cs

This file was deleted.

0 comments on commit 40a8128

Please sign in to comment.