External Cookie for External Login in ASP.NET OWIN -


we have legacy system built on asp.net mvc 4, support signal sign on via azure active directory current users new users. since have managed our own authentication workflow, asp.net identity not fit in our case.

i have managed build demo working on owin openidconnect middleware passive mode without using asp.net identity. below code works correctly:

app.setdefaultsigninasauthenticationtype("externalcookie"); app.usecookieauthentication(new cookieauthenticationoptions {     authenticationtype = "externalcookie",     authenticationmode = authenticationmode.passive, });  app.useopenidconnectauthentication(     new openidconnectauthenticationoptions     {         authenticationmode = authenticationmode.passive,         clientid = clientid,         authority = authority          // more code     }); 

and in externallogincallback action:

public async task<actionresult> externallogincallback(string returnurl) {     var authmanager = request.getowincontext().authentication;      var result = await authmanager.authenticateasync("externalcookie");     authmanager.signout("externalcookie");      //more code convert local identity } 

this case common using other providers google, facebook or twitter. 1 thing have not clear externalcookie, maybe have missed whole thing. understanding when external login successfully, external cookie used store external claim identity. , call:

var result = await authmanager.authenticateasync("externalcookie"); authmanager.signout("externalcookie"); 

in order external claim identity , convert external identity local identity. have little bit confusion why have call signout external cookie in case.

also, i'm not sure whether external cookie must when using external login, or have other ways around without using external cookie.

please give explanation on point.

to answer last question, change name of cookie in startup.auth file configure external cookie -

app.useexternalsignincookie(defaultauthenticationtypes.externalcookie); 

you can use string instead of defaultauthenticationtypes enum , directly specify name of cookie -

app.useexternalsignincookie("myexternalcookie");