Files
WireMock.Net/test/WireMock.Net.Tests/Authentication/MockJwtSecurityTokenHandler.cs
Stef Heyenrath 249b3562ab Update AzureADAuthenticationMatcher to support V2 Azure AAD tokens (#1288)
* Update AzureADAuthenticationMatcher to support V2 Azure AAD tokens

* fix ;-)

* add tests

* Update test/WireMock.Net.Tests/Authentication/MockJwtSecurityTokenHandler.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* .

* WIREMOCK_AAD_TENANT

* update logging

* throw new SecurityTokenInvalidIssuerException($"tenant {extractedTenant} does not match {_tenant}.");

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-05-06 18:49:21 +02:00

18 lines
647 B
C#

// Copyright © WireMock.Net
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using Microsoft.IdentityModel.Tokens;
namespace WireMock.Net.Tests.Authentication;
internal class MockJwtSecurityTokenHandler : JwtSecurityTokenHandler
{
public override ClaimsPrincipal ValidateToken(string token, TokenValidationParameters validationParameters, out SecurityToken validatedToken)
{
validatedToken = new JwtSecurityToken();
var claims = new[] { new Claim(ClaimTypes.Name, "TestUser") };
var identity = new ClaimsIdentity(claims, "TestAuthType");
return new ClaimsPrincipal(identity);
}
}