-
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.
Allow API access with a token from Authorize access (#1274)
- Loading branch information
Showing
6 changed files
with
42 additions
and
16 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
1 change: 1 addition & 0 deletions
1
TeachingRecordSystem/src/TeachingRecordSystem.Api/appsettings.Development.json
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
1 change: 1 addition & 0 deletions
1
TeachingRecordSystem/src/TeachingRecordSystem.Api/appsettings.Testing.json
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
17 changes: 16 additions & 1 deletion
17
...ngRecordSystem/src/TeachingRecordSystem.AuthorizeAccess/Pages/OidcTest/SignedIn.cshtml.cs
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,12 +1,27 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Text.Json; | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using static IdentityModel.OidcConstants; | ||
|
||
namespace TeachingRecordSystem.AuthorizeAccess.Pages.OidcTest; | ||
|
||
[Authorize(AuthenticationSchemes = TestAppConfiguration.AuthenticationSchemeName)] | ||
public class SignedInModel : PageModel | ||
{ | ||
public void OnGet() | ||
[Display(Name = "Access token")] | ||
public string? AccessToken { get; set; } | ||
|
||
[Display(Name = "Claims")] | ||
public string? ClaimsJson { get; set; } | ||
|
||
public async Task OnGet() | ||
{ | ||
AccessToken = await HttpContext.GetTokenAsync(TestAppConfiguration.AuthenticationSchemeName, TokenTypes.AccessToken); | ||
|
||
ClaimsJson = JsonSerializer.Serialize( | ||
User.Claims.ToDictionary(c => c.Type, c => c.Value), | ||
new JsonSerializerOptions() { WriteIndented = true }); | ||
} | ||
} |
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