Skip to content

Commit 76a165b

Browse files
rishabhpoddarjscyo
andauthored
Ee feature flag (supertokens#533)
* adds empty ee module * changes to runBuild to add ee jar * adds ee built jar * adds test function to ee module * removes test function * adds skeleton logic for feature flag * fixes a bug related to no syncing on init * makes logic simpler * renames * improves code flow * adds a TODO * adds logic for querying API and also for formatting code for sub modules of the core * adds comments about all scenarios of api and db liveness * adds TODOs for long term future changes * changes ee to be dynamically loaded instead of statically * adds ee jar initially * adds ee stuff to downloader * updates contributing guide * gets ee package to dynamically load in the core * modifies a comment * adds a small TODO comment in test * changes logging message * changes copyright and adds storage layer to EE * clarifies some TODOs * adds core version and telemetry ID to license key sync API * adds telemetry ID on core startup * adds code for license check cronjob * fails core start if licese check in db fails * refactors and removes some old TODOs * adds API to load license key * renames file * refactors and adds skeleton for airgapped license check * adds more APIs for ee stuff * adds new API to get enabled features * adds logger * adds logging * refactors code * adds a TODO comment * fixes small bug * adds s TODO * adds more API and skeleton for paid feature * adds db queries * adds JWT verification code * removes unnecessary code * small fix * fixes a bug * changes license check path * small change * adds public key info for stateless lilcense key * changes public key * adds a TODO and adds test feature * removes TODO * Ee feature flag tests (supertokens#545) * inital commit * adds some basic tests * adds more test * small changes * small changes * small changes * reverses dependency * moves ee test to ee folder * adds test files to ee folder Co-authored-by: rishabhpoddar <[email protected]> * removes wrong copyright from ee folder files * adds a few tests * adds more tests * adds more tests * adds JWT parsing test * adds more tests * removes unnecessary comment * adds more tests * more tests * small bug fix * adds more tests * adds test keys * adds more test keys * modifies one test * removes unnecesary logging and refactors function name * adds more tests * more tests * adds more tests * adds more tests * more tests * fixes a bug * adds more tests * fixes test for in mem * fixes bug in test * test: Adds API tests for EE feature flag (supertokens#547) * starts adding tests * adds more tests * adds more SetLicenseKeyAPITests * adds more tests * fixes * fixes * implements feedback * fixes * updates licenses, cdi version and changelog Co-authored-by: Joel Coutinho <[email protected]>
1 parent d17d839 commit 76a165b

File tree

57 files changed

+4092
-189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+4092
-189
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+17-6
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,40 @@
11
## Summary of change
2+
23
(A few sentences about this PR)
34

45
## Related issues
6+
57
- Link to issue1 here
68
- Link to issue1 here
79

810
## Test Plan
9-
(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!)
11+
12+
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your
13+
changes work. Bonus points for screenshots and videos!)
1014

1115
## Documentation changes
12-
(If relevant, please create a PR in our [docs repo](https://github.com/supertokens/docs), or create a checklist here highlighting the necessary changes)
16+
17+
(If relevant, please create a PR in our [docs repo](https://github.com/supertokens/docs), or create a checklist here
18+
highlighting the necessary changes)
1319

1420
## Checklist for important updates
21+
1522
- [ ] Changelog has been updated
1623
- [ ] If there are any db schema changes, mention those changes clearly
1724
- [ ] `coreDriverInterfaceSupported.json` file has been updated (if needed)
1825
- [ ] `pluginInterfaceSupported.json` file has been updated (if needed)
1926
- [ ] Changes to the version if needed
20-
- In `build.gradle`
27+
- In `build.gradle`
28+
- [ ] If added a new paid feature, edit the `getPaidFeatureStats` function in FeatureFlag.java file
2129
- [ ] Had installed and ran the pre-commit hook
22-
- [ ] If there are new dependencies that have been added in `build.gradle`, please make sure to add them in `implementationDependencies.json`.
30+
- [ ] If there are new dependencies that have been added in `build.gradle`, please make sure to add them
31+
in `implementationDependencies.json`.
2332
- [ ] Issue this PR against the latest non released version branch.
24-
- 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.
25-
- If no such branch exists, then create one from the latest released branch.
33+
- To know which one it is, run find the latest released tag (`git tag`) in the format `vX.Y.Z`, and then find the
34+
latest branch (`git branch --all`) whose `X.Y` is greater than the latest released tag.
35+
- If no such branch exists, then create one from the latest released branch.
2636

2737
## Remaining TODOs for this PR
38+
2839
- [ ] Item1
2940
- [ ] Item2

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ gradle-app.setting
1111
!jar/**/*.jar
1212
!cli/jar/**/*.jar
1313
!downloader/jar/**/*.jar
14+
!ee/jar/**/*.jar
1415

1516
*target*
1617
*.war

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [unreleased]
99

10+
## [4.3.0] - 2023-01-05
11+
12+
- Adds feature flag, ee folder and APIs to add / remove license keys for enterprise features.
13+
1014
## [4.2.1] - 2022-11-24
1115

1216
- Updates the type of `access_token_validity` in the CoreConfig from `int` to `long`

CONTRIBUTING.md

+80-45
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,154 @@
11
# Contributing
22

3-
We're so excited you're interested in helping with SuperTokens! We are happy to help you get started, even if you don't have any previous open-source experience :blush:
3+
We're so excited you're interested in helping with SuperTokens! We are happy to help you get started, even if you don't
4+
have any previous open-source experience :blush:
45

56
## New to Open Source?
6-
1. Take a look at [How to Contribute to an Open Source Project on GitHub](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github)
7-
2. Go through the [SuperTokens Code of Conduct](https://github.com/supertokens/supertokens-core/blob/master/CODE_OF_CONDUCT.md)
7+
8+
1. Take a look
9+
at [How to Contribute to an Open Source Project on GitHub](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github)
10+
2. Go through
11+
the [SuperTokens Code of Conduct](https://github.com/supertokens/supertokens-core/blob/master/CODE_OF_CONDUCT.md)
812

913
## Where to ask Questions?
10-
1. Check our [Github Issues](https://github.com/supertokens/supertokens-core/issues) to see if someone has already answered your question.
11-
2. Join our community on [Discord](https://supertokens.io/discord) and feel free to ask us your questions
1214

13-
As you gain experience with SuperTokens, please help answer other people's questions! :pray:
15+
1. Check our [Github Issues](https://github.com/supertokens/supertokens-core/issues) to see if someone has already
16+
answered your question.
17+
2. Join our community on [Discord](https://supertokens.io/discord) and feel free to ask us your questions
18+
19+
As you gain experience with SuperTokens, please help answer other people's questions! :pray:
1420

1521
## What to Work On?
22+
1623
You can get started by taking a look at our [Github issues](https://github.com/supertokens/supertokens-core/issues)
17-
If you find one that looks interesting and no one else is already working on it, comment in the issue that you are going to work on it.
24+
If you find one that looks interesting and no one else is already working on it, comment in the issue that you are going
25+
to work on it.
1826

19-
Please ask as many questions as you need, either directly in the issue or on [Discord](https://supertokens.io/discord). We're happy to help!:raised_hands:
27+
Please ask as many questions as you need, either directly in the issue or on [Discord](https://supertokens.io/discord).
28+
We're happy to help!:raised_hands:
2029

21-
### Contributions that are ALWAYS welcome
30+
### Contributions that are ALWAYS welcome
2231

2332
1. More tests
24-
2. Contributing to discussions that can be found [here](https://github.com/supertokens/supertokens-core/issues?q=is%3Aissue+is%3Aopen+label%3Adiscussions)
33+
2. Contributing to discussions that can be
34+
found [here](https://github.com/supertokens/supertokens-core/issues?q=is%3Aissue+is%3Aopen+label%3Adiscussions)
2535
3. Improved error messages
2636
4. Educational content like blogs, videos, courses
2737

28-
2938
## Development Setup
3039

3140
### With Gitpod
41+
3242
1. Navigate to the [supertokens-root](https://github.com/supertokens/supertokens-root) repository
3343
2. Click on the `Open in Gitpod` button
3444

3545
### Local Setup Prerequisites
46+
3647
- OS: Linux or macOS. Or if using Windows, you need to use [wsl2](https://docs.microsoft.com/en-us/windows/wsl/about).
37-
- JDK: openjdk 15.0.1. Installation instructions for Mac and Linux can be found in [our wiki](https://github.com/supertokens/supertokens-core/wiki/Installing-OpenJDK-for-Mac-and-Linux)
48+
- JDK: openjdk 15.0.1. Installation instructions for Mac and Linux can be found
49+
in [our wiki](https://github.com/supertokens/supertokens-core/wiki/Installing-OpenJDK-for-Mac-and-Linux)
3850
- IDE: [IntelliJ](https://www.jetbrains.com/idea/download/)(recommended) or equivalent IDE
3951

4052
### Familiarize yourself with SuperTokens
53+
4154
1. [Architecture of SuperTokens](https://github.com/supertokens/supertokens-core/wiki/SuperTokens-Architecture)
4255
2. [SuperTokens code and file structure overview](https://github.com/supertokens/supertokens-core/wiki/Code-and-file-structure-overview)
4356
3. [Versioning methodology](https://github.com/supertokens/supertokens-core/wiki/Versioning,-git-and-releases)
4457

45-
4658
### Project Setup
47-
1. Fork the [supertokens-core](https://github.com/supertokens/supertokens-core) repository (**Skip this step if you are NOT modifying supertokens-core**)
59+
60+
1. Fork the [supertokens-core](https://github.com/supertokens/supertokens-core) repository (**Skip this step if you are
61+
NOT modifying supertokens-core**)
4862
2. `git clone https://github.com/supertokens/supertokens-root.git`
4963
3. `cd supertokens-root`
5064
4. Open the `modules.txt` file in an editor (**Skip this step if you are NOT modifying supertokens-core**):
51-
- The `modules.txt` file contains the core, plugin-interface, the type of plugin and their branches(versions)
52-
- By default the `master` branch is used but you can change the branch depending on which version you want to modify
65+
- The `modules.txt` file contains the core, plugin-interface, the type of plugin and their branches(versions)
66+
- By default the `master` branch is used but you can change the branch depending on which version you want to modify
5367
- The `sqlite-plugin` is used as the default plugin as it is an in-memory database and requires no setup
54-
- [core](https://github.com/supertokens/supertokens-core)
55-
- [plugin-interface](https://github.com/supertokens/supertokens-plugin-interface)
56-
- Check the repository branches by clicking on the links listed above, click the branch tab and check for all the available versions
68+
- [core](https://github.com/supertokens/supertokens-core)
69+
- [plugin-interface](https://github.com/supertokens/supertokens-plugin-interface)
70+
- Check the repository branches by clicking on the links listed above, click the branch tab and check for all
71+
the available versions
5772
- Add your github `username` separated by a ',' after `core,master` in `modules.txt`
58-
- If, for example, your github `username` is `helloworld` then modules.txt should look like...
73+
- If, for example, your github `username` is `helloworld` then modules.txt should look like...
5974
```
6075
// put module name like module name,branch name,github username(if contributing with a forked repository) and then call ./loadModules script
6176
core,master,helloworld
6277
plugin-interface,master
6378
sqlite-plugin,master
6479
```
65-
66-
5. Run loadModules to clone the required repositories
67-
`./loadModules`
6880
81+
5. Run loadModules to clone the required repositories
82+
`./loadModules`
6983
7084
## Modifying code
85+
7186
1. Open `supetokens-root` in your IDE
72-
2. After gradle has imported all the dependencies you can start modifying the code
87+
2. After gradle has imported all the dependencies you can start modifying the code
7388
74-
## Testing
89+
## Testing
7590
7691
### On your local machine
77-
1. Navigate to the `supertokens-root` repository
92+
93+
1. Navigate to the `supertokens-root` repository
7894
2. Run all tests
79-
`./startTestEnv`
80-
3. If all tests pass the terminal should display
95+
`./startTestEnv`
96+
3. If all tests pass the terminal should display
97+
8198
- core tests:
82-
![core tests passing](https://github.com/supertokens/supertokens-logo/blob/master/images/core-tests-passing.png)
99+
![core tests passing](https://github.com/supertokens/supertokens-logo/blob/master/images/core-tests-passing.png)
83100
- plugin tests:
84-
![plugin tests passing](https://github.com/supertokens/supertokens-logo/blob/master/images/plugin-tests-passing.png)
101+
![plugin tests passing](https://github.com/supertokens/supertokens-logo/blob/master/images/plugin-tests-passing.png)
85102
86103
### Using github actions
104+
87105
1. Go to the supertokens-core repo on github (or your forked version of it).
88106
2. Navigate to the Actions tab.
89107
3. Find the action named "Run tests" and navigate to it.
90108
4. Click on the "Run workflow" button.
91109
5. Set the config variables in the drop down:
92-
- **supertokens-plugin-interface repo owner name**: If you have forked the supertokens-plugin-interface repo, then set the value of this to your github username.
93-
- **supertokens-plugin-interface repos branch name**: If the core version you are working on is compatible with a plugin-interface version that is not in the master branch, then set the correct branch name in this value.
110+
- **supertokens-plugin-interface repo owner name**: If you have forked the supertokens-plugin-interface repo, then
111+
set the value of this to your github username.
112+
- **supertokens-plugin-interface repos branch name**: If the core version you are working on is compatible with a
113+
plugin-interface version that is not in the master branch, then set the correct branch name in this value.
94114
6. Click on "Run workflow".
95115
96116
## Running the core manually
117+
97118
1. Run `startTestEnv --wait` in a terminal, and keep it running
98119
2. Then open `supertokens-root` in another terminal and run `cp ./temp/config.yaml .`
99-
3. Then run `java -classpath "./core/*:./plugin-interface/*" io.supertokens.Main ./ DEV`. This will start the core to listen on `http://localhost:3567`
120+
3. Then run `java -classpath "./core/*:./plugin-interface/*:./ee/*" io.supertokens.Main ./ DEV`. This will start the
121+
core to listen on `http://localhost:3567`
100122
101123
## Pull Request
102-
1. Before submitting a pull request make sure all tests have passed
103-
2. Reference the relevant issue or pull request and give a clear description of changes/features added when submitting a pull request
124+
125+
1. Before submitting a pull request make sure all tests have passed
126+
2. Reference the relevant issue or pull request and give a clear description of changes/features added when submitting a
127+
pull request
104128
3. Make sure the PR title follows [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) specification
105129
106-
## SuperTokens Community
107-
SuperTokens is made possible by a passionate team and a strong community of developers. If you have any questions or would like to get more involved in the SuperTokens community you can check out:
108-
- [Github Issues](https://github.com/supertokens/supertokens-core/issues)
109-
- [Discord](https://supertokens.io/discord)
110-
- [Twitter](https://twitter.com/supertokensio)
111-
- or [email us](mailto:[email protected])
112-
130+
## Install the supertokens CLI manually
131+
132+
1. Setup test env and keep it running
133+
2. In `supertokens-root`, run `cp temp/config.yaml .`
134+
3. On a different terminal, go to `supertokens-root` folder and
135+
run `java -classpath "./cli/*" io.supertokens.cli.Main true install`
136+
137+
## SuperTokens Community
138+
139+
SuperTokens is made possible by a passionate team and a strong community of developers. If you have any questions or
140+
would like to get more involved in the SuperTokens community you can check out:
141+
142+
- [Github Issues](https://github.com/supertokens/supertokens-core/issues)
143+
- [Discord](https://supertokens.io/discord)
144+
- [Twitter](https://twitter.com/supertokensio)
145+
- or [email us](mailto:[email protected])
146+
113147
Additional resources you might find useful:
114-
- [SuperTokens Docs](https://supertokens.io/docs/community/getting-started/installation)
115-
- [Blog Posts](https://supertokens.io/blog/)
116-
- [Development guideline for the backend and frontend recipes](https://github.com/supertokens/supertokens-core/wiki/Development-guideline-for-the-backend-and-frontend-recipes)
148+
149+
- [SuperTokens Docs](https://supertokens.io/docs/community/getting-started/installation)
150+
- [Blog Posts](https://supertokens.io/blog/)
151+
- [Development guideline for the backend and frontend recipes](https://github.com/supertokens/supertokens-core/wiki/Development-guideline-for-the-backend-and-frontend-recipes)
117152
118153
119154

LICENSE.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Portions of this software are licensed as follows:
2+
3+
* All content that resides under the "ee/" directory of this repository, if that directory exists, is licensed under the
4+
license defined in "ee/LICENSE.md".
5+
* All third party components incorporated into the SuperTokens Software are licensed under the original license provided
6+
by the owner of the applicable component.
7+
* Content outside of the above mentioned directories or restrictions above is available under the "Apache 2.0"
8+
license as defined below.
9+
110

211
Apache License
312
Version 2.0, January 2004
@@ -176,7 +185,7 @@
176185

177186
END OF TERMS AND CONDITIONS
178187

179-
Copyright 2020 SuperTokens, Inc.
188+
Copyright 2020-2023 SuperTokens, Inc.
180189

181190
Licensed under the Apache License, Version 2.0 (the "License");
182191
you may not use this file except in compliance with the License.
@@ -188,4 +197,4 @@
188197
distributed under the License is distributed on an "AS IS" BASIS,
189198
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190199
See the License for the specific language governing permissions and
191-
limitations under the License.
200+
limitations under the License.

build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ compileTestJava { options.encoding = "UTF-8" }
1919
// }
2020
//}
2121

22-
version = "4.2.1"
22+
version = "4.3.0"
2323

2424

2525
repositories {
@@ -29,6 +29,7 @@ repositories {
2929
dependencies {
3030

3131
// https://mvnrepository.com/artifact/com.google.code.gson/gson
32+
// if this changes, remember to also change in the ee folder's build.gradle
3233
implementation group: 'com.google.code.gson', name: 'gson', version: '2.3.1'
3334

3435
// https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml

cli/src/main/java/io/supertokens/cli/Main.java

+7-9
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public static void main(String[] args) {
7171
}
7272

7373
// java -classpath "./cli/*" io.supertokens.cli.Main <args>
74-
// - args: true [--path <path location>] --> via installer is true
75-
// - args: false <installation path> <command> <...command args>
74+
// - args: true [--path <path location>] --> via installer is true
75+
// - args: false <installation path> <command> <...command args>
7676
private static void start(String[] args) {
7777
boolean viaInstaller = Boolean.parseBoolean(args[0]);
7878
String installationDir;
@@ -82,18 +82,16 @@ private static void start(String[] args) {
8282
if (viaInstaller) {
8383
installationDir = "ignored";
8484
command = "install";
85-
options = java.util.Arrays.stream(args, 1, args.length)
86-
.toArray(String[]::new);
85+
options = java.util.Arrays.stream(args, 1, args.length).toArray(String[]::new);
8786
} else {
8887
installationDir = args[1];
8988

9089
if (args.length == 2) {
91-
args = new String[]{args[0], args[1], "--help"};
90+
args = new String[] { args[0], args[1], "--help" };
9291
}
9392

9493
command = args[2];
95-
options = java.util.Arrays.stream(args, 3, args.length)
96-
.toArray(String[]::new);
94+
options = java.util.Arrays.stream(args, 3, args.length).toArray(String[]::new);
9795
}
9896

9997
initCommandHandlers();
@@ -103,8 +101,8 @@ private static void start(String[] args) {
103101
handler.handleCommand(installationDir, viaInstaller, options);
104102
}
105103
} else {
106-
throw new QuitProgramException("Unknown command '" + command +
107-
"'. Please use \"supertokens --help\" to see the list of available commands", null);
104+
throw new QuitProgramException("Unknown command '" + command
105+
+ "'. Please use \"supertokens --help\" to see the list of available commands", null);
108106
}
109107
}
110108

0 commit comments

Comments
 (0)