Customizing form_post response view in IdentityServer4

Viewed 108

I'm using IdentityServer4 and I'd like to add some kind of simple visual loading indicator when a user is being authorized/redirected using "form_post" response mode.

When the connect/authorize route is called with a "form_post" response mode, it returns a blank page with a form that submits, so I'm trying to figure out how to add some custom html to this page.

I found this issue for IdentityServer3 that covers my exact use case but I'm not finding how to implement this in IdentityServer4 as it doesn't use the ViewService structure that 3 uses.

I started down the path of a custom authorize interaction response generator but If I redirect to a custom view from here but I'm not sure what that custom view needs to look like to handle the form posting part of the process.

public class CustomAuthorizeInteractionResponseGenerator : AuthorizeInteractionResponseGenerator
{
    //...

    public override async Task<InteractionResponse> ProcessInteractionAsync(ValidatedAuthorizeRequest request, ConsentResponse consent = null)
    {
        var interactionResponse = await base.ProcessInteractionAsync(request, consent);

        if (interactionResponse.IsLogin ||
            interactionResponse.IsError ||
            interactionResponse.IsConsent)
        {
            return interactionResponse;
        }

        if (request.ResponseMode == "form_post")
        {
            return new InteractionResponse
            {
                RedirectUrl = "/custom_form_post"
            };
        }

        return interactionResponse;
    }
}
1 Answers

That page is hardcoded in IdentityServer and the code for it is located in the AuthorizeResult.cs class.

So I guesss customizing it will be hard unless you recompile IdentityServer yourself.

Another option could perhaps be to customize the consent-screen and display something to the user, before that page is returned.

Related