mmajic
mmajic
CC#
Created by TonesCPK on 11/29/2023 in #help
Deciding on a tech stack for internal tools
Depends on the usage and required features. From the short text it sounds like you would need a client that connects to an API. For mobile apps check out Maui. For web apps check out Angular (typescript). For backend stuff look at .NET and Microsoft SQL server for databases. Not sure about windows apps since ive never done one but look at windows forms
2 replies
CC#
Created by mmajic on 11/29/2023 in #help
IdentityServer update database error when multiple user types.
here is where i register identityserver
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
{
services.AddDbContext<DataContext>(options =>
options.UseSqlServer(
configuration.GetConnectionString("DefaultConnection"),
b => b.MigrationsAssembly(typeof(DataContext).Assembly.FullName)));

services.AddScoped<IDataContext>(provider => provider.GetService<DataContext>()!);

services.AddIdentity<EntityUser, Role>(opt =>
{
opt.Password.RequiredLength = 8;
opt.Password.RequireDigit = false;
opt.Password.RequireNonAlphanumeric = false;
opt.Password.RequireUppercase = false;
opt.User.RequireUniqueEmail = true;
opt.User.AllowedUserNameCharacters = null;
})
.AddEntityFrameworkStores<DataContext>();

services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.SaveToken = true;
options.RequireHttpsMetadata = false;
options.TokenValidationParameters = new TokenValidationParameters()
{
ValidateIssuer = true,
ValidateAudience = true,
ValidAudience = configuration["JWTSettings:validAudience"],
ValidIssuer = configuration["JWTSettings:validIssuer"],
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["JWTSettings:securityKey"]!))
};
});
return services;
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
{
services.AddDbContext<DataContext>(options =>
options.UseSqlServer(
configuration.GetConnectionString("DefaultConnection"),
b => b.MigrationsAssembly(typeof(DataContext).Assembly.FullName)));

services.AddScoped<IDataContext>(provider => provider.GetService<DataContext>()!);

services.AddIdentity<EntityUser, Role>(opt =>
{
opt.Password.RequiredLength = 8;
opt.Password.RequireDigit = false;
opt.Password.RequireNonAlphanumeric = false;
opt.Password.RequireUppercase = false;
opt.User.RequireUniqueEmail = true;
opt.User.AllowedUserNameCharacters = null;
})
.AddEntityFrameworkStores<DataContext>();

services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(options =>
{
options.SaveToken = true;
options.RequireHttpsMetadata = false;
options.TokenValidationParameters = new TokenValidationParameters()
{
ValidateIssuer = true,
ValidateAudience = true,
ValidAudience = configuration["JWTSettings:validAudience"],
ValidIssuer = configuration["JWTSettings:validIssuer"],
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configuration["JWTSettings:securityKey"]!))
};
});
return services;
2 replies