Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Samples don't include population of Configuration data in database #38

Open
OriginalArkus opened this issue Feb 16, 2022 · 1 comment
Open
Labels
documentation Improvements or additions to documentation

Comments

@OriginalArkus
Copy link

The samples don't include any population of the Configuration data into the database.

There is an example that populates Test Users, but no example for Clients, IdentityProviders, IdentityResources, ApiResources, ApiScopes, or ClientCorsOrigins.

@daviddesmet
Copy link
Owner

There is really no difference as you normally do when working with MongoDB.

E.g.

// Startup.cs

services.AddSingleton<IMongoClient>(s =>
{
	var mcs = MongoClientSettings.FromUrl(new MongoUrl(connectionString));
	return new MongoClient(mcs);
};
// Inject IMongoClient since is configured in the startup

var db = mongoClient.GetDatabase("Security");
var clients = db.GetCollection<AspNetCore.IdentityServer.Mongo.Entities.Client>("Clients");
clients.InsertOne(new AspNetCore.IdentityServer.Mongo.Entities.Client
{
	ClientId = "your-client-id",
	ClientName = "Your Client Name",
	AllowedGrantTypes =
	{
		new AspNetCore.IdentityServer.Mongo.Entities.ClientGrantType { GrantType = GrantType.AuthorizationCode },
		new AspNetCore.IdentityServer.Mongo.Entities.ClientGrantType { GrantType = GrantType.ClientCredentials }
	},
	ClientSecrets = { new AspNetCore.IdentityServer.Mongo.Entities.ClientSecret { Value = "your secret", Created = DateTime.UtcNow } },
	RequireClientSecret = true,
	RequireConsent = false,
	RequirePkce = true,
        // removed for brevity
	Enabled = true,
	EnableLocalLogin = true
});

I will look into updating or creating another sample just for the population of such data.

@daviddesmet daviddesmet added the documentation Improvements or additions to documentation label Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants