I’m testing Duende Identity Server.
I used the sample named 6_JS_with_backend to test Google IDP. The initial sample is working fine.
I modified it to replace the in memory data by a database (using Identity Framework) and then the claims are missing the profile information (name, givenname, familyname). As soon as I switch back to “In Memory” it’s working fine again.
The database has been created succesfully by EF migration and there are no execution errors.
I don’t understand what’s happening.
Javascript client is not modified.
IdentityServer ConfigureServices:
public static WebApplication ConfigureServices(this WebApplicationBuilder builder)
{
var migrationsAssembly = typeof(Program).Assembly.GetName().Name;
builder.Services.AddRazorPages();
string connectionString = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(connectionString));
builder.Services.AddIdentity<ApplicationUser, ApplicationRole>()
.AddEntityFrameworkStores<ApplicationDbContext>();
builder.Services.AddIdentityServer(options =>
{
options.EmitStaticAudienceClaim = true;
})
.AddConfigurationStoreCache()
.AddConfigurationStore(options =>
{
options.EnablePooling = true;
options.ConfigureDbContext = builder =>
{
builder.UseSqlServer(connectionString, configure =>
{
configure.MigrationsAssembly(migrationsAssembly);
});
};
})
.AddOperationalStore(options =>
{
options.EnablePooling = true;
options.ConfigureDbContext = builder =>
{
builder.UseSqlServer(connectionString, configure =>
{
configure.MigrationsAssembly(migrationsAssembly);
});
};
options.EnableTokenCleanup = true;
options.TokenCleanupInterval = (int)TimeSpan.FromDays(20).TotalSeconds;
});
builder.Services.AddIdentityServerConfiguration(opt => opt.LicenseKey = "<TEST>").AddClientConfigurationStore();
builder.Services.AddConfigurationDbContext<ConfigurationDbContext>(options =>
{
options.ConfigureDbContext = builder => builder.UseSqlServer(connectionString);
});
var configuration = builder.Configuration;
// Put in Keyvault
builder.Services.AddAuthentication()
.AddGoogle("Google", options =>
{
options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;
options.ClientId = configuration["Authentication:Google:ClientId"]!;
options.ClientSecret = configuration["Authentication:Google:ClientSecret"]!;
});
return builder.Build();
}
ApplicationRoles:
using Microsoft.AspNetCore.Identity;
namespace IdentityServer.Models
{
public class ApplicationRole : IdentityRole
{
}
}
ApplicationUser
using Microsoft.AspNetCore.Identity;
namespace IdentityServer.Models
{
public class ApplicationUser : IdentityUser
{
public string? TenantId { get; set; }
public string? License { get; set; }
}
}
In Memory result:
With database result:
I checked in the database.
The client is here, clientscopes and identityresources as well.