IdentityServer/IdentityServer4

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

hubaozhang2017 opened this issue · 3 comments

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

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.

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>()
			
         ;`

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.