auth.liyouming.com 全部配

  1. public class Startup
  2. {
  3. public Startup(IConfiguration configuration)
  4. {
  5. Configuration = configuration;
  6. }
  7.  
  8. public IConfiguration Configuration { get; }
  9.  
  10. public void ConfigureServices(IServiceCollection services)
  11. {
  12.  
  13. services.AddMvc();
  14.  
  15. #region 业务数据库
  16. services.AddOptions();
  17. services.AddDbContext<CustomContext>(builder =>
  18. {
  19. builder.UseSqlServer(this.Configuration["ConnectionString"], options =>
  20. {
  21. options.UseRowNumberForPaging();
  22. options.MigrationsAssembly("LYM.OAuth2OpenId");
  23. });
  24. }, ServiceLifetime.Transient);
  25. #endregion
  26.  
  27. #region IdentityServer4 By liyouming Add At 2017-11-28
  28. //结合EFCore生成IdentityServer4数据库
  29. // 项目工程文件最后添加 <ItemGroup><DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" /></ItemGroup>
  30.  
  31. //dotnet ef migrations add InitialIdentityServerPersistedGrantDbMigration -c PersistedGrantDbContext -o Data/Migrations/IdentityServer/PersistedGrantDb
  32. //dotnet ef migrations add InitialIdentityServerConfigurationDbMigration -c ConfigurationDbContext -o Data/Migrations/IdentityServer/ConfigurationDb
  33.  
  34. //黎又铭 Add 2017-11-28 添加IdentityServer4对EFCore数据库的支持
  35. //但是这里需要初始化数据 默认生成的数据库中是没有配置数据
  36. const string connectionString = @"Data Source=192.168.0.42;Initial Catalog=A.IdentityServer4;User ID=sa;password=lym123!@#;Integrated Security=false;";
  37. var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
  38. string customUrl = this.Configuration["Authority"]; //"http://192.168.0.42:5000";
  39. #region 添加对IdentiyServer4配置内容处理 By Liyouming 2017-11-29
  40. services.AddIdentityServer(idroptions =>
  41. {
  42. //设置将在发现文档中显示的颁发者名称和已发布的JWT令牌。建议不要设置此属性,该属性从客户端使用的主机名中推断颁发者名称
  43. //idroptions.IssuerUri = "";
  44. //设置认证
  45. idroptions.Authentication = new IdentityServer4.Configuration.AuthenticationOptions
  46. {
  47. //监控浏览器cookie不难发现lym.Cookies=8660972474e55224ff37f7421c79a530 实际是cookie记录服务器session的名称
  48. CheckSessionCookieName = "lym.SessionId", // CookieAuthenticationDefaults.AuthenticationScheme,//用于检查会话端点的cookie的名称
  49. CookieLifetime = new TimeSpan(, , ),//身份验证Cookie生存期(仅在使用IdentityServer提供的Cookie处理程序时有效)
  50. CookieSlidingExpiration = true,//指定cookie是否应该滑动(仅在使用IdentityServer提供的cookie处理程序时有效)
  51. RequireAuthenticatedUserForSignOutMessage = true //指示是否必须对用户进行身份验证才能接受参数以结束会话端点。默认为false
  52. };
  53. //活动事件 允许配置是否应该将哪些事件提交给注册的事件接收器
  54. idroptions.Events = new IdentityServer4.Configuration.EventsOptions
  55. {
  56. RaiseErrorEvents = true,
  57. RaiseFailureEvents = true,
  58. RaiseSuccessEvents = true,
  59. RaiseInformationEvents = true
  60.  
  61. };
  62. //允许设置各种协议参数(如客户端ID,范围,重定向URI等)的长度限制
  63. //idroptions.InputLengthRestrictions = new IdentityServer4.Configuration.InputLengthRestrictions
  64. //{
  65. // //可以看出下面很多参数都是对长度的限制
  66. // AcrValues = 100,
  67. // AuthorizationCode = 100,
  68. // ClientId = 100,
  69. // /*
  70. // ..
  71. // ..
  72. // ..
  73. // */
  74. // ClientSecret = 1000
  75. //};
  76. //用户交互页面定向设置处理
  77. idroptions.UserInteraction = new IdentityServer4.Configuration.UserInteractionOptions
  78. {
  79.  
  80. LoginUrl = customUrl + "/Account/Login",//【必备】登录地址
  81. LogoutUrl = customUrl + "/Account/Logout",//【必备】退出地址
  82. ConsentUrl = customUrl + "/Consent/Index",//【必备】允许授权同意页面地址
  83. ErrorUrl = customUrl + "/Error/Index", //【必备】错误页面地址
  84. LoginReturnUrlParameter = "returnUrl",//【必备】设置传递给登录页面的返回URL参数的名称。默认为returnUrl
  85. LogoutIdParameter = "logoutId", //【必备】设置传递给注销页面的注销消息ID参数的名称。缺省为logoutId
  86. ConsentReturnUrlParameter = "returnUrl", //【必备】设置传递给同意页面的返回URL参数的名称。默认为returnUrl
  87. ErrorIdParameter = "errorId", //【必备】设置传递给错误页面的错误消息ID参数的名称。缺省为errorId
  88. CustomRedirectReturnUrlParameter = "returnUrl", //【必备】设置从授权端点传递给自定义重定向的返回URL参数的名称。默认为returnUrl
  89. CookieMessageThreshold = //【必备】由于浏览器对Cookie的大小有限制,设置Cookies数量的限制,有效的保证了浏览器打开多个选项卡,一旦超出了Cookies限制就会清除以前的Cookies值
  90. };
  91. //缓存参数处理 缓存起来提高了效率 不用每次从数据库查询
  92. idroptions.Caching = new IdentityServer4.Configuration.CachingOptions
  93. {
  94. ClientStoreExpiration = new TimeSpan(, , ),//设置Client客户端存储加载的客户端配置的数据缓存的有效时间
  95. ResourceStoreExpiration = new TimeSpan(, , ),// 设置从资源存储加载的身份和API资源配置的缓存持续时间
  96. CorsExpiration = new TimeSpan(, , ) //设置从资源存储的跨域请求数据的缓存时间
  97. };
  98. //IdentityServer支持一些端点的CORS。底层CORS实现是从ASP.NET Core提供的,因此它会自动注册在依赖注入系统中
  99. idroptions.Cors = new IdentityServer4.Configuration.CorsOptions
  100. {
  101. CorsPaths = new List<PathString>() {
  102. new PathString("/")
  103. }, //支持CORS的IdentityServer中的端点。默认为发现,用户信息,令牌和撤销终结点
  104.  
  105. CorsPolicyName = "default", //【必备】将CORS请求评估为IdentityServer的CORS策略的名称(默认为"IdentityServer4")。处理这个问题的策略提供者是ICorsPolicyService在依赖注入系统中注册的。如果您想定制允许连接的一组CORS原点,则建议您提供一个自定义的实现ICorsPolicyService
  106. PreflightCacheDuration = new TimeSpan(, , )//可为空的<TimeSpan>,指示要在预检Access-Control-Max-Age响应标题中使用的值。默认为空,表示在响应中没有设置缓存头
  107. };
  108.  
  109. })
  110. #endregion
  111.  
  112. #region 添加IdentityServer4 认证证书相关处理 By Liyouming 2017-11-29
  113. //AddSigningCredential 添加登录证书 这个是挂到IdentityServer4中间件上 提供多种证书处理 RsaSecurityKey\SigningCredentials
  114. //这里可以采用IdentiServe4的证书封装出来
  115. //添加一个签名密钥服务,该服务将指定的密钥材料提供给各种令牌创建/验证服务。您可以从证书存储中传入X509Certificate2一个SigningCredential或一个证书引用
  116. //.AddSigningCredential(new System.Security.Cryptography.X509Certificates.X509Certificate2()
  117. //{
  118. // Archived = true,
  119. // FriendlyName = "",
  120. // PrivateKey = System.Security.Cryptography.AsymmetricAlgorithm.Create("key")
  121. //})
  122. //AddDeveloperSigningCredential在启动时创建临时密钥材料。这是仅用于开发场景,当您没有证书使用。
  123. //生成的密钥将被保存到文件系统,以便在服务器重新启动之间保持稳定(可以通过传递来禁用false)。
  124. //这解决了在开发期间client / api元数据缓存不同步的问题
  125. .AddDeveloperSigningCredential()
  126. //添加验证令牌的密钥。它们将被内部令牌验证器使用,并将显示在发现文档中。
  127. //您可以从证书存储中传入X509Certificate2一个SigningCredential或一个证书引用。这对于关键的转换场景很有用
  128. //.AddValidationKeys(new AsymmetricSecurityKey[] {
  129.  
  130. //})
  131. #endregion
  132.  
  133. #region 添加IdentityServer4用户缓存数据 By Liyouming 2017-11-29
  134. //添加配置数据全部配置到内存中 如果有EFCore数据库持久化这里不会配置 只需要配置 AddConfigurationStore、AddOperationalStore 数据仓储服务
  135. //寄存器IClientStore和ICorsPolicyService实现基于内存中的Client配置对象集合。
  136. //.AddInMemoryClients(IdrConfig.IdrConfigurations.GetClient())
  137. //IResourceStore基于IdentityResource配置对象的内存中收集来注册实现。
  138. //.AddInMemoryIdentityResources(IdrConfig.IdrConfigurations.GetIdentityResources())
  139. //IResourceStore基于ApiResource配置对象的内存中收集来注册实现。
  140. //.AddInMemoryApiResources(IdrConfig.IdrConfigurations.GetApiResources())
  141. //添加测试用户
  142. //.AddTestUsers(new List<IdentityServer4.Test.TestUser>() {
  143.  
  144. // new IdentityServer4.Test.TestUser{
  145. // SubjectId=Guid.NewGuid().ToString(),
  146. // Username="liyouming",
  147. // Password="liyouming"
  148.  
  149. // }
  150. //})
  151. #endregion
  152.  
  153. #region 添加对IdentityServer4 EF数据库持久化支持 By Liyouming 2017-11-29
  154. //黎又铭 Add 2017-11-28 添加IdentityServer4对EFCore数据库的支持
  155. .AddConfigurationStore(options =>
  156. {
  157. options.ConfigureDbContext = builder =>
  158. {
  159. builder.UseSqlServer(connectionString,
  160. builderoptions =>
  161. {
  162. builderoptions.MigrationsAssembly(migrationsAssembly);
  163. });
  164. };
  165. })
  166. .AddOperationalStore(options =>
  167. {
  168. options.ConfigureDbContext = builder =>
  169. {
  170. builder.UseSqlServer(connectionString, builderoptions =>
  171. {
  172. builderoptions.MigrationsAssembly(migrationsAssembly);
  173. });
  174.  
  175. };
  176.  
  177. options.EnableTokenCleanup = true; //允许对Token的清理
  178. options.TokenCleanupInterval = ; //清理周期时间Secends
  179. })
  180. #endregion
  181.  
  182. ;
  183. #endregion
  184.  
  185. //services.AddScoped<IUserService, UserService>();
  186.  
  187. #region 添加授权验证方式 这里是Cookies & OpenId Connect
  188. JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
  189. services.AddAuthentication(
  190. options =>
  191. {
  192. options.DefaultScheme = "lym.oauth.cookies";
  193. options.DefaultChallengeScheme = "oidc";
  194. }
  195. )
  196. .AddCookie("lym.oauth.cookies", options=> {
  197.  
  198. options.ExpireTimeSpan = TimeSpan.FromMinutes();
  199. options.Cookie.Name = "lym.idrserver";
  200.  
  201. }) //监控浏览器Cookies不难发现有这样一个 .AspNetCore.lym.Cookies 记录了加密的授权信息
  202. .AddOpenIdConnect("oidc", options =>
  203. {
  204. options.Authority = customUrl;
  205. options.ClientId = "lym.clienttest";
  206. options.ClientSecret = "lym.clienttest";
  207. options.RequireHttpsMetadata = false;
  208. options.SaveTokens = true;
  209. options.ResponseType = "code id_token";
  210. //布尔值来设置处理程序是否应该转到用户信息端点检索。额外索赔或不在id_token创建一个身份收到令牌端点。默认为“false”
  211. options.GetClaimsFromUserInfoEndpoint = true;
  212. options.CallbackPath = new PathString("/oidc/login-callback");
  213. options.SignInScheme = "lym.oauth.cookies";
  214. options.SignOutScheme = "lym.oauth.cookies";
  215. options.RemoteSignOutPath = new PathString("/oidc/front-channel-logout-callback");
  216. options.Scope.Add("openid");
  217. options.Scope.Add("profile");
  218. options.Scope.Add("cloudservices");
  219. options.Events = new OpenIdConnectEvents
  220. {
  221. OnRedirectToIdentityProvider = OnRedirectToIdentityProvider,
  222. OnRemoteSignOut = OnRemoteSignOut,
  223. OnRemoteFailure = OnRemoteFailure,
  224. OnAuthenticationFailed = OnAuthenticationFailed,
  225. OnRedirectToIdentityProviderForSignOut = OnRedirectToIdentityProviderForSignOut,
  226. OnAuthorizationCodeReceived = OnAuthorizationCodeReceived,
  227. OnMessageReceived = OnMessageReceived,
  228. OnTicketReceived = OnTicketReceived,
  229. OnTokenResponseReceived = OnTokenResponseReceived,
  230. OnTokenValidated = OnTokenValidated,
  231. OnUserInformationReceived = OnUserInformationReceived
  232. };
  233. });
  234. #endregion
  235.  
  236. }
  237. #region Events事件
  238. private static Task OnRedirectToIdentityProvider(RedirectContext context)
  239. {
  240. if (context.HttpContext.Items.ContainsKey("idp"))
  241. {
  242. var idp = context.HttpContext.Items["idp"];
  243. context.ProtocolMessage.AcrValues = "idp:" + idp;
  244. }
  245.  
  246. return Task.FromResult();
  247. }
  248.  
  249. private static Task OnRemoteSignOut(RemoteSignOutContext context)
  250. {
  251. return Task.FromResult();
  252. }
  253.  
  254. private static Task OnRemoteFailure(RemoteFailureContext context)
  255. {
  256. return Task.FromResult();
  257. }
  258.  
  259. private static Task OnAuthenticationFailed(AuthenticationFailedContext context)
  260. {
  261. return Task.FromResult();
  262. }
  263.  
  264. private static Task OnRedirectToIdentityProviderForSignOut(RedirectContext context)
  265. {
  266. context.ProtocolMessage.PostLogoutRedirectUri = context.Request.Scheme + "://" + context.Request.Host;
  267. return Task.FromResult();
  268. }
  269. private static Task OnAuthorizationCodeReceived(AuthorizationCodeReceivedContext context)
  270. {
  271. return Task.FromResult();
  272. }
  273. private static Task OnMessageReceived(MessageReceivedContext context)
  274. {
  275. return Task.FromResult();
  276. }
  277.  
  278. private static Task OnTicketReceived(TicketReceivedContext context)
  279. {
  280. return Task.FromResult();
  281. }
  282.  
  283. private static Task OnTokenResponseReceived(TokenResponseReceivedContext context)
  284. {
  285. return Task.FromResult();
  286. }
  287.  
  288. private static Task OnTokenValidated(TokenValidatedContext context)
  289. {
  290. return Task.FromResult();
  291. }
  292.  
  293. private static Task OnUserInformationReceived(UserInformationReceivedContext context)
  294. {
  295. return Task.FromResult();
  296. }
  297. #endregion
  298.  
  299. public void ConfigureContainer(ContainerBuilder builder)
  300. {
  301. //Autofac 注入
  302. builder.RegisterInstance(this.Configuration).AsImplementedInterfaces();
  303.  
  304. //builder.RegisterType<RedisProvider>().As<IRedisProvider>().SingleInstance();
  305.  
  306. builder.AddUnitOfWork(provider =>
  307. {
  308. provider.Register(new LYM.Data.EntityFramework.ClubUnitOfWorkRegisteration());
  309. });
  310.  
  311. builder.RegisterModule<CoreModule>()
  312. .RegisterModule<EntityFrameworkModule>();
  313. }
  314. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  315. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  316. {
  317. if (env.IsDevelopment())
  318. {
  319. app.UseDeveloperExceptionPage();
  320. app.UseBrowserLink();
  321. }
  322. else
  323. {
  324. app.UseExceptionHandler("/Home/Error");
  325. }
  326. app.UseAuthentication();
  327. app.UseStaticFiles();
  328.  
  329. app.UseIdentityServer();
  330.  
  331. app.UseMvc(routes =>
  332. {
  333. routes.MapRoute(
  334. name: "default",
  335. template: "{controller=Home}/{action=Index}/{id?}");
  336. });
  337.  
  338. // app.UseMvcWithDefaultRoute();
  339.  
  340. }
  341. }

auth.liyouming.com

web.liyouming.com 全部配置

  1. public class Startup
  2. {
  3. public Startup(IConfiguration configuration)
  4. {
  5.  
  6. Configuration = configuration;
  7. }
  8.  
  9. public IConfiguration Configuration { get; }
  10.  
  11. public void ConfigureServices(IServiceCollection services)
  12. {
  13.  
  14. #region 数据库连接
  15. string customUrl = this.Configuration["Authority"];
  16. services.AddMvc();
  17. services.AddOptions();
  18. services.AddDbContext<CustomContext>(builder =>
  19. {
  20. builder.UseSqlServer(this.Configuration["ConnectionString"], options =>
  21. {
  22. options.UseRowNumberForPaging();
  23. options.MigrationsAssembly("LYM.WebSite");
  24. });
  25. }, ServiceLifetime.Transient);
  26. #endregion
  27.  
  28. #region 添加授权验证方式 这里是Cookies & OpenId Connect
  29. JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
  30. services.AddAuthentication(
  31. options =>
  32. {
  33. options.DefaultScheme = "lym.oauth.cookies";// CookieAuthenticationDefaults.AuthenticationScheme;
  34. options.DefaultChallengeScheme = "oidc";
  35. }
  36. )
  37. .AddCookie("lym.oauth.cookies", options =>
  38. {
  39.  
  40. options.ExpireTimeSpan = TimeSpan.FromMinutes();
  41. options.Cookie.Name = "lym.website";
  42.  
  43. }) //监控浏览器Cookies不难发现有这样一个 .AspNetCore.lym.Cookies 记录了加密的授权信息
  44. .AddOpenIdConnect("oidc", options =>
  45. {
  46. options.Authority = customUrl;
  47. options.ClientId = "lym.clienttest1";
  48. options.ClientSecret = "lym.clienttest";
  49. options.RequireHttpsMetadata = false;
  50. options.SaveTokens = true;
  51. options.ResponseType = "code id_token";
  52. //布尔值来设置处理程序是否应该转到用户信息端点检索。额外索赔或不在id_token创建一个身份收到令牌端点。默认为“false”
  53. options.GetClaimsFromUserInfoEndpoint = true;
  54. options.CallbackPath = new PathString("/oidc/login-callback");
  55. options.SignInScheme = "lym.oauth.cookies";
  56. options.SignOutScheme = "lym.oauth.cookies";
  57. options.RemoteSignOutPath = new PathString("/oidc/front-channel-logout-callback");
  58. options.Scope.Add("openid");
  59. options.Scope.Add("profile");
  60. options.Scope.Add("cloudservices");
  61. options.Events = new OpenIdConnectEvents
  62. {
  63. OnRedirectToIdentityProvider = OnRedirectToIdentityProvider,
  64. OnRemoteSignOut = OnRemoteSignOut,
  65. OnRemoteFailure = OnRemoteFailure,
  66. OnAuthenticationFailed = OnAuthenticationFailed,
  67. OnRedirectToIdentityProviderForSignOut = OnRedirectToIdentityProviderForSignOut,
  68. OnAuthorizationCodeReceived = OnAuthorizationCodeReceived,
  69. OnMessageReceived = OnMessageReceived,
  70. OnTicketReceived = OnTicketReceived,
  71. OnTokenResponseReceived = OnTokenResponseReceived,
  72. OnTokenValidated = OnTokenValidated,
  73. OnUserInformationReceived = OnUserInformationReceived
  74. };
  75.  
  76. });
  77. #endregion
  78.  
  79. #region Cap配置
  80.  
  81. //services.AddDbContext<CapApiContext>(builder =>
  82. //{
  83. // builder.UseSqlServer(this.Configuration["CapConnectionString"]);
  84. //}, ServiceLifetime.Transient);
  85.  
  86. //services.AddCap(x =>
  87. //{
  88. // //EF实体框架
  89. // x.UseEntityFramework<CapApiContext>();
  90.  
  91. // // Dapper
  92. // // x.UseSqlServer("Your ConnectionStrings");
  93.  
  94. // // RabbitMQ 消息
  95.  
  96. // //x.UseRabbitMQ(rabbitMQOption =>
  97. // //{
  98.  
  99. // // #region UseRabbitMQ 参数说明
  100. // // //HostName 宿主地址 string localhost
  101. // // //UserName 用户名 string guest
  102. // // //Password 密码 string guest
  103. // // //VirtualHost 虚拟主机 string /
  104. // // //Port 端口号 int -1
  105. // // //TopicExchangeName CAP默认Exchange名称 string cap.default.topic
  106. // // //RequestedConnectionTimeout RabbitMQ连接超时时间 int 30,000 毫秒
  107. // // //SocketReadTimeout RabbitMQ消息读取超时时间 int 30,000 毫秒
  108. // // //SocketWriteTimeout RabbitMQ消息写入超时时间 int 30,000 毫秒
  109. // // //QueueMessageExpires 队列中消息自动删除时间 int(10天) 毫秒
  110. // // #endregion
  111. // // rabbitMQOption.HostName = "192.168.0.42";
  112. // // //rabbitMQOption.VirtualHost = "/rabbit";
  113. // // //rabbitMQOption.UserName = "lym123";
  114. // // //rabbitMQOption.Password = "lym123";
  115. // // rabbitMQOption.Port = 5672;
  116. // // // rabbitmq options.
  117. // //});
  118.  
  119. // x.UseRabbitMQ("localhost");
  120.  
  121. // // Kafka 消息
  122. // // x.UseKafka("localhost:5003");
  123.  
  124. // // 执行失败消息时的回调函数,详情见下文 Action<MessageType,string,string>
  125. // //x.FailedCallback = null;
  126. // //处理消息的线程默认轮询等待时间(秒) 15 秒
  127. // x.PollingDelay = 15;
  128. // //启动队列中消息的处理器个数 2
  129. // x.QueueProcessorCount = 2;
  130. // //失败重试次数
  131. // x.FailedRetryCount = 3;
  132. // //失败重试时间间隔
  133. // x.FailedRetryInterval = 15;
  134.  
  135. //});
  136.  
  137. #endregion
  138.  
  139. }
  140. #region Events事件
  141. private static Task OnRedirectToIdentityProvider(RedirectContext context)
  142. {
  143. if (context.HttpContext.Items.ContainsKey("idp"))
  144. {
  145. var idp = context.HttpContext.Items["idp"];
  146. context.ProtocolMessage.AcrValues = "idp:" + idp;
  147. }
  148.  
  149. return Task.FromResult();
  150. }
  151.  
  152. private static Task OnRemoteSignOut(RemoteSignOutContext context)
  153. {
  154. return Task.FromResult();
  155. }
  156.  
  157. private static Task OnRemoteFailure(RemoteFailureContext context)
  158. {
  159. return Task.FromResult();
  160. }
  161.  
  162. private static Task OnAuthenticationFailed(AuthenticationFailedContext context)
  163. {
  164. return Task.FromResult();
  165. }
  166.  
  167. private static Task OnRedirectToIdentityProviderForSignOut(RedirectContext context)
  168. {
  169. context.ProtocolMessage.PostLogoutRedirectUri = context.Request.Scheme + "://" + context.Request.Host;
  170. return Task.FromResult();
  171. }
  172. private static Task OnAuthorizationCodeReceived(AuthorizationCodeReceivedContext context)
  173. {
  174. return Task.FromResult();
  175. }
  176. private static Task OnMessageReceived(MessageReceivedContext context)
  177. {
  178. return Task.FromResult();
  179. }
  180.  
  181. private static Task OnTicketReceived(TicketReceivedContext context)
  182. {
  183. return Task.FromResult();
  184. }
  185.  
  186. private static Task OnTokenResponseReceived(TokenResponseReceivedContext context)
  187. {
  188. return Task.FromResult();
  189. }
  190.  
  191. private static Task OnTokenValidated(TokenValidatedContext context)
  192. {
  193. return Task.FromResult();
  194. }
  195.  
  196. private static Task OnUserInformationReceived(UserInformationReceivedContext context)
  197. {
  198. return Task.FromResult();
  199. }
  200. #endregion
  201. public void ConfigureContainer(ContainerBuilder builder)
  202. {
  203. //Autofac 注入
  204. builder.RegisterInstance(this.Configuration).AsImplementedInterfaces();
  205.  
  206. //builder.RegisterType<RedisProvider>().As<IRedisProvider>().SingleInstance();
  207.  
  208. builder.AddUnitOfWork(provider =>
  209. {
  210. provider.Register(new LYM.Data.EntityFramework.ClubUnitOfWorkRegisteration());
  211. });
  212.  
  213. builder.RegisterModule<CoreModule>()
  214. .RegisterModule<EntityFrameworkModule>();
  215. }
  216.  
  217. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  218. {
  219. if (env.IsDevelopment())
  220. {
  221. app.UseDeveloperExceptionPage();
  222. app.UseBrowserLink();
  223. }
  224. else
  225. {
  226. app.UseExceptionHandler("/Home/Error");
  227. }
  228.  
  229. app.UseStaticFiles();
  230. app.UseAuthentication();
  231. app.UseMvc(routes =>
  232. {
  233. routes.MapRoute(
  234. name: "default",
  235. template: "{controller=Home}/{action=Index}/{id?}");
  236. });
  237.  
  238. // app.UseCap(); //Cap配置
  239. }
  240. }

web.liyouming.com

centos7.0 环境

SSO登录,SSO退出 搞定

下面是登录视频演示:

项目目录结构

一步一步学习IdentityServer4 (7) IdentityServer4成功配置全部配置的更多相关文章

  1. 一步一步学习IdentityServer4 (1) 概要配置说明

    //结合EFCore生成IdentityServer4数据库 // 项目工程文件最后添加 <ItemGroup><DotNetCliToolReference Include=&qu ...

  2. 12.Linux软件安装 (一步一步学习大数据系列之 Linux)

    1.如何上传安装包到服务器 有三种方式: 1.1使用图形化工具,如: filezilla 如何使用FileZilla上传和下载文件 1.2使用 sftp 工具: 在 windows下使用CRT 软件 ...

  3. (转) 一步一步学习ASP.NET 5 (四)- ASP.NET MVC 6四大特性

    转发:微软MVP 卢建晖 的文章,希望对大家有帮助.原文:http://blog.csdn.net/kinfey/article/details/44459625 编者语 : 昨晚写好的文章居然csd ...

  4. (转) 一步一步学习ASP.NET 5 (二)- 通过命令行和sublime创建项目

    转发:微软MVP 卢建晖 的文章,希望对大家有帮助. 注:昨天转发之后很多朋友指出了vNext的命名问题,原文作者已经做出了修改,后面的标题都适用 asp.net 5这个名称. 编者语 : 昨天发了第 ...

  5. 一步一步学习SignalR进行实时通信_1_简单介绍

    一步一步学习SignalR进行实时通信\_1_简单介绍 SignalR 一步一步学习SignalR进行实时通信_1_简单介绍 前言 SignalR介绍 支持的平台 相关说明 OWIN 结束语 参考文献 ...

  6. 一步一步学习SignalR进行实时通信_8_案例2

    原文:一步一步学习SignalR进行实时通信_8_案例2 一步一步学习SignalR进行实时通信\_8_案例2 SignalR 一步一步学习SignalR进行实时通信_8_案例2 前言 配置Hub 建 ...

  7. 一步一步学习SignalR进行实时通信_9_托管在非Web应用程序

    原文:一步一步学习SignalR进行实时通信_9_托管在非Web应用程序 一步一步学习SignalR进行实时通信\_9_托管在非Web应用程序 一步一步学习SignalR进行实时通信_9_托管在非We ...

  8. 一步一步学习SignalR进行实时通信_7_非代理

    原文:一步一步学习SignalR进行实时通信_7_非代理 一步一步学习SignalR进行实时通信\_7_非代理 SignalR 一步一步学习SignalR进行实时通信_7_非代理 前言 代理与非代理 ...

  9. 一步一步学习SignalR进行实时通信_5_Hub

    原文:一步一步学习SignalR进行实时通信_5_Hub 一步一步学习SignalR进行实时通信\_5_Hub SignalR 一步一步学习SignalR进行实时通信_5_Hub 前言 Hub命名规则 ...

  10. 一步一步学习SignalR进行实时通信_6_案例

    原文:一步一步学习SignalR进行实时通信_6_案例 一步一步学习SignalR进行实时通信\_6_案例1 一步一步学习SignalR进行实时通信_6_案例1 前言 类的定义 各块功能 后台 上线 ...

随机推荐

  1. 浅谈 vue实例 和 vue组件

    vue实例: import Vue from 'vue'; import app from './app'; import myRouter from './routers'; new Vue({ e ...

  2. 科学计算三维可视化---TraitsUI(配置视图)

    配置视图 模态窗口: from traits.api import HasTraits,Int,Strclass ModelManager(HasTraits): model_name = Str c ...

  3. 【转】MYSQL数据库设计规范与原则

    转载出:http://www.cnblogs.com/lovekingly/p/5044278.htmlMYSQL数据库设计规范 1.数据库命名规范 采用26个英文字母(区分大小写)和0-9的自然数( ...

  4. awk例子

     ls |awk -F . '{print $1}'|awk -F '-[0-9]' '{print $1}' 

  5. 分享自己新做的vim colorscheme

    把下面的内容保存成darkslategrey.vim,放入~/.vim/colors目录即可. " Vim color file " Maintainer: jiqing() &q ...

  6. 在springMVC中使用自定义注解来进行登录拦截控制

    1:java注解使用是相当频繁,特别是在搭建一些框架时,用到类的反射获取方法和属性,用的尤其多. java中元注解有四个: @Retention     @Target     @Document  ...

  7. sort函数(cmp)、map用法---------------Tju_Oj_2312Help Me with the Game

    这道题里主要学习了sort函数.sort的cmp函数写法.C++的map用法(其实和数组一样) Your task is to read a picture of a chessboard posit ...

  8. Ubuntu 增加全新硬盘 分区及开机自动挂载

    安装新的硬盘后.可以安装Gparted, 或者从live cd启动,然后用Gparted工具对硬盘进行分区.然后进入系统,启动Disks, 找到对应硬盘, 选择Edit Mount Options, ...

  9. host映射方法

    host映射: host是根据TCP/IP for Windows 的标准来工作的,它的作用是包含IP地址和Host name(主机名)的映射关系,是一个映射IP地址和Host name(主机名)的规 ...

  10. MySQL 5.6 GTID Replication【转】

    一. MySQL 5.6引入了GTID的概念,那么GTID是何方神圣?其实也不复杂,就是一个全局事务标示符.使用GTID时,每次事务提交都会在binlog里生成1个唯一的标示符,它由UUID和事务ID ...