0

我正在开发一个项目,该项目需要支持授权客户端到两个 Okta 服务器之一(这是一个临时问题,但仍然必须解决),具体取决于路由。这可能吗 ?如果是这样怎么办?

目前,我有这个授权给 okta 服务器的代码

 public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            .AddOktaWebApi(new OktaWebApiOptions()
            {
                OktaDomain = Configuration["Okta:OktaDomain"],
                AuthorizationServerId = Configuration["Okta:AuthorizationServerId"],
                Audience = Configuration["Okta:Audience"]
            })
            
            services.AddAuthorization(options =>
            {
                options.AddPolicy("TestPolicy", new AuthorizationPolicyBuilder()
                    .RequireAuthenticatedUser()
                    .AddAuthenticationSchemes(OktaDefaults.ApiAuthenticationScheme)
                    .RequireClaim("testId")
                    .Build());
            });
            return IoC.ConfigureIoC(services);
        }

控制器是这样装饰的

[Authorize(Policy = "TestPolicy", AuthenticationSchemes = Okta.AspNetCore.OktaDefaults.ApiAuthenticationScheme)]
4

0 回答 0