/
githubmirror
/
aspnetcore
Обзор
Документация
Войти
/
githubmirror
/
aspnetcore
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Security/Authentication/test/WsFederation/TestTokenHandler.cs
30 строк
1019 B
Keegan Caruso
Update JwtBearer, WsFed, and OIDC handlers to use identity model 7 (#49541)
21 июл 2023, 19:39
Не верифицирован
21 июл 2023, 19:39
a56e968
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Security.Claims; using Microsoft.IdentityModel.Tokens; namespace Microsoft.AspNetCore.Authentication.WsFederation; internal class TestSecurityTokenHandler : TokenHandler { public override SecurityToken ReadToken(string token) { return new TestSecurityToken(); } public override Task<TokenValidationResult> ValidateTokenAsync(string token, TokenValidationParameters validationParameters) { if (!string.IsNullOrEmpty(token) && token.Contains("ThisIsAValidToken")) { return Task.FromResult(new TokenValidationResult { ClaimsIdentity = new ClaimsIdentity("Test"), IsValid = true, SecurityToken = new TestSecurityToken() }); } throw new SecurityTokenException("The security token did not contain ThisIsAValidToken"); } }