owin

Claims Auth with OWIN Self Hosted WebApi

天大地大妈咪最大 提交于 2019-12-20 18:09:07
问题 I am self hosting WebApi with the following configuration: Visual Studio 2012 / .NET 4.0 public void Configuration(IAppBuilder appBuilder) { var config = new HttpConfiguration(); // authentication config.MessageHandlers.Add(new Shield.PresharedKeyAuthorizer()); // routing config.Routes.MapHttpRoute( name: "Default", routeTemplate: "{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); appBuilder.UseWebApi(config); } I have a simple test setup with the following

How to use IAppBuilder-based Owin Middleware in ASP.NET 5

[亡魂溺海] 提交于 2019-12-20 17:33:00
问题 ASP.NET 5 (aspnet vnext) is OWIN based like Katana was, but has different abstractions. Notably IAppBuilder has been replaced by IApplicationBuilder . Many middleware libraries depend on IAppBuilder and have not been updated to support ASP.NET 5 How can I use this OWIN middleware in APS.NET 5 middleware. Both are OWIN based so it should be possible. Microsoft.AspNet.Builder.OwinExtensions does provide a UseOwin method, but it is based on the low-level OWIN signatures so cannot be used with

Passing logical call context from OWIN pipeline to WebApi controller

青春壹個敷衍的年華 提交于 2019-12-20 17:32:24
问题 I'm trying to pass contextual information on the logical call context (using CallContext.LogicalSetData(CallContextKey, value) ) as per Stephen Cleary's post http://blog.stephencleary.com/2013/04/implicit-async-context-asynclocal.html; and inspired by the code in https://github.com/neuecc/OwinRequestScopeContext. The value will be available through out the OWIN pipeline, but it is not available when the call enters the WebApi controller, the value is not set. I also noticed that when setting

How to pass information from OnAuthenticated event to a controller and SignIn?

一曲冷凌霜 提交于 2019-12-20 15:25:49
问题 As I've found out here, I can't call HttpContext.GetOwinContext().Authentication.SignIn(...) in FacebookAuthenticationProvider OnAuthenticated event. It seems to be a different context. My users will be from Facebook, which means that I will need to retrieve data such as id , email ... This information is accessible on the OnAuthenticated event and I need this information to SignIn. I need to access this information on my controller... I tried this in the event: context.OwinContext.Set(

ASP.NET Web API and OpenID Connect: how to get Access Token from Authorization Code

和自甴很熟 提交于 2019-12-20 10:36:43
问题 I try to get OpenID Connect running... A user of my Web API managed to get an Authorization Code of a OpenID Connect Provider. How am I supposed to pass this code to my ASP.NET Web API? How do I have to configure OWIN Middleware such that I can get an Access Token using the Authorization Code? UPDATE: A SPA uses AJAX for communicating with my web service (ASP.NET Web API). In my web service a use OWIN Middleware. I set OpenIDConnect as the authentication mechanism. When the web service is

ASP.net Identity, IoC and sharing DbContext

让人想犯罪 __ 提交于 2019-12-20 10:27:57
问题 Have anyone been successful in attaching an IoC with OWIN ASP.NET Identity to share the same DbContext as the WebApi (or MVC) application? I would like that if ASP.Net identity loads the user, it loads in the same dbcontext as used in the rest of the application. (using AutoFac as IoC - but wouldn't mind an example with other container) Edit : 06/Jan/2014: Just to be a bit more specific, when the ASP.Net identity attempts to use a DbContext it needs to be the same DbContext instance as the

405 Method Not Allowed on WebAPI2 (OWIN)

﹥>﹥吖頭↗ 提交于 2019-12-20 09:48:43
问题 I am setting up a WebAPI endpoint for my API, but am having trouble getting my AngularJS calls to my PostRegister method to work. The webAPI and Angular are on separate sites. On the Startup.cs I have: public void Configuration(IAppBuilder app) { ConfigureOAuth(app); var config = new HttpConfiguration(); WebApiConfig.Register(config); app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); app.UseWebApi(config); } private void ConfigureOAuth(IAppBuilder app) { var oAuthServerOptions = new

How can I instantiate OWIN IDataProtectionProvider in Azure Web Jobs?

非 Y 不嫁゛ 提交于 2019-12-20 09:38:03
问题 I need an instance of IDataProtectionProvider to generate email confirmation tokens using the Identity Framework UserManager in an Azure Web Jobs worker: var confirmToken = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); This crashes because a null IUserTokenProvider<User, int> was passed to the UserManager<User, int> upon constuction. In the MVC application an instance is created like this: public class OWINStartup { public void Configuration(IAppBuilder app) { var

Custom Identity using MVC5 and OWIN

只愿长相守 提交于 2019-12-20 08:40:21
问题 I trying to add custom properties to the ApplicationUser for a web site using MVC5 and OWIN authentication. I've read https://stackoverflow.com/a/10524305/264607 and I like how it integrates with the base controller for easy access to the new properties. My issue is that when I set the HTTPContext.Current.User property to my new IPrincipal I get a null reference error: [NullReferenceException: Object reference not set to an instance of an object.] System.Web.Security.UrlAuthorizationModule

How to serve index.html with web api selfhosted with OWIN

我的梦境 提交于 2019-12-20 08:37:05
问题 Should be an easy question, just can't find the answer. I have an SPA (AngularJS) with web api which is self hosted with Owin. I use Nancy to serve the page, but I would like to get rid of Nancy and use Index.html as my single page. I've seen this question here: How to route EVERYTHING other than Web API to /index.html I can't use accepted answer as I don't have MVC and HomeController, the way suggested in the updated question doesn't work either, I get No HTTP resource was found that matches