public static IPassportBuilder AddDbContext <TContext>(this IPassportBuilder builder, string connectionString) where TContext : DbContext { builder.Services.AddDefaultTransient <IClientRepository, ClientRepository>() .AddDefaultTransient <IClientScopeRepository, ClientScopeRepository>() .AddDefaultTransient <IClientSecretRepository, ClientSecretRepository>() .AddDefaultTransient <IScopeRepository, ScopeRepository>(); builder.Services.AddDbContext <TContext>(x => x.UseSqlServer(connectionString)); return(builder); }
public static IPassportBuilder AddInMemoryClients(this IPassportBuilder builder, IEnumerable <ClientVm> clients) { builder.Services.AddDefaultTransient <IClientRepository, ClientMemoryRepository>() .AddDefaultTransient <IClientScopeRepository, ClientScopeRepository>() .AddDefaultTransient <IClientSecretRepository, ClientSecretRepository>() .AddDefaultTransient <IScopeRepository, ScopeRepository>(); builder.Services.AddSingleton(clients); return(builder); }
public static IPassportBuilder AddSecretKey(this IPassportBuilder builder, string secretKey) { builder.Services.AddOptions(); var signingKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(secretKey)); builder.Services.Configure <PassportOptions>(options => { options.SigningCredentials = new SigningCredentials(signingKey, SecurityAlgorithms.HmacSha256); }); return(builder); }
public static IPassportBuilder AddInMemoryScopes(this IPassportBuilder builder, IEnumerable <ScopeVm> scopes) { builder.Services.AddSingleton(scopes); return(builder); }