b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

scopes .NET Core微服务之基于IdentityServer建(4)

电脑杂谈  发布时间:2019-03-20 20:07:59  来源:网络整理

这里我们使用的是implicit这个flow(详细内容可以阅读ddrsql的IdentityServer4之Implicit(隐式许可)),它主要用于客户端应用程序(主要指基于javascript的应用),它允许客户端程序重定向到AuthorizationServer,然后带着token重定向回来。scopesscopes值得一提的是这里的ResponseType为"id_token token",表示既获取id_token也获取access_token。而SaveTokens设为true则表示要将从AuthorizationServer返回的token持久化在cookie之中,这样就不用每次都去请求token了。

当然,也还得在Configure方法中,配置Authentication中间件:

    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseBrowserLink();
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }

        app.UseAuthentication();

        app.UseStaticFiles();

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");
        });
    }

*.位置仍然需要在UseMvc之前。

在InMemoryConfiguration类中修改GetClients方法:

    public static IEnumerable<Client> GetClients()
    {
        return new[]
        {
            new Client
            {
                ClientId = "client.api.service",
                ClientSecrets = new [] { new Secret("clientsecret".Sha256()) },
                AllowedGrantTypes = GrantTypes.ResourceOwnerPasswordAndClientCredentials,
                AllowedScopes = new [] { "clientservice" }
            },
            ......,
            new Client
            {
                ClientId = "cas.mvc.client.implicit",
                ClientName = "CAS MVC Web App Client",
                AllowedGrantTypes = GrantTypes.Implicit,
                RedirectUris = { $"http://{Configuration["Clients:MvcClient:IP"]}:{Configuration["Clients:MvcClient:Port"]}/signin-oidc" },
                PostLogoutRedirectUris = { $"http://{Configuration["Clients:MvcClient:IP"]}:{Configuration["Clients:MvcClient:Port"]}/signout-callback-oidc" },
                AllowedScopes = new [] {
                    IdentityServerConstants.StandardScopes.OpenId,
                    IdentityServerConstants.StandardScopes.Profile,
                    "agentservice", "clientservice", "productservice"
                },
                AllowAccessTokensViaBrowser = true // can return access_token to this client
            }
        };
    }


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-92987-4.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    每日福利
    热点图片
    拼命载入中...