katana

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

烈酒焚心 提交于 2019-11-28 16:50:55
问题 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

How to explain Katana and OWIN in simple words and uses?

China☆狼群 提交于 2019-11-28 14:54:44
I have read many articles about the OWIN and Katana projects, but I could not get the whole picture of it. For a normal web developer who uses ASP.NET: What exactly is OWIN and what problems does it solve (in simple words). What is its relation to IIS? Does OWIN replace IIS? if not, in what situations does OWIN best fit? How could OWIN help me in my daily work projects? How could OWIN help me in a self-improvement projects? Admir Tuzović Regarding the comment above, OWIN is not a framework. OWIN is a specification on how web servers and web applications should be built in order to decouple

No owin.Environment item was found in the context

不打扰是莪最后的温柔 提交于 2019-11-28 09:38:24
Microsoft recently introduced new ASP.NET Identity - replacement for old (Simple)Membership. Unfortunately, I can't use this new membership system in my old project because it throws System.InvalidOperationException: No owin.Environment item was found in the context. This is a known bug , but Microsoft keeps silence about this issue. The easiest way to reproduce this bug - it's to create a new web application (MVC, WebForms or WebApi - doesn't matter) in VS 2013 (with Web Tools 2013 Preview Refresh) and then go to the login page. It will work. Then change namespace in your application to

How do you set katana-project to allow token requests in json format?

浪子不回头ぞ 提交于 2019-11-28 08:09:35
When I setup an OAuth Authorization Server in asp.net webapi 2 how can I set the token endpoint to accept json rather then a form encoded post? Using the sample http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api I tried to send application/json with { "grant_type":"password", "username":"Alice", "password":"password123" } I receive the response 400 Bad Request { "error" : "unsupported_grant_type" } where as a content type of application/x-www-form-urlencoded and body of grant_type=password&username=Alice&password=password123 works as expected. 200 OK { "access_token" :

GoogleOauth2 Issue Getting Internal Server 500 error

妖精的绣舞 提交于 2019-11-28 06:55:51
I decided to give the new Google Oauth2 middleware a try and it has pretty much broken everything. Here is my provider config from startup.auth.cs.. When turned on, all of the providers including the google provider get a 500 internal server on Challenge. However the details of the internal server error are not available and I cant figure out how to turn on any debugging or tracing for the Katana middleware. Seems to me like they were in a rush to get the google Oauth middleware out the door. //// GOOGLE var googleOptions = new GoogleOAuth2AuthenticationOptions { ClientId = "228", ClientSecret

CORS is not working in web api with OWIN authentication

末鹿安然 提交于 2019-11-28 05:58:32
In my application i am using web api with token based authentication with CORS support, but when client request for the token, an error occured due to CORS (Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at (my site name) . This can be fixed by moving the resource to the same domain or enabling CORS.) I had configured everything required for CORS support ( i think so). here my configuration Owin start up class public class Startup { public void Configuration(IAppBuilder app) { var config = new HttpConfiguration { DependencyResolver = new

Global exception handling in OWIN middleware

泪湿孤枕 提交于 2019-11-28 03:49:47
I'm trying to create a unified error handling/reporting in ASP.NET Web API 2.1 Project built on top of OWIN middleware (IIS HOST using Owin.Host.SystemWeb). Currently I used a custom exception logger which inherits from System.Web.Http.ExceptionHandling.ExceptionLogger and uses NLog to log all exceptions as the code below: public class NLogExceptionLogger : ExceptionLogger { private static readonly Logger Nlog = LogManager.GetCurrentClassLogger(); public override void Log(ExceptionLoggerContext context) { //Log using NLog } } The I want to change the response body for all API exceptions to a

How do I issue the corresponding Bearer and Cookie identity in ASP.NET with multiple Authorization schemes?

让人想犯罪 __ 提交于 2019-11-27 22:38:30
问题 This documentation describes in part how to use more than one authentication scheme: In some scenarios, such as Single Page Applications it is possible to end up with multiple authentication methods. For example, your application may use cookie-based authentication to log in and bearer authentication for JavaScript requests. In some cases you may have multiple instances of an authentication middleware. For example, two cookie middlewares where one contains a basic identity and one is created

Alternative to use HttpContext in System.Web for Owin

此生再无相见时 提交于 2019-11-27 22:03:21
问题 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

User (IPrincipal) not available on ApiController's constructor using Web Api 2.1 and Owin

五迷三道 提交于 2019-11-27 21:21:45
问题 I am Using Web Api 2.1 with Asp.Net Identity 2. I am trying to get the authenticated User on my ApiController's constructor (I am using AutoFac to inject my dependencies), but the User shows as not authenticated when the constructor is called. I am trying to get the User so I can generate Audit information for any DB write-operations. A few things I'm doing that can help on the diagnosis: I am using only app.UseOAuthBearerTokens as authentication with Asp.Net Identity 2. This means that I