katana

Is there Application_End from Global.asax in Owin?

▼魔方 西西 提交于 2019-11-29 23:39:55
Startup.cs is a new way to initialize your app instead of Application_Start in Global.asax and it's fine. But is there a place to put my teardown logic, for example this: public class WebApiApplication : System.Web.HttpApplication { protected void Application_End() { // Release you ServiceBroker listener SqlDependency.Stop(connString); } } Looked in Microsoft.Owin namespace but it only seems to have OwinStartupAttribute . Does this mean that application lifecycle events are still processed by System.Web.HttpApplication instance and are not supported by OWIN specification? AppProperties , found

In Web Api / Owin architecture, where are requests to '/token' handled?

被刻印的时光 ゝ 提交于 2019-11-29 21:28:48
I am trying to understand the Asp.net Web Api Individual Accounts authentication and authorization. I have see several tutorials on the web including this one . In short, when a user agent provides username and password the API issues a token that the client will use in subsequent calls to the API for to identify itself. The user agent receives the token by making a request, typically to: http://example.com/Token . The path appears to be set in the Startup class like so: TokenEndpointPath = new PathString("/Token") My problem is, I can't find any controller methods that match that path. How

The OWIN authentication pipeline, and how to use Katana middleware correctly?

廉价感情. 提交于 2019-11-29 20:17:35
I've recently started looking at the new ASP.Net Identity framework and the Katana middleware, there's a surprising amount of code and documentation out there, but I'm seeing what appears to be a lot of conflicting information, which I guess is a result of the increasing frequency of code updates. I'm looking to use WsFederation Authentication against an internal ADFS 2 service, but the way the OWIN authentication pipeline works has me a little confused and I'm hoping someone can offer some definitive information. Specifically, I'm interested in the order in which middleware should be hooked

How do I get an instance of IAppBuilder elsewhere in my ASP.NET MVC 5.2.3 application?

∥☆過路亽.° 提交于 2019-11-29 18:31:17
问题 I need to build an Owin middle-ware object but not from within the Startup class. I need to build it from within anywhere else in my code, so I need a reference to the AppBuilder instance of the application. Is there a way to get that from anywhere else? 回答1: You could simply inject AppBuilder itself to OwinContext . But since Owin context only supports IDisposable object, wrap it in IDisposable object and register it. public class AppBuilderProvider : IDisposable { private IAppBuilder _app;

Access token revocation implementation in OAuth 2

老子叫甜甜 提交于 2019-11-29 13:45:25
问题 I've used OWIN OAuth 2 to implement my Authorization Server Provider. Now, I want to implement token revocation (when my client application wants to logout). Can anybody help me and tell how to implement token revocation in OWIN KATANA OAuth 2. Are there some good practices for it? 回答1: There are two kinds of token involved in OAuth 2.0. One is access token and the other is refresh token. For refresh token, I really recommend Token Based Authentication using ASP.NET Web API 2, Owin, and

Owin cookie authentication set-cookie not saving in browser

橙三吉。 提交于 2019-11-29 03:41:13
I am building self-hosted web server on this stack: OWIN Nancy Web Api 2 And I am using Microsoft.Owin.Security.Cookies from Katana for forms-like authentication. I got Set-Cookie header in response, but cookie don't being saved and not being included in next request. So what's the problem? What I am doing wrong? Owin startup: app.UseCookieAuthentication(new CookieAuthenticationOptions() { AuthenticationMode = AuthenticationMode.Active, AuthenticationType = "GM", CookieHttpOnly = true, CookieSecure = CookieSecureOption.SameAsRequest, CookiePath = "/", CookieName = CookieAuthenticationDefaults

Alternative to use HttpContext in System.Web for Owin

余生长醉 提交于 2019-11-29 02:59:13
ASP.NET authentication is now based on OWIN middleware that can be used on any OWIN-based host. ASP.NET Identity does not have any dependency on System.Web . I have an AuthorizeAttribute filter where I need to get the current user and add some properties to be retrieved later by action controllers. The problem is that I have to use the HttpContext wich belongs to System.Web. Is there any alternative of HttpContext for Owin? public class WebApiAuthorizeAttribute : AuthorizeAttribute { public override async Task OnAuthorizationAsync(HttpActionContext actionContext, CancellationToken

Customising the OWIN/Katana UserManager factory behaviour

假装没事ソ 提交于 2019-11-29 01:55:45
问题 There are many samples online using OWIN/Katana to find users in a database based on ausername/password combination and generate a claims principal, such as... var userManager = context.OwinContext.GetUserManager<ApplicationUserManager>(); ApplicationUser user = await userManager.FindAsync(context.UserName, context.Password); // generate claims here... That's fine if you're creating a new application and want Entity Framework to do the dirty work. But, I have an eight year old monolithic web

How to use Swagger as Welcome Page of IAppBuilder in WebAPI

依然范特西╮ 提交于 2019-11-28 21:05:30
问题 I try to use Swagger with Microsoft WebAPI 2. For the moment, I've the following call in a method. appBuilder .ConfigureOAuth() .UseWebApi(configuration) .UseWelcomePage(); If I want to use Swagger, I must use this url "https://localhost:44300/swagger" which one works very well. I want my home page redirects to the url of my swagger, perhaps as follows but this sample doesn't works. appBuilder ... .UseWelcomePage("/swagger"); Any idea ? 回答1: I got this working how I wanted by adding a route

In Web Api / Owin architecture, where are requests to '/token' handled?

泪湿孤枕 提交于 2019-11-28 19:03:23
问题 I am trying to understand the Asp.net Web Api Individual Accounts authentication and authorization. I have see several tutorials on the web including this one. In short, when a user agent provides username and password the API issues a token that the client will use in subsequent calls to the API for to identify itself. The user agent receives the token by making a request, typically to: http://example.com/Token. The path appears to be set in the Startup class like so: TokenEndpointPath = new