November Happy Hour will be moved to Thursday December 5th.

Adding OpenIddict eventhandlers

Vote:
 

When using AddOpenIDConnect() we have no access to the underlying calls that adds the OpenIddict server, for adding e.g. eventhandlers.

https://kevinchalet.com/2018/07/02/implementing-advanced-scenarios-using-the-new-openiddict-rc3-events-model/

Has anyone found away around this? I'm thinkning that the Episerver.OpenIdConnect package should expose the OpenIddict internals in some way to allow us to do this sort of customization. An alternative of course is to implement OpenIddict without the Episerver package but it feels overkill.

#277749
Apr 04, 2022 15:08
Vote:
 

All the option classes are still available, have you tried:

services.Configure<OpenIddictServerOptions>(options =>
{
    options.Handlers.Add(new OpenIddictServerHandlerDescriptor
    {
        ...
    });
});

There is probably an extension method available to make this code nicer, so you don't have to construct the descriptor. It also look like you have to add the descriptor to the container:

var descriptor = new OpenIddictServerHandlerDescriptor
{
   ...
};

services.Add(descriptor.ServiceDescriptor);

services.Configure<OpenIddictServerOptions>(options =>
{
    options.Handlers.Add(descriptor);
});

I've added to our backlog that we should look into exposing OpenIddictBuilder, which makes the code a bit cleaner when you want to extend our code.

#277820
Edited, Apr 05, 2022 16:06
Vote:
 

Thanks, works like a charm!

+1 if it could be exposed as part of the Episerver package.

#277864
Apr 06, 2022 9:49
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.