当前位置: 首页 > news >正文

怎么写网站规划方案wordpress评论不准设置网站

怎么写网站规划方案,wordpress评论不准设置网站,python wordpress 外链,数字化营销怎么做最近研究dotnet core,微软将IdentityServer4作为推荐的服务授权和验证的组件,其独立性特别适合微服务或者分布式的服务扩展验证,所以非常受广大dotnet开发人员的青睐.默认的IdentityServer4默认使用内存对象的验证和授权,而在IdentityServer的官方推荐只有Entity Framework cor… 最近研究dotnet core,微软将IdentityServer4作为推荐的服务授权和验证的组件,其独立性特别适合微服务或者分布式的服务扩展验证,所以非常受广大dotnet开发人员的青睐.默认的IdentityServer4默认使用内存对象的验证和授权,而在IdentityServer的官方推荐只有Entity Framework core的集成,默认也只有SQL Server的实例,如果想要使用MySQL等其他数据库,Google了好多或多或少都遇到了很多坑,本人也尝试了N(N4)小时,最终还是放弃使用EF Core,改用比较透明化的Dapper来实现持久层.最终的项目地址如下:https://github.com/DarinHan/IdentityServer4.Dapper关于该项目的使用方法参考项目的说明,有一份MySQL的Demo示例,如果使用SQL Server,也有类似的方法供使用.下面就具体实现原理给大家介绍下细节,方便大家理解IdentityServer4的内部原理.在研究了IdentityServer4.EntityFramework的源代码后,知道要实现IdentityServer中内置对象的Client,Apiresource,Identityresource,PersistedGrant的持久化,主要要实现3个Store,即项目中的ClientStore,ResourceStore,PersistedGrantStore.从字面意思来看,这三个Store承担着商店的角色,提供Client,Resource以及PersistedGrant的查询等功能.此外我们知道如果需要查询这三个对象,前提是我们得先保存到数据库中,所以对于Client对象我们需要实现查询(Store的角色),新增和修改的功能,这样如果我们在管理后台中才能通过新增和修改的功能动态维护这些对象.为了不污染Store在IdentityServer中的定义,我们引入IProvider接口的概念,分别对应四个接口(区分API和Identity)如下using IdentityServer4.Models;using System.Collections.Generic; namespace IdentityServer4.Dapper.Interfaces{    public interface IClientProvider    {        Client FindClientById(string clientid);        void Add(Client client);        IEnumerablestring QueryAllowedCorsOrigins();      }}using IdentityServer4.Models;using System.Collections.Generic; namespace IdentityServer4.Dapper.Interfaces{    public interface IIdentityResourceProvider    {        IEnumerableIdentityResource FindIdentityResourcesByScope(IEnumerablestring scopeNames);        IEnumerableIdentityResource FindIdentityResourcesAll();        void Add(IdentityResource identityResource);        IdentityResource FindIdentityResourcesByName(string name);    }}using IdentityServer4.Models;using System.Collections.Generic; namespace IdentityServer4.Dapper.Interfaces{    public interface IApiResourceProvider    {        ApiResource FindApiResource(string name);        IEnumerableApiResource FindApiResourcesByScope(IEnumerablestring scopeNames);        IEnumerableApiResource FindApiResourcesAll();        void Add(ApiResource apiResource);    }}using IdentityServer4.Models;using System.Collections.Generic; namespace IdentityServer4.Dapper.Interfaces{    public interface IPersistedGrantProvider    {        IEnumerablePersistedGrant GetAll(string subjectId);        IEnumerablePersistedGrant GetAll(string subjectId, string clientId);        IEnumerablePersistedGrant GetAll(string subjectId, string clientId, string type);        PersistedGrant Get(string key);        void Add(PersistedGrant token);        void Update(PersistedGrant token);        void RemoveAll(string subjectId, string clientId);        void RemoveAll(string subjectId, string clientId, string type);        void Remove(string key);        void Store(PersistedGrant grant);    }}在我们得Store中通过的注入的方式使用接口对应的服务,并实现对应IStore对应的接口方法,比如ClientStore实现如下.    public class ClientStore : IClientStore    {        private readonly IClientProvider _clientDB;        private readonly ILoggerClientStore _logger;         public ClientStore(IClientProvider client, ILoggerClientStore logger)        {            _clientDB client ?? throw new ArgumentNullException(nameof(client));            _logger logger;        }         public TaskClient FindClientByIdAsync(string clientId)        {            var client _clientDB.FindClientById(clientId);             _logger.LogDebug({clientId} found in database: {clientIdFound}, clientId, client ! null);            return Task.FromResultClient(client);        }    }在Identity这样,最终对应Client的读写操作都转移到了IClientProvider中.Server4.Dapper.DefaultProviders命名空间下,我们提供了Iprovider的默认实现.实现方法使用了Dapper和AutoMapper实现了数据库操作,这里就不一一举例了.值得一说的是部分对象字段都是SQL的关键字,直接执行SQL会报错,我们使用了数据库中的列名保护的方法,具体实现方法在各个数据库实例项目中配置.比如在MySQL的实现中,我们配置保护字符为.public static class IdentityServerDapperExtensions    {        public static IIdentityServerBuilder AddMySQLProvider(this IIdentityServerBuilder builder, ActionDBProviderOptions dbProviderOptionsAction null)        {            //config mysql            var options new DBProviderOptions();            options.DbProviderFactory new MySqlClientFactory();            //get last insert id for insert actions            options.GetLastInsertID select last_insert_id();;             //config the ColumnName protect string, mysql using             options.ColumnProtect new System.Collections.Generic.Dictionarystring, string();            options.ColumnProtect.Add(left, );            options.ColumnProtect.Add(right, );            //add singgleton            builder.Services.AddSingleton(options);             dbProviderOptionsAction?.Invoke(options);            return builder;        }    }最终实现的IProvider使用扩展方法注入到容器中.public static IIdentityServerBuilder AddConfigurationStore(this IIdentityServerBuilder builder, ActionConfigurationStoreOptions storeOptionsAction null)        {            var options new ConfigurationStoreOptions();            storeOptionsAction?.Invoke(options);            builder.Services.AddSingleton(options);             builder.Services.AddTransientInterfaces.IClientProvider, DefaultProviders.DefaultClientProvider();            builder.Services.AddTransientInterfaces.IApiResourceProvider, DefaultProviders.DefaultApiResourceProvider();            builder.Services.AddTransientInterfaces.IIdentityResourceProvider, DefaultProviders.DefaultIdentityResourceProvider();             builder.AddClientStoreClientStore();            builder.AddResourceStoreResourceStore();            builder.AddCorsPolicyServiceCorsPolicyService();            return builder;        }在OperationStore方法中,需要将原来IdentityServer4中默认提供的InMemory的实例移除,再添加新的实例.        public static IIdentityServerBuilder AddOperationalStore(this IIdentityServerBuilder builder, ActionOperationalStoreOptions storeOptionsAction null)        {            builder.Services.AddSingletonTokenCleanup();            builder.Services.AddSingletonIHostedService, TokenCleanupHost();//auto clear expired tokens             builder.Services.AddTransientInterfaces.IPersistedGrantProvider, DefaultProviders.DefaultPersistedGrantProvider();            builder.Services.AddTransientInterfaces.IPersistedGrantStoreClanup, DefaultProviders.DefaultPersistedGrantProvider();             var storeOptions new OperationalStoreOptions();            storeOptionsAction?.Invoke(storeOptions);            builder.Services.AddSingleton(storeOptions);             var memopersistedstore builder.Services.FirstOrDefault(c c.ServiceType typeof(IPersistedGrantStore));            if (memopersistedstore ! null)            {                builder.Services.Remove(memopersistedstore);            }            builder.Services.AddSingletonIPersistedGrantStore, PersistedGrantStore();            memopersistedstore builder.Services.FirstOrDefault(c c.ServiceType typeof(IPersistedGrantStore));            return builder;        }到此,基本的持久化改造已经完成了,当然在该项目中还实现了一个自动删除过期Token的服务,这个服务也是EFCore中实现的,基本上是把功能复制过来,具体细节稍有改造. 原文地址:https://blog.csdn.net/u013710468/article/details/81675747.NET社区新闻深度好文欢迎访问公众号文章汇总 http://www.csharpkit.com
http://www.zqtcl.cn/news/163055/

相关文章:

  • 微信网站链接怎么做wordpress 绑定手机版
  • 网站建设的内容是什么在线阅读小说网站怎么建设
  • 福州网站开发哪家比较好建设网站需要掌握什么编程语言
  • 邹平做网站的公司莱芜人才网莱芜招聘
  • 旅行网站开发意义怎样优化网络速度
  • 手机微网站建设多少钱拟定网络设计方案
  • 厦门制作公司网站安卓原生app开发工具
  • worldpress英文网站建设wordpress输出外部文章
  • u9u8网站建设商业公司的域名
  • 有学给宝宝做衣服的网站吗防网站黑客
  • 十大搜索引擎网站微信小程序有什么用处?
  • 团购网站 seo烟台网站建设方案优化
  • 公司网站建设招标文件范本公益永久免费主机
  • 建设银行网站查询企业年金五合一免费建站
  • 做网站开发挣钱吗做网站手机版
  • 网站建设案例精粹 电子书广州白云学校网站建设
  • 良品铺子网站制作用什么软件来做网站
  • ip直接访问网站 备案哪有深圳设计公司
  • 平面构成作品网站第一设计
  • 济南小程序开发多少钱网站移动端优化工具
  • 大连开发区网站淘宝网站优化实例
  • 张家港建网站的公司做网站犯法了 程序员有责任吗
  • 小型企业网站建设项目浦东新区网站推广公司
  • 上海做网站优化公司ps最好用的素材网站
  • 网站建设品牌推广seo制作公司网站
  • 个人网站服务器一年多少钱科技让生活更美好作文450字
  • 开学第一课汉字做网站网盘资源搜索神器
  • 备案网站应用服务树莓派用来做网站
  • 找装修公司上什么网站湘潭交通网站
  • php网站服务建设网站增加关键字