Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom flow - delegation

Tags:

openiddict

I was wondering if it is possible to implement with openiddict a delegation grant type similar to the one implemented here with Identity Server.

var result = await _validator.ValidateAccessTokenAsync(userToken);
if (result.IsError)
{
    context.Result = new GrantValidationResult(TokenRequestErrors.InvalidGrant);
    return;
}

Is there any equivalent method to ValidateAccessTokenAsync in openiddict in order to validate the token and access some of its properties?

like image 488
Pedro Faustino Avatar asked Nov 16 '25 19:11

Pedro Faustino


1 Answers

Implementation of standard token exchange is tracked by https://github.com/openiddict/openiddict-core/issues/1249.

In the meantime, you can override the default ValidateTokenParameter handler to work with your custom grant and extract the access token from the customer parameter you use:

https://github.com/openiddict/openiddict-core/blob/422d8979adb8cdebc6c8c8e14faa1d736208271e/src/OpenIddict.Server/OpenIddictServerHandlers.cs#L168

Then, you can call the IOpenIddictServerDispatcher.DispatchAsync() method with an instance of ProcessAuthenticationContext to trigger an authentication event. If IsRejected is true, this means the token is not valid. Otherwise, you'll be able to access its claims principal.

like image 197
Kévin Chalet Avatar answered Nov 18 '25 07:11

Kévin Chalet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!