DEV Community

Cover image for Impersonation in a .Net core application with Identity Server 4
Venkatesan Rethinam
Venkatesan Rethinam

Posted on

Impersonation in a .Net core application with Identity Server 4

Identity Server 4 does not provide native impersonation support which I needed for one of my projects. I have implemented one on top of it.

Here is the sample project I did in GitHub.

https://github.com/venbacodes/ImpersonationSample-IdentityServer4

This is a sample application to show a way to implement impersonation when using Identity Server.

Key Points

  1. Authorization policy has been setup to restrict impersonation to users with specific role.
  2. Admin users' email is added as a claim while impersonating so that it can be used while ending the impersonation.
  3. Logic is simple as authenticating with the victim users' email for impersonation with additional claims to track the impersonation and the impersonating user.

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay