Skip to content

Commit 03b2829

Browse files
committed
Fix Expired Chain Doesn't Rotate on Successful Login
1 parent 8256d65 commit 03b2829

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

Binary file not shown.
Binary file not shown.

src/CodeBeam.UltimateAuth.Server/Flows/Login/LoginOrchestrator.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,15 @@ public async Task<LoginResult> LoginAsync(AuthFlowContext flow, LoginRequest req
131131
{
132132
var chain = await sessionStore.GetChainByDeviceAsync(userKey.Value, deviceId, ct);
133133

134-
if (chain is not null && !chain.IsRevoked)
135-
chainId = chain.ChainId;
134+
if (chain is not null)
135+
{
136+
var chainState = chain.GetState(now, _options.Session.IdleTimeout);
137+
138+
if (chainState == SessionState.Active)
139+
{
140+
chainId = chain.ChainId;
141+
}
142+
}
136143
}
137144

138145
// TODO: Add accountState here, currently it only checks factor state

src/CodeBeam.UltimateAuth.Server/Infrastructure/Issuers/UAuthSessionIssuer.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,13 @@ await kernel.ExecuteAsync(async _ =>
9292
//chain = await kernel.GetChainAsync(context.ChainId.Value)
9393
// ?? throw new UAuthNotFoundException("Chain not found.");
9494

95-
if (chain.IsRevoked)
96-
throw new UAuthValidationException("Chain revoked.");
95+
var chainState = chain.GetState(now, _options.Session.IdleTimeout);
96+
97+
if (chainState != SessionState.Active)
98+
throw new UAuthValidationException("Chain is not active.");
99+
100+
//if (chain.IsRevoked)
101+
// throw new UAuthValidationException("Chain revoked.");
97102

98103
if (chain.UserKey != context.UserKey || chain.Tenant != context.Tenant)
99104
throw new UAuthValidationException("Invalid chain ownership.");

0 commit comments

Comments
 (0)