{"id":13431592,"url":"https://github.com/jwt-dotnet/jwt","last_synced_at":"2026-04-02T02:08:01.867Z","repository":{"id":1549613,"uuid":"1921154","full_name":"jwt-dotnet/jwt","owner":"jwt-dotnet","description":"Jwt.Net, a JWT (JSON Web Token) implementation for .NET","archived":false,"fork":false,"pushed_at":"2025-03-18T01:47:04.000Z","size":7358,"stargazers_count":2189,"open_issues_count":9,"forks_count":469,"subscribers_count":81,"default_branch":"main","last_synced_at":"2026-02-25T23:22:12.899Z","etag":null,"topics":["authorization","c-sharp","json","jwt"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"git-tfs/git-tfs.github.com","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jwt-dotnet.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-06-19T23:46:02.000Z","updated_at":"2026-02-25T15:36:11.000Z","dependencies_parsed_at":"2024-05-29T17:18:56.095Z","dependency_job_id":"6ec260d0-f7af-47e2-b335-748a5ccf6d2e","html_url":"https://github.com/jwt-dotnet/jwt","commit_stats":{"total_commits":285,"total_committers":68,"mean_commits":"4.1911764705882355","dds":"0.40701754385964917","last_synced_commit":"515a8e6c87c3efda5a5574c0b6a8f8e834919e9f"},"previous_names":["johnsheehan/jwt"],"tags_count":89,"template":false,"template_full_name":null,"purl":"pkg:github/jwt-dotnet/jwt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwt-dotnet%2Fjwt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwt-dotnet%2Fjwt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwt-dotnet%2Fjwt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwt-dotnet%2Fjwt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwt-dotnet","download_url":"https://codeload.github.com/jwt-dotnet/jwt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwt-dotnet%2Fjwt/sbom","scorecard":{"id":545475,"data":{"date":"2025-08-11","repo":{"name":"github.com/jwt-dotnet/jwt","commit":"35344081eccf8ac873b3c78639f9632fb4672108"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":3,"reason":"Found 5/14 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T09:23:14.893Z","repository_id":1549613,"created_at":"2025-08-20T09:23:14.893Z","updated_at":"2025-08-20T09:23:14.893Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31294398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:43:37.129Z","status":"online","status_checked_at":"2026-04-02T02:00:08.535Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authorization","c-sharp","json","jwt"],"created_at":"2024-07-31T02:01:04.352Z","updated_at":"2026-04-02T02:08:01.296Z","avatar_url":"https://github.com/jwt-dotnet.png","language":"C#","readme":"\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\r\n\u003c!-- DO NOT EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\r\n\r\n- [Jwt.Net, a JWT (JSON Web Token) implementation for .NET](#jwtnet-a-jwt-json-web-token-implementation-for-net)\r\n- [Sponsor](#sponsor)\r\n- [Avaliable NuGet packages](#avaliable-nuget-packages)\r\n- [Supported .NET versions:](#supported-net-versions)\r\n- [Jwt.NET](#jwtnet)\r\n  - [Creating (encoding) token](#creating-encoding-token)\r\n    - [Or using the fluent builder API](#or-using-the-fluent-builder-api)\r\n  - [Parsing (decoding) and verifying token](#parsing-decoding-and-verifying-token)\r\n    - [Or using the fluent builder API](#or-using-the-fluent-builder-api-1)\r\n    - [Or using the fluent builder API](#or-using-the-fluent-builder-api-2)\r\n  - [Validate token expiration](#validate-token-expiration)\r\n  - [Parsing (decoding) token header](#parsing-decoding-token-header)\r\n    - [Or using the fluent builder API](#or-using-the-fluent-builder-api-3)\r\n  - [Turning off parts of token validation](#turning-off-parts-of-token-validation)\r\n    - [Or using the fluent builder API](#or-using-the-fluent-builder-api-4)\r\n  - [Custom JSON serializer](#custom-json-serializer)\r\n  - [Custom JSON serialization settings with the default JsonNetSerializer](#custom-json-serialization-settings-with-the-default-jsonnetserializer)\r\n- [Jwt.Net ASP.NET Core](#jwtnet-aspnet-core)\r\n  - [Register authentication handler to validate JWT](#register-authentication-handler-to-validate-jwt)\r\n  - [Custom factories to produce Identity or AuthenticationTicket](#custom-factories-to-produce-identity-or-authenticationticket)\r\n- [License](#license)\r\n\r\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\r\n\r\n[![Build status](https://abatishchev.visualstudio.com/OpenSource/_apis/build/status/Jwt.Net-CI)](https://abatishchev.visualstudio.com/OpenSource/_build/latest?definitionId=9)\r\n[![Release status](https://abatishchev.vsrm.visualstudio.com/_apis/public/Release/badge/b7fc2610-91d5-4968-814c-97a9d76b03c4/2/2)](https://abatishchev.visualstudio.com/OpenSource/_release?_a=releases\u0026view=mine\u0026definitionId=2)\r\n\r\n## Jwt.Net, a JWT (JSON Web Token) implementation for .NET\r\n\r\nThis library supports generating and decoding [JSON Web Tokens](https://tools.ietf.org/html/rfc7519).\r\n\r\n## Sponsor\r\n\r\n| | |\r\n|-|-|\r\n| [\u003cimg alt=\"Auth0 logo\" src=\"https://cdn.auth0.com/blog/github-sponsorships/brand-evolution-logo-Auth0-horizontal-Indigo.png\" height=\"91\"\u003e](https://a0.to/try-auth0) | If you want to quickly implement a secure authentication to your JWT project, [create an Auth0 account](https://a0.to/try-auth0); it's Free! |\r\n\r\n## Avaliable NuGet packages\r\n\r\n1.  Jwt.Net\r\n\r\n[![NuGet](https://img.shields.io/nuget/v/JWT.svg)](https://www.nuget.org/packages/JWT)\r\n[![NuGet Pre](https://img.shields.io/nuget/vpre/JWT.svg)](https://www.nuget.org/packages/JWT)\r\n\r\n2. Jwt.Net for Microsoft Dependency Injection container\r\n\r\n[![NuGet](https://img.shields.io/nuget/v/JWT.Extensions.DependencyInjection.svg)](https://www.nuget.org/packages/JWT.Extensions.DependencyInjection)\r\n[![NuGet Pre](https://img.shields.io/nuget/vpre/JWT.Extensions.DependencyInjection.svg)](https://www.nuget.org/packages/JWT.Extensions.DependencyInjection)\r\n\r\n3. Jwt.Net for ASP.NET Core\r\n\r\n[![NuGet](https://img.shields.io/nuget/v/JWT.Extensions.AspNetCore.svg)](https://www.nuget.org/packages/JWT.Extensions.AspNetCore)\r\n[![NuGet Pre](https://img.shields.io/nuget/vpre/JWT.Extensions.AspNetCore.svg)](https://www.nuget.org/packages/JWT.Extensions.AspNetCore)\r\n\r\n## Supported .NET versions:\r\n\r\n- .NET Framework 3.5\r\n- .NET Framework 4.0 - 4.8\r\n- .NET Standard 1.3, 2.0\r\n- .NET 6.0\r\n\r\n## Jwt.NET\r\n\r\n### Creating (encoding) token\r\n\r\n```c#\r\nvar payload = new Dictionary\u003cstring, object\u003e\r\n{\r\n    { \"claim1\", 0 },\r\n    { \"claim2\", \"claim2-value\" }\r\n};\r\n\r\nIJwtAlgorithm algorithm = new RS256Algorithm(certificate);\r\nIJsonSerializer serializer = new JsonNetSerializer();\r\nIBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();\r\nIJwtEncoder encoder = new JwtEncoder(algorithm, serializer, urlEncoder);\r\nconst string key = null; // not needed if algorithm is asymmetric\r\n\r\nvar token = encoder.Encode(payload, key);\r\nConsole.WriteLine(token);\r\n```\r\n\r\n#### Or using the fluent builder API\r\n\r\n```c#\r\nvar token = JwtBuilder.Create()\r\n                      .WithAlgorithm(new RS256Algorithm(certificate))\r\n                      .AddClaim(\"exp\", DateTimeOffset.UtcNow.AddHours(1).ToUnixTimeSeconds())\r\n                      .AddClaim(\"claim1\", 0)\r\n                      .AddClaim(\"claim2\", \"claim2-value\")\r\n                      .Encode();\r\nConsole.WriteLine(token);\r\n```\r\n### Parsing (decoding) and verifying token\r\n\r\n```c#\r\ntry\r\n{\r\n    IJsonSerializer serializer = new JsonNetSerializer();\r\n    IDateTimeProvider provider = new UtcDateTimeProvider();\r\n    IJwtValidator validator = new JwtValidator(serializer, provider);\r\n    IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();\r\n    IJwtAlgorithm algorithm = new RS256Algorithm(certificate);\r\n    IJwtDecoder decoder = new JwtDecoder(serializer, validator, urlEncoder, algorithm);\r\n    \r\n    var json = decoder.Decode(token);\r\n    Console.WriteLine(json);\r\n}\r\ncatch (TokenNotYetValidException)\r\n{\r\n    Console.WriteLine(\"Token is not valid yet\");\r\n}\r\ncatch (TokenExpiredException)\r\n{\r\n    Console.WriteLine(\"Token has expired\");\r\n}\r\ncatch (SignatureVerificationException)\r\n{\r\n    Console.WriteLine(\"Token has invalid signature\");\r\n}\r\n```\r\n\r\n#### Or using the fluent builder API\r\n\r\n```c#\r\nvar json = JwtBuilder.Create()\r\n                     .WithAlgorithm(new RS256Algorithm(certificate))\r\n                     .MustVerifySignature()\r\n                     .Decode(token);                    \r\nConsole.WriteLine(json);\r\n```\r\n\r\nThe output would be:\r\n\r\n\u003e{ \"claim1\": 0, \"claim2\": \"claim2-value\" }\r\n\r\nYou can also deserialize the JSON payload directly to a .NET type:\r\n\r\n```c#\r\nvar payload = decoder.DecodeToObject\u003cIDictionary\u003cstring, object\u003e\u003e(token, secret);\r\n```\r\n\r\n#### Or using the fluent builder API\r\n\r\n```c#\r\nvar payload = JwtBuilder.Create()\r\n                        .WithAlgorithm(new RS256Algorithm(certificate))\r\n                        .WithSecret(secret)\r\n                        .MustVerifySignature()\r\n                        .Decode\u003cIDictionary\u003cstring, object\u003e\u003e(token);     \r\n```\r\n\r\n### Validate token expiration\r\n\r\nAs described in the [RFC 7519 section 4.1.4](https://tools.ietf.org/html/rfc7519#section-4.1.4):\r\n\r\n\u003eThe `exp` claim identifies the expiration time on or after which the JWT MUST NOT be accepted for processing.\r\n\r\nIf it is present in the payload and is past the current time, the token will fail verification. The value must be specified as the number of seconds since the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time), 1/1/1970 00:00:00 UTC.\r\n\r\n```c#\r\nIDateTimeProvider provider = new UtcDateTimeProvider();\r\nvar now = provider.GetNow().AddMinutes(-5); // token has expired 5 minutes ago\r\n\r\ndouble secondsSinceEpoch = UnixEpoch.GetSecondsSince(now);\r\n\r\nvar payload = new Dictionary\u003cstring, object\u003e\r\n{\r\n    { \"exp\", secondsSinceEpoch }\r\n};\r\nvar token = encoder.Encode(payload);\r\n\r\ndecoder.Decode(token); // throws TokenExpiredException\r\n```\r\n\r\nThen, as described in the [RFC 7519 section 4.1.5](https://tools.ietf.org/html/rfc7519#section-4.1.5):\r\n\r\n\u003eThe \"nbf\" (not before) claim identifies the time before which the JWT MUST NOT be accepted for processing\r\n\r\nIf it is present in the payload and is prior to the current time, the token will fail verification.\r\n\r\n### Parsing (decoding) token header\r\n\r\n```c#\r\nIJsonSerializer serializer = new JsonNetSerializer();\r\nIBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();\r\nIJwtDecoder decoder = new JwtDecoder(serializer, urlEncoder);\r\n\r\nJwtHeader header = decoder.DecodeHeader\u003cJwtHeader\u003e(token);\r\n\r\nvar typ = header.Type; // JWT\r\nvar alg = header.Algorithm; // RS256\r\nvar kid = header.KeyId; // CFAEAE2D650A6CA9862575DE54371EA980643849\r\n```\r\n\r\n#### Or using the fluent builder API\r\n\r\n```c#\r\nJwtHeader header = JwtBuilder.Create()\r\n                             .DecodeHeader\u003cJwtHeader\u003e(token);\r\n\r\nvar typ = header.Type; // JWT\r\nvar alg = header.Algorithm; // RS256\r\nvar kid = header.KeyId; // CFAEAE2D650A6CA9862575DE54371EA980643849\r\n```\r\n\r\n### Turning off parts of token validation\r\n\r\nIf you'd like to validate a token but ignore certain parts of the validation (such as whether to the token has expired or not valid yet), you can pass a `ValidateParameters` object to the constructor of the `JwtValidator` class.\r\n\r\n```c#\r\nvar validationParameters = new ValidationParameters\r\n{\r\n    ValidateSignature = true,\r\n    ValidateExpirationTime = false,\r\n    ValidateIssuedTime = false,\r\n    TimeMargin = 100\r\n};\r\nIJwtValidator validator = new JwtValidator(serializer, provider, validationParameters);\r\nIJwtDecoder decoder = new JwtDecoder(serializer, validator, urlEncoder, algorithm);\r\nvar json = decoder.Decode(expiredToken); // will not throw because of expired token\r\n```\r\n\r\n#### Or using the fluent builder API\r\n\r\n```c#\r\nvar json = JwtBuilder.Create()\r\n                     .WithAlgorithm(new RS256Algorirhm(certificate))\r\n                     .WithSecret(secret)\r\n                     .WithValidationParameters(\r\n                         new ValidationParameters\r\n                         {\r\n                             ValidateSignature = true,\r\n                             ValidateExpirationTime = false,\r\n                             ValidateIssuedTime = false,\r\n                             TimeMargin = 100\r\n                         })\r\n                     .Decode(expiredToken);\r\n```\r\n\r\n### Custom JSON serializer\r\n\r\nBy default JSON serialization is performed by JsonNetSerializer implemented using [Json.Net](https://www.json.net). To use a different one, implement the `IJsonSerializer` interface:\r\n\r\n```c#\r\npublic sealed class CustomJsonSerializer : IJsonSerializer\r\n{\r\n    public string Serialize(object obj)\r\n    {\r\n        // Implement using favorite JSON serializer\r\n    }\r\n\r\n    public T Deserialize\u003cT\u003e(string json)\r\n    {\r\n        // Implement using favorite JSON serializer\r\n    }\r\n}\r\n```\r\n\r\nAnd then pass this serializer to JwtEncoder constructor:\r\n\r\n```c#\r\nIJwtAlgorithm algorithm = new RS256Algorirhm(certificate);\r\nIJsonSerializer serializer = new CustomJsonSerializer();\r\nIBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder();\r\nIJwtEncoder encoder = new JwtEncoder(algorithm, serializer, urlEncoder);\r\n```\r\n\r\n### Custom JSON serialization settings with the default JsonNetSerializer\r\n\r\nAs mentioned above, the default JSON serialization is done by `JsonNetSerializer`. You can define your own custom serialization settings as follows:\r\n\r\n```c#\r\nJsonSerializer customJsonSerializer = new JsonSerializer\r\n{\r\n    // All keys start with lowercase characters instead of the exact casing of the model/property, e.g. fullName\r\n    ContractResolver = new CamelCasePropertyNamesContractResolver(), \r\n    \r\n    // Nice and easy to read, but you can also use Formatting.None to reduce the payload size\r\n    Formatting = Formatting.Indented,\r\n    \r\n    // The most appropriate datetime format.\r\n    DateFormatHandling = DateFormatHandling.IsoDateFormat,\r\n    \r\n    // Don't add keys/values when the value is null.\r\n    NullValueHandling = NullValueHandling.Ignore,\r\n    \r\n    // Use the enum string value, not the implicit int value, e.g. \"red\" for enum Color { Red }\r\n    Converters.Add(new StringEnumConverter())\r\n};\r\nIJsonSerializer serializer = new JsonNetSerializer(customJsonSerializer);\r\n```\r\n\r\n## Jwt.Net ASP.NET Core\r\n\r\n### Register authentication handler to validate JWT\r\n\r\n```c#\r\npublic void ConfigureServices(IServiceCollection services)\r\n{\r\n    services.AddAuthentication(options =\u003e\r\n                 {\r\n                     options.DefaultAuthenticateScheme = JwtAuthenticationDefaults.AuthenticationScheme;\r\n                     options.DefaultChallengeScheme = JwtAuthenticationDefaults.AuthenticationScheme;\r\n                 })\r\n            .AddJwt(options =\u003e\r\n                 {\r\n                     // secrets, required only for symmetric algorithms, such as HMACSHA256Algorithm\r\n                     // options.Keys = new[] { \"mySecret\" };\r\n                     \r\n                     // optionally; disable throwing an exception if JWT signature is invalid\r\n                     // options.VerifySignature = false;\r\n                 });\r\n  // the non-generic version AddJwt() requires registering an instance of IAlgorithmFactory manually\r\n  services.AddSingleton\u003cIAlgorithmFactory\u003e(new RSAlgorithmFactory(certificate));\r\n  // or\r\n  services.AddSingleton\u003cIAlgorithmFactory\u003e(new DelegateAlgorithmFactory(algorithm));\r\n\r\n  // or use the generic version AddJwt\u003cTFactory() to use a custom implementation of IAlgorithmFactory\r\n  .AddJwt\u003cMyCustomAlgorithmFactory\u003e(options =\u003e ...);\r\n}\r\n\r\npublic void Configure(IApplicationBuilder app)\r\n{\r\n    app.UseAuthentication();\r\n}\r\n```\r\n\r\n### Custom factories to produce Identity or AuthenticationTicket\r\n\r\n```c#\r\nservices.AddSingleton\u003cIIdentityFactory, CustomIdentityFctory\u003e();\r\nservices.AddSingleton\u003cITicketFactory, CustomTicketFactory\u003e();\r\n```\r\n\r\n## License\r\n\r\nThe following projects and their resulting packages are licensed under Public Domain, see the [LICENSE#Public-Domain](LICENSE.md#Public-Domain) file.\r\n\r\n- JWT \r\n\r\nThe following projects and their resulting packages are licensed under the MIT License, see the [LICENSE#MIT](LICENSE.md#MIT) file.\r\n\r\n- JWT.Extensions.AspNetCore\r\n- JWT.Extensions.DependencyInjection\r\n","funding_links":[],"categories":["Frameworks, Libraries and Tools","C# #","Security","C\\#","Libraries","框架, 库和工具","Validator","🗒️ Cheatsheets"],"sub_categories":["Security",".Net","安全","📦 Libraries"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwt-dotnet%2Fjwt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwt-dotnet%2Fjwt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwt-dotnet%2Fjwt/lists"}