IdentityServer / IdentityServer4

OpenID Connect and OAuth 2.0 Framework for ASP.NET Core
https://identityserver.io
Apache License 2.0
9.23k stars 4.02k forks source link

I am trying to override, ValidateAllowedCorsOriginsAsync, to handle iOS origin, but not sure how to hook the derived class to IdentityServer4 to use it. Is there an example or can you provide a link for instruction #5438

Closed hubaozhang2017 closed 2 years ago

hubaozhang2017 commented 2 years ago
leastprivilege commented 2 years ago

Important update

This organization is not maintained anymore besides critical security bugfixes (if feasible). This organization will be archived when .NET Core 3.1 end of support is reached (3rd Dec 2022). All new development is happening in the new Duende Software organization.

The new Duende IdentityServer comes with a commercial license but is free for dev/testing/personal projects and companies or individuals making less than 1M USD gross annnual revenue. Please get in touch with us if you have any question.

hubaozhang2017 commented 2 years ago

I figured out the problem. Here are steps: (1) Create a class, CustomClientConfigurationValidator, and override ValidateAllowedCorsOriginsAsync `

      public class CustomClientConfigurationValidator : DefaultClientConfigurationValidator

{

    readonly IConfiguration _configuration;

    public CustomClientConfigurationValidator(IConfiguration configuration)
        :base()

    {

        _configuration = configuration;

    }

    protected override Task ValidateAllowedCorsOriginsAsync(ClientConfigurationValidationContext context)

    {}

  }`

(2) Add AddClientConfigurationValidator to services `
var identityServerBuilder = services.AddIdentityServer()

            .AddSigningCredential(new X509Certificate2(certPath, "", X509KeyStorageFlags.MachineKeySet))

            .AddClientConfigurationValidator<CustomClientConfigurationValidator>()

         ;`
github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.