核心其实就一句代码: services.AddControllers(x => x.Filters.Add<AuthorizeAttribute>());
services.AddControllers(x => x.Filters.Add<AuthorizeAttribute>());
PS, 如果Controller中的代码加了 [AllowAnonymous] 的,那么可以覆盖AuthorizeAttribute
So easy.