Skip to content

Commit

Permalink
Merge pull request #7 from DuendeSoftware/aspnet-extensions
Browse files Browse the repository at this point in the history
Use Duende.AspNetCore extensions for DPoP
  • Loading branch information
josephdecock authored Nov 6, 2024
2 parents 9171451 + f063af6 commit 61cba16
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 987 deletions.
22 changes: 16 additions & 6 deletions src/Api/TestController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using DPoPApi;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using IdentityModel;

namespace Duende.IdentityServer.Demo
{
Expand All @@ -10,8 +10,8 @@ public class TestController : ControllerBase
[Authorize(AuthenticationSchemes = IdentityServerConstants.LocalApi.AuthenticationScheme)]
public IActionResult Get()
{
var scheme = Request.GetAuthorizationScheme();
var proofToken = Request.GetDPoPProofToken();
var scheme = GetAuthorizationScheme(Request);
var proofToken = GetDPoPProofToken(Request);

var claims = User.Claims.Select(c => new { c.Type, c.Value }).ToList();

Expand All @@ -28,14 +28,24 @@ public IActionResult Get()
[Authorize(AuthenticationSchemes = "dpop")]
public IActionResult GetDPoP()
{
var scheme = Request.GetAuthorizationScheme();
var proofToken = Request.GetDPoPProofToken();
var scheme = GetAuthorizationScheme(Request);
var proofToken = GetDPoPProofToken(Request);

var claims = User.Claims.Select(c => new { c.Type, c.Value }).ToList();
claims.Add(new { Type = "authorization_scheme", Value = scheme });
claims.Add(new { Type = "proof_token", Value = proofToken });

return new JsonResult(claims);
}

private static string GetAuthorizationScheme(HttpRequest request)
{
return request.Headers.Authorization.FirstOrDefault()?.Split(' ', StringSplitOptions.RemoveEmptyEntries)[0];
}

private static string GetDPoPProofToken(HttpRequest request)
{
return request.Headers[OidcConstants.HttpHeaders.DPoP].FirstOrDefault();
}
}
}
35 changes: 0 additions & 35 deletions src/DPoP/ConfigureJwtBearerOptions.cs

This file was deleted.

81 changes: 0 additions & 81 deletions src/DPoP/DPoPExtensions.cs

This file was deleted.

153 changes: 0 additions & 153 deletions src/DPoP/DPoPJwtBearerEvents.cs

This file was deleted.

13 changes: 0 additions & 13 deletions src/DPoP/DPoPMode.cs

This file was deleted.

15 changes: 0 additions & 15 deletions src/DPoP/DPoPOptions.cs

This file was deleted.

30 changes: 0 additions & 30 deletions src/DPoP/DPoPProofValidatonContext.cs

This file was deleted.

Loading

0 comments on commit 61cba16

Please sign in to comment.