• 大小: 0.29M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2020-12-14
  • 语言: C#
  • 标签: 接口  验证  asp.net  JWT  

资源简介

用visual studio code打开文件,运行dotnet watch run  

之后在postman里面去访问,可看到如下效果

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using System.Security.Claims;
using Microsoft.IdentityModel.Tokens;

namespace JwtAuthSample
{
    public class MyTokenValidator : ISecurityTokenValidator
    {
        public bool CanValidateToken => true;

        public int MaximumTokenSizeInBytes { get;set;}

        public bool CanReadToken(string securityToken)
        {
            return true;
        }

        public ClaimsPrincipal ValidateToken(string securityToken TokenValidationParameters validat

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-01-10 10:03  JwtAuthSampleMQ\
     目录           0  2018-01-10 10:02  JwtAuthSampleMQ\.vs\
     目录           0  2018-01-10 10:03  JwtAuthSampleMQ\.vscode\
     文件        1623  2018-01-10 10:03  JwtAuthSampleMQ\.vscode\launch.json
     文件         328  2018-01-10 10:03  JwtAuthSampleMQ\.vscode\tasks.json
     目录           0  2018-01-10 10:02  JwtAuthSampleMQ\.vs\config\
     文件       79914  2018-01-10 09:53  JwtAuthSampleMQ\.vs\config\applicationhost.config
     目录           0  2018-01-10 10:02  JwtAuthSampleMQ\.vs\JwtAuthSample\
     目录           0  2018-01-10 10:02  JwtAuthSampleMQ\.vs\JwtAuthSample\v15\
     文件        8192  2018-01-10 09:59  JwtAuthSampleMQ\.vs\JwtAuthSample\v15\.suo
     文件         178  2017-12-18 11:38  JwtAuthSampleMQ\appsettings.Development.json
     文件         376  2018-01-10 11:47  JwtAuthSampleMQ\appsettings.json
     目录           0  2018-01-10 10:02  JwtAuthSampleMQ\bin\
     目录           0  2018-01-10 10:02  JwtAuthSampleMQ\bin\Debug\
     目录           0  2018-01-10 10:02  JwtAuthSampleMQ\bin\Debug\netcoreapp2.0\
     文件      267955  2018-01-10 10:16  JwtAuthSampleMQ\bin\Debug\netcoreapp2.0\JwtAuthSample.deps.json
     文件       14336  2018-01-10 12:42  JwtAuthSampleMQ\bin\Debug\netcoreapp2.0\JwtAuthSample.dll
     文件        3212  2018-01-10 12:42  JwtAuthSampleMQ\bin\Debug\netcoreapp2.0\JwtAuthSample.pdb
     文件         252  2018-01-10 10:16  JwtAuthSampleMQ\bin\Debug\netcoreapp2.0\JwtAuthSample.runtimeconfig.dev.json
     文件         221  2018-01-10 10:16  JwtAuthSampleMQ\bin\Debug\netcoreapp2.0\JwtAuthSample.runtimeconfig.json
     目录           0  2018-01-10 10:02  JwtAuthSampleMQ\Controllers\
     文件        2600  2018-01-10 12:19  JwtAuthSampleMQ\Controllers\AuthorizeController.cs
     文件        1358  2018-01-10 12:00  JwtAuthSampleMQ\Controllers\ValuesController.cs
     文件         693  2017-12-19 10:44  JwtAuthSampleMQ\JwtAuthSample.csproj
     文件         241  2018-01-10 09:53  JwtAuthSampleMQ\JwtAuthSample.csproj.user
     目录           0  2018-01-10 10:02  JwtAuthSampleMQ\Models\
     文件         281  2018-01-10 12:38  JwtAuthSampleMQ\Models\JwtSettings.cs
     文件        1414  2017-12-19 16:54  JwtAuthSampleMQ\MyTokenValidator.cs
     目录           0  2018-01-10 10:15  JwtAuthSampleMQ\obj\
     目录           0  2018-01-10 10:02  JwtAuthSampleMQ\obj\Debug\
     目录           0  2018-01-10 10:02  JwtAuthSampleMQ\obj\Debug\netcoreapp2.0\
............此处省略19个文件信息

评论

共有 条评论