asp.net - Owin AuthenticationMode Active and Passive for different path -


i'm using owin wsfederation authentication. unauthorized users want 1 path redirected sts , return 401 response. possible set different authenticationmode different path?

you can "fork" owin pipeline in order configure middleware differently different paths.

public void configuration(iappbuilder app) {     app.useerrorpage(new errorpageoptions());      app.map("active", active =>      {         active.useopenidconnectauthentication(             new openidconnectauthenticationoptions             {                 authenticationmode = authenticationmode.active                 //todo: add other options.             });     });      app.map("passive", passive =>     {         passive.useopenidconnectauthentication(             new openidconnectauthenticationoptions             {                 authenticationmode = authenticationmode.passive,                 //todo: add other options.             });     }); } 

this sample configures "error page" middleware run on requests, goes on create 2 url-mapped pipelines, 1 requests start /active , other paths start /passive. each of these mapped pipelines partially configure oidc authentication middleware, using active , passive modes respectively.

this mechanism designed let run different sets of middleware when requests come in on specific paths. put common middleware before mapped middleware make run on every request.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -