Probably will not try to create an impersonation feature in the IdentityServer4 core libraries. You just need a small data structure to store your issued UserId and a service to verify this. This is the main function that you should develop.
Also think that you might need superuser functions that are still present, even if you impersonate yourself (e.g. un-impersonate).
source share