Skip to content

fix: Parse Server option extendSessionOnUse not working for session lengths < 24 hours - #9113

Merged
mtrezza merged 6 commits into
parse-community:alphafrom
vivekjoshi556:issue_8981
May 27, 2024
Merged

mtrezza merged 6 commits into
parse-community:alphafrom
vivekjoshi556:issue_8981

Conversation

@vivekjoshi556

Copy link
Copy Markdown
Contributor

Pull Request

This PR helps with dynamically extending session based on session Length.

Issue

Closes: #8981

Approach

I followed a similar approach to what @mman suggested here.

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)

@parse-github-assistant

Copy link
Copy Markdown

Thanks for opening this pull request!

@vivekjoshi556

Copy link
Copy Markdown
Contributor Author

Hello @mman,
You mentioned that you would beta test. Please look at the solution and let me know what you think.

@codecov

codecov Bot commented May 1, 2024 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.15%. Comparing base (f1469c6) to head (57f8283).
Report is 13 commits behind head on alpha.

❗ Current head 57f8283 differs from pull request most recent head c99c48b

Please upload reports for the commit c99c48b to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##            alpha    #9113      +/-   ##
==========================================
+ Coverage   94.13%   94.15%   +0.01%     
==========================================
  Files         186      186              
  Lines       14687    14726      +39     
==========================================
+ Hits        13826    13865      +39     
  Misses        861      861              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mman

mman commented May 1, 2024

Copy link
Copy Markdown
Contributor

Thanks a lot @vivekjoshi556, I will take a look first thing next week, now OOO.

@vivekjoshi556

Copy link
Copy Markdown
Contributor Author

Hey @mman. Just wanted to check if you got some time to look at the PR.

@mman

mman commented May 6, 2024

Copy link
Copy Markdown
Contributor

@vivekjoshi556 The code looks nice and clean, the tests as well. Will try to deploy to my stage env later today.

@vivekjoshi556

Copy link
Copy Markdown
Contributor Author

Hey @mman Just wanted to check in again.

@mtrezza if you have inputs as well, please let me know.

There is a minor issue with linting I'll fix it in the next push, anything else let me know.

Comment thread src/Auth.js Resolved
Comment thread spec/Auth.spec.js Resolved
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
Comment thread src/Auth.js Resolved
@mtrezza

mtrezza commented May 10, 2024 •

Copy link
Copy Markdown
Member

This fix just shifts the problem downwards from 24 hours to 1 minute. Because for a session length of <1 minute, the problem in #8981 persists.

I wonder whether we need such a complex logic for this. If I understand #8981 (comment) correctly, the purpose of this logic is to find a middle ground between:

  • extending the session on every request --> con: high DB writes
  • ensuring that the session extends before it expires --> con: session would never get extended

Wouldn't it be simpler to extend the session when the remaining session token validity time reached < 50% of the session length?

For example:

  • session length 1 year --> session extends if remaining time is < 182 days
  • session length 1 day --> session extends if remaining time is < 12 hours
  • session length 1 hour --> session extends if remaining time is < 30 mins
  • session length 1 minute --> session extends if remaining time is < 30 secs

Pros:

  • Simple to document and understand
  • This adapts dynamically to the session length, instead of some arbitrary extension trigger times
  • It's easy to make this configurable via a new Parse Server option in the future, by letting a developer configure the threshold, e.g. 50% as in examples above.

And could you please document this new behavior in the Parse Server option extendSessionOnUse?

Comment thread spec/Auth.spec.js Resolved
@mtrezza mtrezza changed the title fix: ExtendSessionOnUse Updates fix: Parse Server option extendSessionOnUse not working for session lengths < 24 hours May 10, 2024
@mtrezza

mtrezza commented May 14, 2024 •

Copy link
Copy Markdown
Member

@vivekjoshi556 Just a friendly ping here; if you could simplify the logic and add the functionality description to the option docs (this repo, not the docs repo), then we could go ahead and merge.

@vivekjoshi556

Copy link
Copy Markdown
Contributor Author

So sorry just got a bit swamped with work. Give me some time

@vivekjoshi556

Copy link
Copy Markdown
Contributor Author

@mtrezza I have made the mentioned changes. Please let me know if anything else needs to be done.

Comment thread src/Options/index.js Resolved
Comment thread src/Options/docs.js Resolved
Comment thread src/Options/Definitions.js Resolved
Signed-off-by: Manuel <5673677+mtrezza@users.noreply.github.com>
@mtrezza
mtrezza merged commit 0a054e6 into parse-community:alpha May 27, 2024
parseplatformorg pushed a commit that referenced this pull request May 27, 2024
# [7.1.0-alpha.9](7.1.0-alpha.8...7.1.0-alpha.9) (2024-05-27)

### Bug Fixes

* Parse Server option `extendSessionOnUse` not working for session lengths < 24 hours ([#9113](#9113)) ([0a054e6](0a054e6))
@parseplatformorg

Copy link
Copy Markdown
Contributor

🎉 This change has been released in version 7.1.0-alpha.9

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label May 27, 2024
@mman

mman commented May 27, 2024

Copy link
Copy Markdown
Contributor

@vivekjoshi556 Excellent, very clean code, putting into production :)

@vivekjoshi556
vivekjoshi556 deleted the issue_8981 branch May 27, 2024 15:26
parseplatformorg pushed a commit that referenced this pull request Jun 30, 2024
# [7.1.0-beta.1](7.0.0...7.1.0-beta.1) (2024-06-30)

### Bug Fixes

* `Parse.Cloud.startJob` and `Parse.Push.send` not returning status ID when setting Parse Server option `directAccess: true` ([#8766](#8766)) ([5b0efb2](5b0efb2))
* `Required` option not handled correctly for special fields (File, GeoPoint, Polygon) on GraphQL API mutations ([#8915](#8915)) ([907ad42](907ad42))
* Facebook Limited Login not working due to incorrect domain in JWT validation ([#9122](#9122)) ([9d0bd2b](9d0bd2b))
* Live query throws error when constraint `notEqualTo` is set to `null` ([#8835](#8835)) ([11d3e48](11d3e48))
* Parse Server option `extendSessionOnUse` not working for session lengths < 24 hours ([#9113](#9113)) ([0a054e6](0a054e6))
* Rate limiting can fail when using Parse Server option `rateLimit.redisUrl` with clusters ([#8632](#8632)) ([c277739](c277739))
* SQL injection when using Parse Server with PostgreSQL; fixes security vulnerability [GHSA-c2hr-cqg6-8j6r](GHSA-c2hr-cqg6-8j6r) ([#9167](#9167)) ([2edf1e4](2edf1e4))

### Features

* Add `silent` log level for Cloud Code ([#8803](#8803)) ([5f81efb](5f81efb))
* Add server security check status `security.enableCheck` to Features Router ([#8679](#8679)) ([b07ec15](b07ec15))
* Prevent Parse Server start in case of unknown option in server configuration ([#8987](#8987)) ([8758e6a](8758e6a))
* Upgrade to @parse/push-adapter 6.0.0 ([#9066](#9066)) ([18bdbf8](18bdbf8))
* Upgrade to @parse/push-adapter 6.2.0 ([#9127](#9127)) ([ca20496](ca20496))
* Upgrade to Parse JS SDK 5.2.0 ([#9128](#9128)) ([665b8d5](665b8d5))
@parseplatformorg

Copy link
Copy Markdown
Contributor

🎉 This change has been released in version 7.1.0-beta.1

@parseplatformorg parseplatformorg added the state:released-beta Released as beta version label Jun 30, 2024
parseplatformorg pushed a commit that referenced this pull request Jun 30, 2024
# [7.1.0](7.0.0...7.1.0) (2024-06-30)

### Bug Fixes

* `Parse.Cloud.startJob` and `Parse.Push.send` not returning status ID when setting Parse Server option `directAccess: true` ([#8766](#8766)) ([5b0efb2](5b0efb2))
* `Required` option not handled correctly for special fields (File, GeoPoint, Polygon) on GraphQL API mutations ([#8915](#8915)) ([907ad42](907ad42))
* Facebook Limited Login not working due to incorrect domain in JWT validation ([#9122](#9122)) ([9d0bd2b](9d0bd2b))
* Live query throws error when constraint `notEqualTo` is set to `null` ([#8835](#8835)) ([11d3e48](11d3e48))
* Parse Server option `extendSessionOnUse` not working for session lengths < 24 hours ([#9113](#9113)) ([0a054e6](0a054e6))
* Rate limiting can fail when using Parse Server option `rateLimit.redisUrl` with clusters ([#8632](#8632)) ([c277739](c277739))
* SQL injection when using Parse Server with PostgreSQL; fixes security vulnerability [GHSA-c2hr-cqg6-8j6r](GHSA-c2hr-cqg6-8j6r) ([#9167](#9167)) ([2edf1e4](2edf1e4))

### Features

* Add `silent` log level for Cloud Code ([#8803](#8803)) ([5f81efb](5f81efb))
* Add server security check status `security.enableCheck` to Features Router ([#8679](#8679)) ([b07ec15](b07ec15))
* Prevent Parse Server start in case of unknown option in server configuration ([#8987](#8987)) ([8758e6a](8758e6a))
* Upgrade to @parse/push-adapter 6.0.0 ([#9066](#9066)) ([18bdbf8](18bdbf8))
* Upgrade to @parse/push-adapter 6.2.0 ([#9127](#9127)) ([ca20496](ca20496))
* Upgrade to Parse JS SDK 5.2.0 ([#9128](#9128)) ([665b8d5](665b8d5))
@parseplatformorg

Copy link
Copy Markdown
Contributor

🎉 This change has been released in version 7.1.0

@parseplatformorg parseplatformorg added the state:released Released as stable version label Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:released Released as stable version state:released-alpha Released as alpha version state:released-beta Released as beta version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

extendSessionOnUse not working as expected

4 participants