Skip to content

souzartn/IdentityServer4.Samples.Mongo

Repository files navigation

IdentityServer4 Sample for MongoDB

7_EntityFrameworkStorage-mongo: Based on Quickstart #7: Using EntityFramework Core for configuration and operational data but using MongoDB for the configuration data.

Note: In order to better support this repo moving forward, we will only maintain one quicksample based on MongoDB.

Each Sample Solution listed above is composed of:

  • IdentityServer - project based on IdentityServer4 that manages authentication
  • API - is a sample API project, used by client/* projects to showcase QuickstartIdentityServer functionality
  • clients/MvcClient - Asp .Net Core mvc client project sample
  • clients/Client - .NET Core console client project sample

Technical dependencies

  • Solution is based on Visual Studio 2019.
  • ASP .Net Core 2.2
  • Most relevant Nugets:

Running the solution

Getting one of those sample project up and running on your machine should be fairly straightforward once you have any MongoDB running.

  • If you do not have MongoDB in your environment or wish to run it locally please take a look at Setup mongo
  1. With mongo depency resolved, open the selected project in Visual Studio.
  2. Make sure you have multiple projects selected to startup - "IdentityServer", "Api" and any desired client (e.g. Clients\MvcClient) before executing solution from Visual Studio - see screenshots below:

First execution

In your very first execution you should get an exception stating that "Mongo Repository was created/populated! Please restart your website..."

This is because the first execution will automatically create a new Mongo Repository (database), but due to MongoDB.Driver limitations it is necessary to restart the solution in order to proper configure MongoDB to ignore Extra Elements such as "_id" that does not exist in IdentityServer4.Models classes.

Authentication

Once the MongoDB is created, you should see two browser tabs, one related to the MvcClient and the other related to QuickstartIdentityServer. In the Click on "Secure" menu In the the MvcClient, click on "secure", you will be redirected to QuickstartIdentityServer authentication page - it is almost identical to all original IdentityServer4.Samples, but for your convinience we took the opportunity to display a some sample user/password that were automatically added to the MongoDB.

Aditional information

About

Project inspired in the "IdentityServer4.Samples" that shows how to use MongoDB for the configuration data.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •