Skip to content

Extending a session is not working #4441

@richarddavenport

Description

@richarddavenport

Preflight checklist

Ory Network Project

No response

Describe the bug

Version 1.2.0 but also tried 1.3.1
We self host and use asp.net for our backend.

We call toSession and then pass the session.id to the extendSession endpoint. In the database, I can see the session.expires_at is updated to the correct time. We also extend the expiration of the cookie to match the expiration.

Here's the problem: I set the lifespan to "1m" for testing. During the 1 minute we extend the session (up to this point everything seems to be accurate). After 1 minute the initial 1 minute lifespan has passed we call toSession and the endpoint gives us back this error:

{Ory.Client.Client.ApiException: Error calling ToSession: {"error":{"code":401,"status":"Unauthorized","reason":"No valid session credentials found in the request.","message":"The request could not be authorized"}}

   at Ory.Client.Api.FrontendApi.ToSessionWithHttpInfoAsync(String xSessionToken, String cookie, String tokenizeAs, CancellationToken cancellationToken)
   at Ory.Client.Api.FrontendApi.ToSessionAsync(String xSessionToken, String cookie, String tokenizeAs, CancellationToken cancellationToken)
   at MBP.Api.Services.KratosService.WhoAmI(String cookie) in /monorepo/MBP/Api/Services/KratosService.cs:line 73}

But we are sending the same cookie that worked a few seconds prior.
Any guidance would be very helpful. Thanks.

Reproducing the bug

Run kratos, get a session.
Try to extend the session.
Wait until the original lifespan would have expired.
Call toSession with the cookie and we get the error.

Relevant log output

Relevant configuration

session:
  lifespan: 1m
  earliest_possible_extend: 45s

Version

1.2.1

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Docker

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions