Implemented token fetch

This commit is contained in:
2026-08-16 14:21:34 +02:00
parent def73c3fa8
commit 8d77e99c75
9 changed files with 51 additions and 16 deletions
+2
View File
@@ -10,6 +10,7 @@
*.userosscache
*.sln.docstates
*.env
*.env.json
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
@@ -55,6 +56,7 @@ bld/
# Visual Studio 2015/2017 cache/options directory
.vs/
.vscode/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
@@ -1,14 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>59a05094-4ac2-472d-af04-3407e909432d</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.11" />
<PackageReference Include="Microsoft.OpenApi" Version="2.12.0" />
<PackageReference Include="Scalar.AspNetCore" Version="2.16.20" />
</ItemGroup>
</Project>
@@ -1,6 +0,0 @@
@PostFundManagement.Api_HostAddress = http://localhost:5112
GET {{PostFundManagement.Api_HostAddress}}/weatherforecast/
Accept: application/json
###
+8 -1
View File
@@ -1,3 +1,5 @@
using Scalar.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
@@ -9,6 +11,11 @@ var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.MapScalarApiReference(options =>
{
options.WithTitle("Post-fund Management API")
.WithTheme(ScalarTheme.BluePlanet);
});
app.MapOpenApi();
}
@@ -21,7 +28,7 @@ var summaries = new[]
app.MapGet("/weatherforecast", () =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
@@ -1,8 +0,0 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
+4
View File
@@ -1,4 +1,8 @@
{
"MachineIdentity": {
"Authority": "https://sts.security.khongisa.co.za",
"Audience": "pfm-api-dev"
},
"Logging": {
"LogLevel": {
"Default": "Information",
+16
View File
@@ -0,0 +1,16 @@
@hostname = api.example.com
@port = 8080
@host = {{hostname}}:{{port}}
@contentType = application/json
###
# @prompt username
# @prompt refCode Your reference code display on webpage
# @prompt otp Your one-time password in your mailbox
POST https://{{host}}/verify-otp/{{refCode}} HTTP/1.1
Content-Type: {{contentType}}
{
"username": "{{username}}",
"otp": "{{otp}}"
}
+6
View File
@@ -0,0 +1,6 @@
### Token Request
POST https://{{authority}}/connect/token
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: identity
grant_type={{grantType}}&client_id={{clientId}}&client_secret={{clientSecret}}&scope={{scope}}
@@ -0,0 +1,12 @@
namespace PostFundManagement.Infrastructure.Configuration;
public sealed class MachineIdentity
{
public string? Authority { get; set; }
public string? Audience { get; set; }
public string? ClientId { get; set; }
public string? ClientSecret { get; set; }
}