owin

AuthenticationManager.GetExternalLoginInfo returns null except in ExternalLoginCallback

空扰寡人 提交于 2019-12-12 21:51:54
问题 I am using the standard MVC template in VS2013 and have enabled external logins. It works fine, and I am now adding some features. I find that AuthenticationManager.GetExternalLoginInfo works fine in the ExternalLoginCallback action. However, if I have it anywhere else, it always returns null, even if the user is logged in. I did a test by adding the following in the Account controller: [Authorize] public async Task<ActionResult> Test() { Debug.Assert(User.Identity.IsAuthenticated); var

Stop IResponseCookies.Append() from encoding cookies. dotnetcore 2.0 [duplicate]

℡╲_俬逩灬. 提交于 2019-12-12 17:22:30
问题 This question already has an answer here : Stop url encoding cookie (1 answer) Closed last year . We are building a dotnetcore 2.0 web app that receiving cookies from a legacy system via http and setting the cookies in the response. When I debug the app I can see that cookie.value is not url encoded but after calling append the set-cookie headers are url encoded. This is problematic as the legacy cookies need to be unencoded as legacy apps read them as they are. public static void AddCookie

Can a client cancel a Web Api request?

若如初见. 提交于 2019-12-12 16:26:19
问题 I have the following method in my web api controller (the long running methods honor cancellation tokens, i.e. they won't run if cancellation has been requested): public async Task<IHttpActionResult> ApiMethod(CancellationToken cancellationToken) { await LongRunningNetworkOperation1(cancellationToken); await LongRunningNetworkOperation2(cancellationToken); return Ok(); } The client has the following code to call my web api controller: using (var httpClient = new HttpClient()) { httpClient

Register MicroServices in Azure Active Directory (AAD) for Security

僤鯓⒐⒋嵵緔 提交于 2019-12-12 15:18:18
问题 I have a service fabric application (Stateless and Statefull) deployed in Service fabric cluster. I am trying to implement security in the applications. The application uses the Active Directory Authentication Library (ADAL) to get a token from Azure AD using the OAuth 2.0 client credential flow, where the client credential is a password. I am able to implement the same scenario in ordinary web api applications by registering them in Azure portal. Can anyone tell me how to register a service

Mono with Owin Authentication

杀马特。学长 韩版系。学妹 提交于 2019-12-12 15:01:45
问题 I have an Owin application I'm running in Mono, and I'm trying to get authentication to work properly on it. I used the info on this page as a start. I quickly realized that Owin Authentication uses some Windows specific libraries. This question had a workaround for that, though, which I thought would be enough. It wasn't. The following code throws the exception described in the other question (in another place than the question describes (see comment in code)). If I try to comment out stuff

C#: modifying Owin response stream causes AccessViolationException

余生长醉 提交于 2019-12-12 14:16:25
问题 I'm attempting to use some custom Owin middleware to modify (in this case, completely replace) the response stream in specific circumstances. Anytime I make a call that does trigger my middleware to replace the response, everything works properly. The problem only occurs when I make a call that my middleware does not make changes to. Additionally, I have only been able to get the error to occur when the API call that is not being replaced is returning a manually created HttpResponseMessage

How do I integration test a ASP 5/Core Web API with [Authorize] Attributes

点点圈 提交于 2019-12-12 11:28:59
问题 I currently have an ASP 5/ASP Core Web API that I need to integration test with the OWIN Test Server. The problem is that I use IdentityServer as the authorization server in production and I do not want to include the authorization as part of my integration testing. This is the Startup.cs of the API: public Startup(IHostingEnvironment env) { // Set up configuration sources. IConfigurationBuilder builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.

Capturing login event so I can cache other user information

半腔热情 提交于 2019-12-12 10:44:16
问题 I've built a web application. When I built it I ticked 'Organizational Accounts' It works well - I log in with my Office 365 account and User.Identity.Name contains the email address This application is a replacement front end for an older ASP Classic app. The App has an existing security table that I need to use. I want to use the email address to look up a record in this table to get The internal database key for the user (so I can use it in database calls) The security level (authorisation

Can I enable tracing in OWIN?

限于喜欢 提交于 2019-12-12 09:31:45
问题 I have an environmental problem somewhere in OWIN and I want to get some information about what is happening. I have read that I can enable tracing but can't find much information on how to do it. I have added the following to my web.config but no joy. Is this possible? <!-- 1. Enable the switch here. Without this, you get nothing. By default, Katana has "new SourceSwitch("Microsoft.Owin")" at the root level. --> <switches> <add name="Microsoft.Owin" value="Verbose" /> </switches> <!-- 2. Add

Owin SelfHost WebApi - client closing the connection during response raises an exception?

梦想与她 提交于 2019-12-12 08:23:32
问题 I'm running an Owin Selfhost based WebApi where i've put in an API unhandled exception logger via config.Services.Add(typeof(IExceptionLogger), _apiExceptionLogger); Relevant part of ApiExceptionLogger: public override void Log(ExceptionLoggerContext context) { if (context == null || context.ExceptionContext == null) return; Logger.Error("Unhandled exception from Web API", context.ExceptionContext.Exception); } The cases it's catching and logging regularly are ones where the client requests a