Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement TOTP inmemory classes #564

Merged
merged 45 commits into from
Mar 27, 2023
Merged

feat: Implement TOTP inmemory classes #564

merged 45 commits into from
Mar 27, 2023

Conversation

KShivendu
Copy link
Contributor

@KShivendu KShivendu commented Feb 10, 2023

Summary of change

Implement TOTP inmemory classes

Related issues

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your
changes work. Bonus points for screenshots and videos!)

Documentation changes

(If relevant, please create a PR in our docs repo, or create a checklist here
highlighting the necessary changes)

Checklist for important updates

  • Changelog has been updated
    • If there are any db schema changes, mention those changes clearly
  • coreDriverInterfaceSupported.json file has been updated (if needed)
  • pluginInterfaceSupported.json file has been updated (if needed)
  • Changes to the version if needed
    • In build.gradle
  • If added a new paid feature, edit the getPaidFeatureStats function in FeatureFlag.java file
  • Had installed and ran the pre-commit hook
  • If there are new dependencies that have been added in build.gradle, please make sure to add them
    in implementationDependencies.json.
  • Issue this PR against the latest non released version branch.
    • To know which one it is, run find the latest released tag (git tag) in the format vX.Y.Z, and then find the
      latest branch (git branch --all) whose X.Y is greater than the latest released tag.
    • If no such branch exists, then create one from the latest released branch.

TODO

  • Cronjob to removed expired codes
  • Add feature flag check and usage stats (send MAU - will require mod to session to keep track of last active time)
    • we should also count one MAU if they just sign in / up and not create a session.
    • We need -> number of monthly active users, number of active users who have enabled totp, number of total users who have enabled totp.
  • Delete user code needs to change to remove totp info for the user.

@KShivendu KShivendu changed the base branch from master to 4.3 February 10, 2023 07:14
.github/ISSUE_TEMPLATE/release.md Outdated Show resolved Hide resolved
src/main/java/io/supertokens/inmemorydb/Start.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/inmemorydb/Start.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/inmemorydb/Start.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/inmemorydb/Start.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/inmemorydb/Start.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
- Add created_time_ms
- Run cron to delete expired used tokens
- Add feature to delete all TOTP data on user deletion
- Simulate foreign key constraint in totp_used_codes for inmemorydb
- Refactor and clean TOTP.java code
- Use java-totp to generate secret key and verify code
- Add and update tests
- Add config for totp_rate_limit_window_size
- Improve function names and return types
- Use `is_valid` for totp_used_code
- Expose function to generate TOTP code for tests to use
Every used code is only linked to the user now. No concept of code
to device linking. So removed device_name.
src/main/java/io/supertokens/config/CoreConfig.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/config/CoreConfig.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/inmemorydb/Start.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
build.gradle Show resolved Hide resolved
- Improve rate limiting and device removal logic
- Add config for TOTP rate limting
- Properly use transactions
- Add/update tests
- Use device period in totp generation and validation
- Add tests to cover most edge cases of Totp.java
- Fix overriding of  totp_rate_limit_cooldown_sec
- Add tests for TOTP cron
- Add comments for edge cases and readability
- Introduce totp_invalid_code_expiry_sec config
- Query all codes instead of only expired ones
- Remove redundant deleteAllDataForUser from TOTPQueries
- Move TOTP code generation to tests
- Add logging to DeleteExpriedTotoTokens cron
CHANGELOG.md Show resolved Hide resolved
src/main/java/io/supertokens/totp/Totp.java Outdated Show resolved Hide resolved
* feat: Add support for active users stats

* feat: Monitor active users for all auth recipes and session recipe
)

* test: Add tests for active users update across different API calls

* fix: Suppress usermapping exceptions for active users monitoring (#587)
* feat: Make TOTP a paid feature and report stats

* test: Add test for TOTP usage stats

* refactor: MAU should be sent irrespective of TOTP

* refactor: Use internal supertokens user id in TOTP APIs (#591)

* refactor: Use internal supertokens user id in TOTP APIs

* test: Add test for user id mapping in TOTP APIs
KShivendu and others added 2 commits March 23, 2023 21:25
* feat: Check TOTP feature flag in TOTP recipe functions

* feat: Test feature flag error is handled by APIs
CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
@KShivendu KShivendu mentioned this pull request Mar 27, 2023
9 tasks
* test: Fix failing tests

* fixes tests

---------

Co-authored-by: rishabhpoddar <rishabh.poddar@gmail.com>
@rishabhpoddar rishabhpoddar changed the base branch from 4.4 to 4.5 March 27, 2023 15:09
KShivendu and others added 2 commits March 27, 2023 21:37
* feat: Add new API and tests for counting active users

* chores: Update CHANGELOG to mention new active user count API

* test: Add bad input tests for active users count API

* chores: Update the http method for active user count API in CHANGELOG
@rishabhpoddar rishabhpoddar merged commit 3e6c4a6 into 4.5 Mar 27, 2023
@rishabhpoddar rishabhpoddar deleted the feat/totp-inmemory branch March 27, 2023 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants