protected static Dgraph4NetClient GetDgraphClient() { // This switch must be set before creating the GrpcChannel/HttpClient. AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); // The port number(5000) must match the port of the gRPC server. var channel = GrpcChannel.ForAddress("http://localhost:9080", new GrpcChannelOptions { Credentials = ChannelCredentials.Insecure }); var dg = new Dgraph4NetClient(channel); return(dg); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <ForwardedHeadersOptions>(options => { options.ForwardedHeaders = ForwardedHeaders.All; }); services.AddSingleton(Configuration); services.AddTransient <ChannelBase>(delegate { return(new Channel("localhost:9080", ChannelCredentials.Insecure)); }); services.AddTransient(sp => new Dgraph4NetClient(sp.GetRequiredService <ChannelBase>())); ClassFactory.MapAssembly(typeof(DUser).Assembly); var channel = new Channel("localhost:9080", ChannelCredentials.Insecure); var dgraph = new Dgraph4NetClient(channel); if (!File.Exists("schema.dgraph")) { dgraph.Alter(new Api.Operation { DropAll = true }).GetAwaiter().GetResult(); } // sends mapping to Dgraph dgraph.Map(typeof(DUser).Assembly); services.AddIdentity <DUser, DRole>(options => options.SignIn.RequireConfirmedAccount = true) .AddRoleStore <RoleStore>() .AddUserStore <UserStore>() .AddDefaultTokenProviders() .AddDefaultUI(); services.AddTransient <UserStore, UserStore>(); services.AddRazorPages(); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews(); services.Configure <ForwardedHeadersOptions>(options => { options.ForwardedHeaders = ForwardedHeaders.All; }); services.AddSingleton(Configuration); services.AddTransient <ChannelBase>(delegate { return(new Channel("localhost:9080", ChannelCredentials.Insecure)); }); services.AddTransient(sp => new Dgraph4NetClient(sp.GetRequiredService <ChannelBase>())); ClassFactory.MapAssembly(typeof(OpenIddictDgraphExtensions).Assembly); var channel = new Channel("localhost:9080", ChannelCredentials.Insecure); var dgraph = new Dgraph4NetClient(channel); if (!File.Exists("schema.dgraph")) { dgraph.Alter(new Api.Operation { DropAll = true }).GetAwaiter().GetResult(); } // sends mapping to Dgraph dgraph.Map(typeof(OpenIddictDgraphExtensions).Assembly); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie() .AddOAuth("oidc", options => { options.AuthorizationEndpoint = "/connect/authorize"; }); services.AddOpenIddict().AddCore(options => { options.UseDgraph(); }) // Register the OpenIddict server components. .AddServer(options => { // Enable the token endpoint. options.SetTokenEndpointUris("/connect/token"); // Enable the client credentials flow. options.AllowClientCredentialsFlow(); // Register the signing and encryption credentials. options.AddDevelopmentEncryptionCertificate() .AddDevelopmentSigningCertificate(); // Register the ASP.NET Core host and configure the ASP.NET Core-specific options. options.UseAspNetCore() .EnableTokenEndpointPassthrough(); }) // Register the OpenIddict validation components. .AddValidation(options => { // Import the configuration from the local OpenIddict server instance. options.UseLocalServer(); // Register the ASP.NET Core host. options.UseAspNetCore(); }); ; services.AddMvcCore(); }
public RoleStore(ILogger <RoleStore> logger, Dgraph4NetClient context, IdentityErrorDescriber describer) : base(logger, context, describer) { }