Esempio n. 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddRazorPages();

            #region SSO 单点登陆方式
            services.AddIdentityServer()
            .AddDeveloperSigningCredential()                                    //添加证书
            .AddInMemoryIdentityResources(SSOMemberData.GetIdentityResources()) //身份认证资源加载到内存
            .AddClientStore <SSOClientStore>();                                 //客户端定义加载到内存中
            #endregion
        }
        public async Task <Client> FindClientByIdAsync(string clientId)
        {
            #region 用户名密码
            var memoryClients = SSOMemberData.GetClients();
            if (memoryClients.Any(oo => oo.ClientId == clientId))
            {
                return(memoryClients.FirstOrDefault(oo => oo.ClientId == clientId));
            }
            #endregion

            #region 通过数据库查询Client 信息
            return(GetClient(clientId));

            #endregion
        }