asp.net core - AuthenticationHandler ending request prematurely -




i'm trying make .net core authenticationhandler custom logic. whenever make request page in auth handler runs fine returns 200 without executing code end controller. i've distilled down simplified version.

startup.cs:

public void configureservices(iservicecollection services) {     services.addauthentication("dummy")         .addscheme<authenticationschemeoptions, dummyauthhandler>("dummy", null);     ... 

my handler:

public class dummyauthhandler : authenticationhandler<authenticationschemeoptions> {     public dummyauthhandler(ioptionsmonitor<authenticationschemeoptions> options,          iloggerfactory logger, urlencoder encoder, isystemclock clock) :              base(options, logger, encoder, clock)     {     }      protected override task<authenticateresult> handleauthenticateasync()         => task.fromresult(authenticateresult.success(                new authenticationticket(new claimsprincipal(), "dummy")));      protected override task handlechallengeasync(authenticationproperties properties)           => task.completedtask; } 

i'm thinking i'm missing 1 of methods needed tell framework continue processing request, , not think authentication handler wants page redirected. maybe need add call next() somewhere?

cracked this , this... claimsidentity returning isauthenticated = false, why thought needed handlechallengeasync in first place. here's fixed handler looks like:

public class dummyauthhandler : authenticationhandler<authenticationschemeoptions> {     public dummyauthhandler(ioptionsmonitor<authenticationschemeoptions> options,          iloggerfactory logger, urlencoder encoder, isystemclock clock) :              base(options, logger, encoder, clock)     {     }      protected override task<authenticateresult> handleauthenticateasync()         => task.fromresult(authenticateresult.success(                new authenticationticket(new claimsprincipal(                    new claimsidentity("abc")), "dummy"))); } 




wiki

Comments

Popular posts from this blog

python - Read npy file directly from S3 StreamingBody -

python - Minimize function with Scipy minimize -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -