owin

C# Owin login results in identity=null on production system

有些话、适合烂在心里 提交于 2019-12-22 00:08:44
问题 I've got an asp.net MVC 5 web project which is running fine on my development system. But for some reason, the login using Microsoft Owin with Facebook stops working as soon as I deploy the solution on my production system. The callback always retrieves ....error=access_denied as parameter and I tracked it back to the fact that owin returns null for my identity. Any clue whats going on here? UPDATE I implemented log4net in my Owin code and was able to dive deeper: Response status code does

Custom parameter with Microsoft.Owin.Security.OpenIdConnect and AzureAD v 2.0 endpoint

戏子无情 提交于 2019-12-21 20:17:29
问题 I am migrating my Azure AD secured application to the v2.0 endpoint. I need to pass a custom parameter to the reply uri. With former Azure AD endpoint I did it by adding a usual query parameter to the reply url. e.g. https://myserver.com/myredirect_uri?mycustomparamerter=myvalue Unfortunately, with endpoint 2.0 I received an error saying that the reply uri does not match the one registered. Of course my custom parameter value is dynamic and I cannot hardcode it. I was looking to exploit the

How should I store per request data when using OWIN to Self-Host ASP.NET Web API

浪尽此生 提交于 2019-12-21 19:27:17
问题 I'm in the process of converting my ASP.NET Web API from being IIS hosted to being self hosted. In one of my DelegatingHandlers I set the current user based on the token from the HTTP header. I've been using HttpContext.Current.Items to store this information, but that isn't available under self hosting. What is the correct way to store per request data that can be accessed anywhere in my application? 回答1: The Request message has a Properties collection. 来源: https://stackoverflow.com

WCF, WebAPI and OWIN IIS integrated pipeline. Skip OWIN based on route

孤者浪人 提交于 2019-12-21 16:51:09
问题 Situation I have a Silverlight application that uses a WCF backend. Going forward we have moved to JS clients with WebAPI. I have a couple of WebAPI controllers that I would like to use from the Silverlight client and so have them loaded within the ASP.Net application that hosts the WCF services. This works fine from a "all services are available" point of view, however Authorization is being invoked multiple times for WCF calls; from OWIN and through WCF ServiceAuthorizationManager On the

ASP.Net WebAPI OWIN: Why would Request.GetOwinContext() return null?

房东的猫 提交于 2019-12-21 12:36:33
问题 In my production code we're having a problem where Request.GetOwinContext() always returns null. I setup a small test WebAPI controller to try and isolate the problem: public class TestController : ApiController { [HttpGet] public async Task<IHttpActionResult> GetAsyncContext(string provider) { if (HttpContext.Current.GetOwinContext() == null) return this.BadRequest("No HttpContext.Current Owin Context"); if (Request.GetOwinContext() == null) return this.BadRequest("No Owin Context"); return

OWIN Cookies vs FormsAuthentication

只谈情不闲聊 提交于 2019-12-21 12:15:14
问题 Are there any major advantages of using OWIN cookie-based authentication over Forms Authentication cookie-based authentication for developing MVC web applications? The reason I ask is that I would not be using any of the Entity Framework based hooks for OWIN authentication. I've built apps based on Forms Authentication for years and have been able to do things like create different authentication tokens for admins (faster timeouts), anonymous users, and registered users. Using the UserData

No ApplicationRoleManager class in my MVC 5 template

浪尽此生 提交于 2019-12-21 08:55:27
问题 When I try to add app.CreatePerOwinContext(ApplicationRoleManager.Create) to configauth I am told applicationRoleManager does not exist. Does anybody know why? using Microsoft.Owin.Security.OAuth; using Microsoft.AspNet.Identity; using Microsoft.AspNet.Identity.EntityFramework; using Microsoft.AspNet.Identity.Owin; using Microsoft.Owin; using Microsoft.Owin.Security.Cookies; using Microsoft.Owin.Security.DataProtection; using Microsoft.Owin.Security.Google; using Owin; using System; using

Pass a parameter to OWIN host

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-21 08:00:52
问题 I'm self-hosting ASP.NET Web API and SignalR using OWIN. I start the server (on a console app) with this code: using (WebApplication.Start<Startup>(url)) { Console.WriteLine("Running..."); Console.ReadLine(); } This works fine. But now I need to pass a parameter (an object) to the Startup class. How can this be done? 回答1: The WebApplication.Start method has an overload that accepts a IServiceProvider as parameter, so it is possible to inject the data I want. IServiceProvider serviceProvider =

OWIN app.use vs app.run vs app.map

拜拜、爱过 提交于 2019-12-21 06:59:20
问题 What's the difference among app.use , app.run , app.map in Owin? When to use what? It's not straightforward when reading the documentation. 回答1: app.use inserts a middleware into the pipeline which requires you to call the next middleware by calling next.Invoke(). app.run inserts a middleware without a next, so it just runs. With app.map you can map paths, which get evaluated at runtime, per request, to run certain middleware only if the request path matches the pattern you mapped. See docs

Mixed mode authentication with OWIN

大城市里の小女人 提交于 2019-12-21 05:04:07
问题 I am building an MVC 5 application. I need to authenticate people against an AD and a sql data base or a web service. Requirement is if a person is logged into corporate network or conneted over VPN i have to log them without asking for credentials. if the users are accessing the web site over internet or a person do not have AD account i have to use forms authentication. I am looking at this article but will this work with ASP.Net MVC and OWIN? Any other alternative? Thanks in advance. 回答1: