public void Init(IDictionary <string, string> options) { _options = options; AspPipelineContext.Instance().ConfigureServiceContext.MvcAdded += HandleMvcAdded; AspPipelineContext.Instance().ApplicationBuilderContext.Initialized += HandleApplicationBuilderInitialized; AspPipelineContext.Instance().ApplicationBuilderContext.RouteConfigured += HandleRouteConfigured; }
private void HandleAuthenticationAdded(object sender, EventArgs e) { RsaSecurityKey rsa = null; var xml = _identityServerOptions.Configuration.JsonWebKeys.First().SerializedKey; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { var provider = new RSACryptoServiceProvider(); provider.FromXmlStringNetCore(xml); rsa = new RsaSecurityKey(provider); } else { var r = new RSAOpenSsl(); r.FromXmlStringNetCore(xml); rsa = new RsaSecurityKey(r); } AspPipelineContext.Instance().ConfigureServiceContext.Services.AddAuthentication(cfg => { cfg.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; cfg.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(cfg => { cfg.TokenValidationParameters = new TokenValidationParameters() { ValidateAudience = false, ValidateIssuer = false, ValidateIssuerSigningKey = true, IssuerSigningKey = rsa }; }); }
public void ConfigureServices(IServiceCollection services) { services.AddCors(options => options.AddPolicy("AllowAll", p => p.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader())); services.AddLogging(); var mvcBuilder = services.AddMvc(); AspPipelineContext.Instance().StartConfigureServices(services); services.AddAuthentication(Constants.CookieNames.ExternalCookieName) .AddCookie(Constants.CookieNames.ExternalCookieName) .AddCookie(Constants.CookieNames.ChangePasswordCookieName) .AddCookie(Constants.CookieNames.PasswordLessCookieName) .AddCookie(Constants.CookieNames.AcrCookieName) .AddFacebook(opts => { opts.ClientId = "569242033233529"; opts.ClientSecret = "12e0f33817634c0a650c0121d05e53eb"; opts.SignInScheme = Host.Constants.CookieNames.ExternalCookieName; opts.Scope.Add("public_profile"); opts.Scope.Add("email"); }); services.AddAuthentication(Host.Constants.CookieNames.CookieName) .AddCookie(Host.Constants.CookieNames.CookieName, opts => { opts.LoginPath = "/Home/Authenticate"; }); AspPipelineContext.Instance().ConfigureServiceContext.AddAuthentication(); AspPipelineContext.Instance().ConfigureServiceContext.AddMvc(mvcBuilder); services.AddAuthorization(opts => { AspPipelineContext.Instance().ConfigureServiceContext.AddAuthorization(opts); }); }
public void Init(IDictionary <string, string> properties) { _properties = properties; AspPipelineContext.Instance().ConfigureServiceContext.Initialized += HandleServiceContextInitialized; AspPipelineContext.Instance().ConfigureServiceContext.MvcAdded += HandleMvcAdded; AspPipelineContext.Instance().ConfigureServiceContext.AuthorizationAdded += HandleAuthorizationAdded; AspPipelineContext.Instance().ApplicationBuilderContext.Initialized += HandleApplicationBuilderInitialized; }
public void Init(IDictionary <string, string> properties) { _properties = properties == null ? new Dictionary <string, string>() : properties; AspPipelineContext.Instance().ConfigureServiceContext.Initialized += HandleServiceContextInitialized; AspPipelineContext.Instance().ConfigureServiceContext.AuthenticationAdded += HandleAuthenticationAdded; AspPipelineContext.Instance().ConfigureServiceContext.MvcAdded += HandleMvcAdded; AspPipelineContext.Instance().ConfigureServiceContext.AuthorizationAdded += HandleAuthorizationAdded; }
public void Init(IDictionary <string, string> properties) { _properties = properties == null ? new Dictionary <string, string>() : properties; _identityServerOptions = BuildOptions(_properties); AspPipelineContext.Instance().ConfigureServiceContext.Initialized += HandleServiceContextInitialized; AspPipelineContext.Instance().ConfigureServiceContext.MvcAdded += HandleMvcAdded; AspPipelineContext.Instance().ConfigureServiceContext.AuthenticationAdded += HandleAuthenticationAdded; AspPipelineContext.Instance().ConfigureServiceContext.AuthorizationAdded += HandleAuthorizationAdded; AspPipelineContext.Instance().ApplicationBuilderContext.Initialized += HandleApplicationBuilderInitialized; }
private void HandleServiceContextInitialized(object sender, System.EventArgs e) { string connectionString; if (!_properties.TryGetValue("ConnectionString", out connectionString)) { throw new ModuleException("configuration", "the property 'ConnectionString' is missing"); } AspPipelineContext.Instance().ConfigureServiceContext.Services.AddUmaPostgreEF(connectionString); }
private void HandleMvcAdded(object sender, System.EventArgs e) { string connectionString; if (!_properties.TryGetValue("ConnectionString", out connectionString)) { throw new ModuleException("configuration", "the property 'ConnectionString' is missing"); } AspPipelineContext.Instance().ConfigureServiceContext.Services.AddBasicAccountFilterSqliteEF(connectionString); }
private void HandleMvcAdded(object sender, EventArgs e) { var services = AspPipelineContext.Instance().ConfigureServiceContext.Services; var mvcBuilder = AspPipelineContext.Instance().ConfigureServiceContext.MvcBuilder; var assembly = typeof(SchemasController).Assembly; var embeddedFileProvider = new EmbeddedFileProvider(assembly); services.Configure <RazorViewEngineOptions>(options => { options.FileProviders.Add(embeddedFileProvider); }); mvcBuilder.AddApplicationPart(assembly); }
public void ConfigureServices(IServiceCollection services) { services.AddCors(options => options.AddPolicy("AllowAll", p => p.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader())); var mvcBuilder = services.AddMvc(); AspPipelineContext.Instance().StartConfigureServices(services); AspPipelineContext.Instance().ConfigureServiceContext.AddMvc(mvcBuilder); AspPipelineContext.Instance().ConfigureServiceContext.AddAuthentication(); services.AddAuthorization(opts => { opts.AddScimAuthPolicy(); }); }
private void HandleAuthenticationAdded(object sender, EventArgs e) { var oauthSecurityKey = GetSecurityKey(OAUTH_STORE_LOCATION_NAME, OAUTH_FIND_BY_SUBJECT_DISTINGUISHED_NAME, OAUTH_PUBLIC_KEY_FILE_NAME); var openidSecurityKey = GetSecurityKey(OPENID_STORE_LOCATION_NAME, OPENID_FIND_BY_SUBJECT_DISTINGUISHED_NAME, OPENID_PUBLIC_KEY_FILE_NAME); var openidIssuer = DEFAULT_OPENID_ISSUER; var oauthIssuer = DEFAULT_OAUTH_ISSUER; if (_properties.ContainsKey(OAUTH_ISSUER)) { oauthIssuer = _properties[OAUTH_ISSUER]; } if (_properties.ContainsKey(OPENID_ISSUER)) { openidIssuer = _properties[OPENID_ISSUER]; } var services = AspPipelineContext.Instance().ConfigureServiceContext.Services; services.AddAuthentication(cfg => { cfg.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; cfg.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(cfg => { cfg.TokenValidationParameters = new TokenValidationParameters() { ValidateIssuer = true, ValidIssuers = new List <string> { oauthIssuer, openidIssuer }, ValidateAudience = false, ValidateIssuerSigningKey = true, IssuerSigningKeyResolver = (string token, SecurityToken securityToken, string kid, TokenValidationParameters validationParameters) => { List <SecurityKey> keys = new List <SecurityKey> { oauthSecurityKey, openidSecurityKey }; return(keys); } }; }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { AspPipelineContext.Instance().StartConfigureApplicationBuilder(app, env, loggerFactory); app.UseCors("AllowAll"); loggerFactory.AddConsole(); app.UseAuthentication(); app.UseMvc(routes => { AspPipelineContext.Instance().ApplicationBuilderContext.ConfigureRoutes(routes); routes.MapRoute("AuthArea", "{area:exists}/Authenticate/{action}/{id?}", new { controller = "Authenticate", action = "Index" }); }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { AspPipelineContext.Instance().StartConfigureApplicationBuilder(app, env, loggerFactory); app.UseCors("AllowAll"); loggerFactory.AddConsole(); loggerFactory.AddDebug(); app.UseAuthentication(); app.UseUmaWebsiteStaticFiles(); app.UseUmaExceptionHandler(new ExceptionHandlerMiddlewareOptions { UmaEventSource = app.ApplicationServices.GetService <IUmaServerEventSource>() }); app.UseMvc(routes => { AspPipelineContext.Instance().ApplicationBuilderContext.ConfigureRoutes(routes); routes.MapRoute("default", "{controller}/{action}/{id?}", new { controller = "Home", action = "Index" }); }); }
private void HandleApplicationBuilderInitialized(object sender, EventArgs e) { var applicationBuilderContext = AspPipelineContext.Instance().ApplicationBuilderContext; applicationBuilderContext.App.UseShellStaticFiles(); }
private void HandleMvcAdded(object sender, EventArgs eventArgs) { var serviceContext = AspPipelineContext.Instance().ConfigureServiceContext; serviceContext.Services.AddAccountFilter(serviceContext.MvcBuilder); }
private void HandleApplicationBuilderInitialized(object sender, EventArgs e) { AspPipelineContext.Instance().ApplicationBuilderContext.App.UseOpenIdApi(new IdentityServerOptions()); }
private void HandleConfigureRoute(object sender, EventArgs e) { AspPipelineContext.Instance().ApplicationBuilderContext.RouteBuilder.UseUserManagement(); }
private void HandleMvcAdded(object sender, System.EventArgs e) { var configureServiceContext = AspPipelineContext.Instance().ConfigureServiceContext; configureServiceContext.Services.AddLoginPasswordAuthentication(configureServiceContext.MvcBuilder, GetOptions()); }
private void HandleAuthorizationAdded(object sender, EventArgs e) { AspPipelineContext.Instance().ConfigureServiceContext.AuthorizationOptions.AddScimAuthPolicy(); }
private void HandleServiceContextInitialized(object sender, EventArgs e) { AspPipelineContext.Instance().ConfigureServiceContext.Services.AddScimHost(new ScimServerOptions()); }
private void HandleServiceContextInitialized(object sender, EventArgs e) { var services = AspPipelineContext.Instance().ConfigureServiceContext.Services; services.AddUmaHost(new AuthorizationServerOptions()); }
private void HandleServiceContextInitialized(object sender, EventArgs e) { var services = AspPipelineContext.Instance().ConfigureServiceContext.Services; services.AddOpenIdApi(o => { }); }
private void HandleMvcAdded(object sender, EventArgs e) { var configureServiceContext = AspPipelineContext.Instance().ConfigureServiceContext; configureServiceContext.Services.AddBasicShell(configureServiceContext.MvcBuilder); }
public void Init(IDictionary <string, string> properties) { _properties = properties == null ? new Dictionary <string, string>() : properties; AspPipelineContext.Instance().ConfigureServiceContext.MvcAdded += HandleMvcAdded; AspPipelineContext.Instance().ApplicationBuilderContext.RouteConfigured += HandleRouteConfigured; }
private void HandleRouteConfigured(object sender, EventArgs e) { AspPipelineContext.Instance().ApplicationBuilderContext.RouteBuilder.UseShell(); }
private void HandleServiceContextInitialized(object sender, EventArgs e) { AspPipelineContext.Instance().ConfigureServiceContext.Services.AddStorage(opts => opts.UseInMemoryStorage()); }
private void HandleRouteConfigured(object sender, System.EventArgs e) { var applicationBuilderContext = AspPipelineContext.Instance().ApplicationBuilderContext; applicationBuilderContext.RouteBuilder.UseLoginPasswordAuthentication(); }
public void Init(IDictionary <string, string> options) { AspPipelineContext.Instance().ConfigureServiceContext.Initialized += HandleServiceContextInitialized; }
public void Init(IDictionary <string, string> properties) { _properties = properties; AspPipelineContext.Instance().ConfigureServiceContext.MvcAdded += HandleMvcAdded; }
private void HandleAuthorizationAdded(object sender, EventArgs e) { AspPipelineContext.Instance().ConfigureServiceContext.AuthorizationOptions.AddOpenIdSecurityPolicy(CookieAuthenticationDefaults.AuthenticationScheme); }