Skip to content

Commit fe71f62

Browse files
committed
IAuthWithRequest requests don't need to clear sessions
1 parent 8e999a4 commit fe71f62

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

ServiceStack/src/ServiceStack/Auth/AuthenticateService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,11 @@ private async Task<object> AuthenticateAsync(Authenticate request, string provid
503503
return null; //Just return sessionInfo if no provider or username is given
504504

505505
var authFeature = GetPlugin<AuthFeature>();
506-
if (authFeature?.HasSessionFeature == true)
506+
if (authFeature?.HasSessionFeature == true && oAuthConfig is not IAuthWithRequest)
507507
{
508508
var generateNewCookies = authFeature.GenerateNewSessionCookiesOnAuthentication
509509
//keep existing session during OAuth flow
510510
&& string.IsNullOrEmpty(Request.QueryString["oauth_token"])
511-
&& string.IsNullOrEmpty(Request.QueryString["State"])
512511
&& string.IsNullOrEmpty(Request.QueryString["state"]);
513512

514513
if (generateNewCookies)

ServiceStack/src/ServiceStack/Auth/BasicAuthProvider.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,9 @@ public virtual async Task PreAuthenticateAsync(IRequest req, IResponse res)
6666
}).ConfigAwait();
6767
}
6868
}
69+
70+
protected override Task<IAuthSession> ResetSessionBeforeLoginAsync(IServiceBase authService, IAuthSession session, string userName, CancellationToken token=default)
71+
{
72+
return Task.FromResult(session);
73+
}
6974
}

0 commit comments

Comments
 (0)