owin

Making OWIN use AssemblyResolved() assemblies

 ̄綄美尐妖づ 提交于 2019-12-24 03:32:36
问题 I have a console app that is using AppDomain.CurrentDomain.AssemblyResolve() to load unresolved assemblies. I'm wiring up the handler in a static constructor, and I'm logging every call to the handler. My console app is starting up a self-hosted webservice, using Microsoft.Owin.Hosting.WebApp.Start() . If I run the app with the following DLLs in the same directory as the .exe , the webservice works correctly: Microsoft.Owin.Diagnostics.dll Microsoft.Owin.dll Microsoft.Owin.Host.HttpListener

Self-hosted Owin, static files and authentication

孤街醉人 提交于 2019-12-24 03:06:02
问题 I need to embed a small Owin host in an Azure worker Role. I need to serve some static files, but a sub-directory should be password-protected. I couldn't find any good example on self-hosted apps with authentication. I'm trying to setup the following appBuilder: Func<CookieValidateIdentityContext, Task> validate = async context => { Logger.Trace("Access"); }; var authOptions = new CookieAuthenticationOptions { AuthenticationMode = AuthenticationMode.Active, AuthenticationType =

Integration testing ASP.NET WebAPI controllers that use bearer authentication with identityserver3

喜欢而已 提交于 2019-12-24 01:39:25
问题 I'm trying to integration test my web api controllers. The application uses JWTs to authenticate users against the resource server. To spool up the application, I'm using the TestServer found in Microsoft.OWIN.Testing. I can obtain a valid JWT by performing a login as a browser would do. I then proceed to add the JWT to the request as follows: request.AddHeader("Authorization", "Bearer " + accessToken.RawData); That header also arrives in the OWIN pipeline. However, all controllers protected

C# Google OAUTH2 using OWIN on Mono results in “System.Web.HttpException (0x80004005): headers have already been sent”

社会主义新天地 提交于 2019-12-24 01:13:16
问题 I've followed a number of tutorials for adding google OAUTH2 authentication to an existing MVC project, but I end up with the same issue involving a 404 to the client and the following trace generated: System.Web.HttpException (0x80004005): headers have already been sent at System.Web.HttpResponse.set_StatusCode (System.Int32 value) [0x00012] in <d31574f4ab6745f49b1626160268508f>:0 at System.Web.HttpResponseWrapper.set_StatusCode (System.Int32 value) [0x00000] in

Web app and web api authentication in same application

断了今生、忘了曾经 提交于 2019-12-24 00:47:16
问题 I have a web app MVC,using auth0 owin regular web app cookie based authentication. This web app also has webapis which is used internally in the application. However i have a requirement to call this webapis from outside the application. So i created a restclient and tried to implement jwtbearerauthentication in application (but cookie based on authentication still in place). Now when i call the webapi from other application it validates the bearer token gives no error however it redirects to

How do I inject dependency in owin startup class

回眸只為那壹抹淺笑 提交于 2019-12-24 00:42:18
问题 In my web api application I implemented OAuth2. On GrantResourceOwnerCredentials of ApplicationOAuthProvider I am calling my custom membership service to login and get the token.The problem is I have to inject the membership service into ApplicationOAuthProvider in order to use the service but it didn't allow it due to owinStartup class which don't support the parameter constructor.How do I inject/use my membership service in GrantResourceOwnerCredentials method. public class

Extending WebApi response using OWIN Middleware

随声附和 提交于 2019-12-23 23:13:14
问题 I have a WebApi project based on OWIN, and I wanted to extend the result of WebApi call with some additional data, for example add localization data to response. Initial idea was to inject that logic in a pipeline and once we get a result of API call I just have wrap that json with wrapper that will contain translation and some additional properties like time of execution. So I wrote my own middleware put it after UseWebApi() but it's not executed because WebApi doesn't call "Next" in case it

What to use instead of HttpContext when using OWIN without System.Web

馋奶兔 提交于 2019-12-23 19:20:03
问题 We currently have a NancyFx project that we have wired up using OWIN. We are not using System.Web and we need some place to put our context that lives for the life of a request other than HttpContext. We have started implementing the context on a thread static variable so we can access the context anywhere in the application but we are worried that using Async calls will lose this thread static context. What do you use as a static accessor in lue of HttpContext when you divorce yourself from

Elmah showing, “No OWIN authentication manager is associated with the request.”

怎甘沉沦 提交于 2019-12-23 12:14:41
问题 My elmah logs is showing this error. This is not happening with every requests. It happening intermittently. MVC 5.2, Web API 2.2, ASP.NET Identity 2 and Azure website is my environment. update: Here is my Startup.cs, OAuthOptions = new OAuthAuthorizationServerOptions() { AllowInsecureHttp = true, TokenEndpointPath = new PathString("/token"), AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(settings.AccessTokenExpireTimeSpanInMinutes), Provider = new MyAuthorizationServerProvider(),

MVC 5 with ASP.NET Identity - Get Claims when user logs in

回眸只為那壹抹淺笑 提交于 2019-12-23 11:09:11
问题 I am using OWIN 2.0, and after I log in a user, I want to retrieve an existing claim from the database but if I try to get the user's claims they are empty. If I put the same code in any of the subsequent controllers that gets called then the claims are there. It seems that the claims are not available until the next request after the initial login. Why is this? var claimsIdentity = User.Identity as ClaimsIdentity; var testClaim = claimsIdentity.Claims.Where(r => r.Type == "TestClaim")