owin

Use External Access Token or Local Access Token

爱⌒轻易说出口 提交于 2020-01-11 19:56:32
问题 I am developing an application using ASP.NET MVC 5.2.2, Web API 2.2 and Katana/OWIN 3.0 . The application uses ASP.NET Identity 2.1 for local accounts and database. I am using OAuth Authorization Server to generate access and refresh token. I have Android and IOS apps which uses my local oauth authorization server. Android and IOS apps uses SDK to login with Facebook, Google, etc. After that the apps will send the (Facebook/Google/etc) access token to the server. The server will validate

OWIN and Azure AD HTTPS to HTTP Redirect Loop

扶醉桌前 提交于 2020-01-11 06:01:07
问题 I am very new to OWIN :). I am trying to have a page with an open public area which will allow anonymous over HTTP, and then a restricted section which will require authentication. I'd like not to force the entire site to be HTTPS for general users. The issue I have is that I receive the following loop: http://example.com/authenticatedPage -> 302 Redirect to AD login Login to AD page HTTP 200. Triggers open of the Azure AD link to site. Link to site identifies that this is an OWIN redirect

SignalR without OWIN

。_饼干妹妹 提交于 2020-01-11 05:30:10
问题 I'm participating in the ASP MVC project. I want to use SignalR in the project but I don't want to use OWIN lib. As I understand, SignalR is registered in the application using this piece of code: public class Startup { public void Configuration(IAppBuilder app) { app.MapSignalR(); } } How can I modify this to remove the dependency to OWIN? I would like to use approach similar to RouteConfig.RegisterRoutes(RouteTable.Routes); 回答1: First be sure to Get-Package within the Package Manager

How to set default static web page for Katana/Owin self hosted app?

*爱你&永不变心* 提交于 2020-01-10 08:48:13
问题 I've set up a web site using an Owin self hosted console app. I'm serving static files with no problem, the 'root' of the static part of the site works properly, and the web API routes work fine also. If I browse to: http://localhost/index.html it presents everything like I expect. But I have not figured out how to set it so that browsing to: http://localhost presents index.html (as the default view). This Just Works under an IIS-style site. How do I make it work with Owin self host? 回答1: I

How do you resolve a virtual path to a file under an OWIN host?

回眸只為那壹抹淺笑 提交于 2020-01-10 08:38:58
问题 Under ASP.NET and IIS, if I have a virtual path in the form "~/content", I can resolve this to a physical location using the MapPath method: HttpContext.Server.MapPath("~/content"); How can you resolve a virtual paths to a physical location under an OWIN host? 回答1: You may use AppDomain.CurrentDomain.SetupInformation.ApplicationBase to get root of your application. With the root path, you can implement "MapPath" for Owin. I do not know another way yet. (The ApplicationBase property is also

OWIN Oauth differentiate expired and invalid token

我的梦境 提交于 2020-01-06 11:47:13
问题 I use OWIN Oauth in my ASP.NET MVC application to provide access token for mobile applications. Here's the setup of OAuth: app.UseOAuthAuthorizationServer(new OAuthAuthorizationServerOptions { TokenEndpointPath = new PathString("/api/authenticate/login"), Provider = dependencyContainer.GetService<IOAuthAuthorizationServerProvider>(), RefreshTokenProvider = dependencyContainer.GetService<IAuthenticationTokenProvider>(), AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(applicationSettings

SignInManager.ExternalSignInAsync with Facebook always returns failure

非 Y 不嫁゛ 提交于 2020-01-06 02:41:54
问题 Google+ works, but Facebook always returns a failure. When I examine loginInfo it shows that authenticated = true. This is the code in Statup.Auth.cs - I included the Google+ code which works. public void ConfigureAuth(IAppBuilder app) { // Configure the db context, user manager and signin manager to use a single instance per request app.CreatePerOwinContext(ApplicationDbContext.Create); app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create); app.CreatePerOwinContext

Owin.TestServer To Test a Middleware that Requires Authentication

风格不统一 提交于 2020-01-05 11:26:57
问题 I have a middleware method that requires context.Authentication.User.Identity.Name to be resolved for proper execution. However, when writing a unit test these properties are obviously null as no sign-in has occurred. I am not using Oauth or anything authentication related in this middleware (beyond the obvious name property), as it should be handled elsewhere in another middleware (to promote re-use/flexibility of the component I am developing). Is there a way to mock/fake this value so I

Session timeout owin in MVC 4 after 5 minutes

回眸只為那壹抹淺笑 提交于 2020-01-05 10:18:29
问题 I have an MVC 4 application which uses Owin context to login users. Remember me selected or not, users get kicked out of the system after 5 minutes. Sessionstate is set to be inProc, and it is for 480 minutes. Here is the startup.cs file: public void ConfigureAuth(IAppBuilder app) { // Enable the application to use a cookie to store information for the signed in user // and to use a cookie to temporarily store information about a user logging in with a third party login provider // Configure

Alternate of GetUserManager in asp.net core

空扰寡人 提交于 2020-01-05 08:34:08
问题 I am converting an existing Asp.net Mvc project to .Net Core now the issue is this get method public ApplicationUserManager UserManager { get { return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>(); } private set { _userManager = value; } } In Mvc we could fetch OwinContext using HttpContext.GetOwinContext().GetUserManager() but in case of .Net Core GetOwinContext not present , When I compare definition of HttpContext of both classes HttpContextBase is