owin

Get custom claims from a JWT using Owin

我的未来我决定 提交于 2019-12-04 06:35:55
问题 I'm using Owin with JWTBearerAuthentication to authorize users and validate their tokens. I'm doing it like this: public class Startup { public void Configuration(IAppBuilder app) { HttpConfiguration config = new HttpConfiguration(); config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); ConfigureOAuth(app); app.UseWebApi(config); } private void ConfigureOAuth(IAppBuilder app) {

What is the process that makes IIS start responding to requests through the Owin pipeline?

有些话、适合烂在心里 提交于 2019-12-04 06:16:07
If you create an empty ASP.NET Web Application project in Visual Studio 2013 open the package manager console and install-package Microsoft.Owin.Host.SystemWeb Add a Startup class with a Configuration(IAppBuilder app) method, for example: public class Startup { public void Configuration(IAppBuilder app) { app.Run(context => context.Response.WriteAsync("hello")); } } And run, you'll see hello show up in the browser. However, it you look at the project, there's no change to any files, namely to web.config, that indicates that the Owin pipeline is being used. More importantly, if you have the

OWIN Cookies vs FormsAuthentication

こ雲淡風輕ζ 提交于 2019-12-04 05:08:15
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 portion of the ticket I was able to implement universal sign out, store custom properties, etc. One of

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

ε祈祈猫儿з 提交于 2019-12-04 05:07:27
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 this.Ok(); } [HttpGet] public IHttpActionResult GetContext(string provider) { if (HttpContext.Current

MVC 5 ASP.NET Identity 2: Capture user's preference for “remember me” in ExternalLogin

夙愿已清 提交于 2019-12-04 04:43:57
问题 I am using the Identity 2.0 Sample. I get that by setting isPersistent to true in ExternalLoginCallback action method, the browser will automatically log the user in the next time (within limits) they visit using the same browser. I know that if the user's "remember me" preference was captured and passed to the ExternalLogin action method that it could be put into returnUrl and accessed in ExternalLoginCallback. But how do I get their preference to the ExternalLogin action method? I don't get

Host Web API as Windows Service using OWIN

不羁的心 提交于 2019-12-04 03:52:19
I'm trying to run a Web API application as a Windows Service using OWIN. However, I get the following message, when trying to start the service: The [ServiceName] service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs. For some reason my service doesn't understand that it should keep listening to http://localhost:9000 The VS solution consists of two projects: The Web API and the Windows service. In the Windows service project I have: static class Program { static void Main() { ServiceBase[] ServicesToRun;

No conversion available between HelloWorldComponent and System.Func`2[System.Collections.Generic.IDictionary`2 // Parameter name: signature

橙三吉。 提交于 2019-12-04 03:35:36
问题 I am working through Scott Allen's MVC 5 Fundamentals course on Pluralsight I get an error at "using (WebApp.Start(uri)) " in the code below. The error is An unhandled exception of type 'System.ArgumentException' occurred in Microsoft.Owin.dll System.ArgumentException was unhandled HResult=-2147024809 Message=No conversion available between ConsoleApplication1.HelloWorldComponent and System.Func`2[System.Collections.Generic.IDictionary`2[System.String,System.Object],System.Threading.Tasks

OWIN OpenID connect authorization fails to authorize secured controller / actions

China☆狼群 提交于 2019-12-04 03:08:58
I am working on a project where a third party provider will act as an Oauth2 based Authorization Server. An Asp.net MVC 5 based client which will send the user to the authorization server to authenticate (using login / password) and the auth server will return an access token back to the MVC client. Any further calls to resource servers (APIs) will be made using the access token. To achieve this I am using Microsoft.Owin.Security.OpenIdConnect and the UseOpenIdConnectAuthentication extension. I am able to successfully redirect and get the access token from the auth server but the client is not

SignalR Websocket Exception when closing client

拈花ヽ惹草 提交于 2019-12-04 03:05:10
When starting and stopping a SignalR client that is connected to a basic self hosted server like this: async public void Start(string url) { _connection = new HubConnection(url); _proxy = _connection.CreateHubProxy("hubname"); await _connection.Start().ContinueWith((task) => IsRunning = true); } public void Stop() { _connection.Stop(); } I get the following exception when calling the "Stop" method (including trace messages): SignalR.Transports.TransportHeartBeat Verbose: 0 : KeepAlive(c75fe282-a86d-406a-935b-5981b47bd472) SignalR.Transports.TransportHeartBeat Information: 0 : Connection

The name 'ConfigureAuth' does not exist in the current contex

北城余情 提交于 2019-12-04 03:03:35
I'm getting an error when I'm attempting to run my page says that, The name 'ConfigureAuth' does not exist in the current context in my Stratup Class. I'm sure all AspNet Identity libraries are installed. What do I need to do next, to try to fix this? using Microsoft.Owin; using Owin; [assembly: OwinStartupAttribute(typeof(project_name.Startup))] namespace project_name { public partial class Startup { public void Configuration(IAppBuilder app) { ConfigureAuth(app); } } } If you are using default Visual Studio project template, the ConfigureAuth method could be found in partial class Startup