Adding Identity Roles To Identity Server 4 in .NET Core 3.1

Prerequisites

So where do we start?

Image for post
Image for post
Fig. 1: install identity server 4 templates
Image for post
Image for post
Fig. 2: create a project using IS4 template for ASP.NET Identity
Image for post
Image for post
Fig. 3: add client to list of authorization server clients
Image for post
Image for post
Fig.4: add roles to seed data
Image for post
Image for post
Fig. 5: add alice to member role
Image for post
Image for post
Fig. 6: add bob to admin role
Image for post
Image for post
Fig. 7: implement add role to claim
Image for post
Image for post
Fig. 8: full source for profile service
Image for post
Image for post
Fig. 9: add profile service to startup
Image for post
Image for post
Fig. 10: resulting JWT claims

(Optional) Connecting to MVC ASP.NET Core projects

Image for post
Image for post
Fig. 11: add additional options to AddOpenIdConnect method
Image for post
Image for post
Fig. 12: add authorize attribute to controller

Conclusion

Software Engineer. View my other articles at https://www.vastorigins.com and also guys listen to my podcast about life at https://anchor.fm/vastorigins.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store