owin

OWIN Security - How to Implement OAuth2 Refresh Tokens

元气小坏坏 提交于 2020-01-05 08:11:54
问题 I am using the Web Api 2 template that comes with Visual Studio 2013 has some OWIN middleware to do User Authentication and the likes of. In the OAuthAuthorizationServerOptions I noticed that the OAuth2 Server is setup to hand out tokens that expire in 14 days OAuthOptions = new OAuthAuthorizationServerOptions { TokenEndpointPath = new PathString("/api/token"), Provider = new ApplicationOAuthProvider(PublicClientId,UserManagerFactory) , AuthorizeEndpointPath = new PathString("/api/Account

UserManager.Update(user) method isn't thread safe

可紊 提交于 2020-01-05 04:05:14
问题 I'm trying to update a user with UserManager in a controller. Just before I update the user, a call to an external service fires a webhook that tries to update the same user, also using UserManager. But that's a different request and a different part of the application (the "webhook controller"). Here's the exception I got while debugging in the controller: System.Data.Entity.Core.EntityException. "An error occurred while starting a transaction on the provider connection. See the inner

OWIN DbContext and a single DbContext for all of my Repositories

匆匆过客 提交于 2020-01-04 19:38:56
问题 I am building a ASP.NET MVC application. I'm new to the whole Repositories/Unit Of Work patterns. I'm part way through implementing a generic repository for my EF objects. I realise that there is an issue with ensuring that you only have a single DbContext per Http request... I'm pretty sure that I can achieve this by creating an instance using OWIN. /// <summary> /// Configures OWIN /// </summary> /// <param name="app"></param> public void Configuration(IAppBuilder app) { // Create instance

Need help debugging JwtSecurityTokenHandler (web api owin auth / resource servers)

我怕爱的太早我们不能终老 提交于 2020-01-04 06:56:09
问题 I am desperately trying to find out why I keep getting a 401 response from my resource server: Scenario: Console program running an authorization server. Console program running a resource server. Console program using both (client). I have no problem getting the token, and it validates with expected content at jwt.io. Further, when submitting the base64 encoded secret used to create the token, the site also validates the token string. I have tried every possible combination of suppressing

How to handle former global event handlers in ASP.NET 5?

陌路散爱 提交于 2020-01-04 06:13:33
问题 Actually, we use ASP.NET 4.5 (VS 2013) and want to replace Global.asax.cs with new Startup.cs file, which comes from OWIN specification. We log the start and the end of application using Application_Start and Application_End handlers in this way: protected void Application_Start(object sender, EventArgs e) { _log.Info("The app starts."); } protected void Application_End(object sender, EventArgs e) { _log.Info("The app ends."); } But, as I know there is no such handlers in the new Startup.cs

How to handle former global event handlers in ASP.NET 5?

℡╲_俬逩灬. 提交于 2020-01-04 06:11:12
问题 Actually, we use ASP.NET 4.5 (VS 2013) and want to replace Global.asax.cs with new Startup.cs file, which comes from OWIN specification. We log the start and the end of application using Application_Start and Application_End handlers in this way: protected void Application_Start(object sender, EventArgs e) { _log.Info("The app starts."); } protected void Application_End(object sender, EventArgs e) { _log.Info("The app ends."); } But, as I know there is no such handlers in the new Startup.cs

How to mock HttpContext.Current.GetOwinContext() with Nunit and RhinoMocks?

大城市里の小女人 提交于 2020-01-04 04:06:34
问题 Compared to my last question on Mocking the HttpContext, I had to change the method being tested to public override void OnActionExecuting(HttpActionContext actionContext) { HttpContext.Current.GetOwinContext().Set("RequestGUID", NewId.NextGuid()); base.OnActionExecuting(actionContext); } Now I need to figure out how to mock the HttpContext.Current.GetOwinContext() , So I could write a stub for the Set() method, or generally being able to test this particular line. How can I do this? 回答1: I

Is Owin/Katana supposed to replace Web API? [closed]

℡╲_俬逩灬. 提交于 2020-01-03 16:48:46
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago . When ASP.NET MVC came, Microsoft announced many times in many places that it wasn't supposed to replace ASP.NET Web Forms. In other words, it's just another technology that you might find useful, or you might use Web Forms in other scenarios. However, as companies enter into

Why the required Startup class does't need to implement an appropriate interface, like IStartup?

拥有回忆 提交于 2020-01-03 13:01:45
问题 Using katana, why does the Startup class should not implement a respective interface, like for example: interface IStartup { void Configuration(IAppBuilder app); } public class MyStartup : IStartup { public void Configuration(IAppBuilder app) { ... } } I think that it could be much more intuitive for the developers to understand what they should provide with to the WebApp.Start<T> method as the T argument instead of guessing and looking for examples, it should be more explicit: public void

How to get access token from httpcontext using owin and Mvc 5

▼魔方 西西 提交于 2020-01-03 10:48:41
问题 I've got a IDP implemented in IdentityServer 4. My web app client(implemented in Mvc 5) authenticates with the IDP but now I need to get the access token from the request. A way to do that in .Net Core is to use the Microsoft.AspNetCore.Authentication.AuthenticationTokenExtensions like so: HttpContext.Authentication.GetTokenAsync("acccess_token") I would like to be able to do the same in my .net Mvc5 web app client but I can't find any nuget package or namespace that has a similar