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: oauth2 core integration #916

Open
wants to merge 38 commits into
base: 21.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
03f3914
feat: add boilerplate for oauth2 recipe
porcellus Jun 9, 2024
5a215b9
feat: add a temporary solution to query hydra (until core impl) from …
porcellus Jun 12, 2024
7a29a7a
fix: fix temp solution for hydra calls
porcellus Jun 13, 2024
16e9631
feat: Add a recipe function to create OAuth2Client (#859)
anku255 Jun 17, 2024
fb51f36
feat: Add recipe functions to update/delete OAuth2Client (#863)
anku255 Jun 21, 2024
568a2f3
feat: Add recipe functions to get OAuth2Clients (#865)
anku255 Jun 21, 2024
05b6fb2
Merge remote-tracking branch 'origin/19.0' into feat/oauth2/base
porcellus Jun 26, 2024
2fd8ef4
feat: add initial oauth2 client apis (#866)
porcellus Jul 14, 2024
e84eb49
feat: Add OAuth2Client recipe (#877)
anku255 Jul 23, 2024
9c7a22d
fix: Remove internal redirects in the OAuth2 flow (#896)
anku255 Jul 26, 2024
0b39ad9
fix: Prefer exact api path match in the middleware (#892)
anku255 Jul 26, 2024
92121af
feat: Add userInfoGET endpoint (#890)
anku255 Jul 26, 2024
4ab2410
feat: add functions to validate oauth2 tokens
porcellus Jul 28, 2024
e0cdae5
feat: rename OAuth2 to OAuth2Provider
porcellus Jul 28, 2024
a463b65
feat: expose token validation functions
porcellus Jul 28, 2024
b0984c1
test: update tests
porcellus Jul 28, 2024
a29ffbe
fix: add userinfo_endpoint properly
porcellus Jul 28, 2024
6950da7
feat: removed unnecessary props
porcellus Jul 28, 2024
6974420
fix: add workaround to validate access/idtokens
porcellus Jul 29, 2024
a351c0a
fix: OAuth2 fixes (#900)
anku255 Jul 29, 2024
3736358
Merge remote-tracking branch 'origin/20.0' into feat/oauth2/base
porcellus Aug 1, 2024
aac74df
Merge branch 'feat/oauth2/base' of github.com:supertokens/supertokens…
porcellus Aug 1, 2024
6bab7f5
feat: review fixes
porcellus Aug 1, 2024
be263bd
feat: remove accessTokenStrategy
porcellus Aug 1, 2024
f53853c
test: update tests
porcellus Aug 1, 2024
1271be1
feat: OAuth2Client interface changes (#904)
anku255 Aug 6, 2024
a7a2b87
feat: Add token revocation endpoint (#902)
anku255 Aug 8, 2024
611d860
feat: Add token introspection endpoint (#906)
anku255 Aug 8, 2024
4830f0a
fix: make clientSecret optional (#908)
anku255 Aug 9, 2024
6f45c5f
fix: revokeToken input check
anku255 Aug 9, 2024
905b5cd
feat: add shouldTryLinkingWithSessionUser flag to auth apis and make …
porcellus Aug 11, 2024
9f7866c
feat: add shouldTryRefresh plus self-review and test related fixes
porcellus Aug 18, 2024
6f09926
fix: auth and token endpoint integration
sattvikc Aug 21, 2024
93c3790
fix: token endpoint
sattvikc Aug 23, 2024
2ec4784
fix: refactor issuer
sattvikc Aug 27, 2024
cc9d278
fix: consent integration
sattvikc Sep 5, 2024
cba1ce5
fix: login integration
sattvikc Sep 6, 2024
471e282
fix: minor updates
sattvikc Sep 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .circleci/config_continue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@ jobs:
- run: update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-15.0.1/bin/javac" 2
- run: (cd .circleci/ && ./doUnitTests.sh << parameters.cdi-version >>)
- slack/status
test-backend-sdk-testing:
docker:
- image: rishabhpoddar/supertokens_node_driver_testing_node_20
resource_class: large
parameters:
cdi-version:
type: string
fdi-version:
type: string
steps:
- checkout
- run: echo "127.0.0.1 localhost.org" >> /etc/hosts
- run: apt-get install lsof
- run: npm i -d --force
- run: update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-15.0.1/bin/java" 2
- run: update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-15.0.1/bin/javac" 2
- run: (cd .circleci/ && ./doBackendSDKTests.sh << parameters.cdi-version >> << parameters.fdi-version >>)
- slack/status
test-website:
docker:
- image: rishabhpoddar/supertokens_website_sdk_testing
Expand Down Expand Up @@ -114,6 +132,20 @@ workflows:
matrix:
parameters:
cdi-version: placeholder
- test-backend-sdk-testing:
requires:
- test-dev-tag-as-not-passed
context:
- slack-notification
filters:
tags:
only: /dev-v[0-9]+(\.[0-9]+)*/
branches:
only: /test-cicd\/.*/
matrix:
parameters:
cdi-version: placeholder
fdi-version: placeholder
- test-website:
requires:
- test-dev-tag-as-not-passed
Expand Down Expand Up @@ -143,6 +175,7 @@ workflows:
- test-success:
requires:
- test-unit
- test-backend-sdk-testing
- test-website
- test-authreact
context:
Expand Down
38 changes: 38 additions & 0 deletions .circleci/doBackendSDKTests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
echo "Starting tests for CDI $1";

if [ -z "$SUPERTOKENS_API_KEY" ]; then
echo "SUPERTOKENS_API_KEY not set"
exit 1
fi

coreDriverVersion=$1
coreDriverVersion=`echo $coreDriverVersion | tr -d '"'`

frontendDriverVersion=$2

coreFree=`curl -s -X GET \
"https://api.supertokens.io/0/core-driver-interface/dependency/core/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$coreDriverVersion&driverName=node" \
-H 'api-version: 1'`
if [[ `echo $coreFree | jq .core` == "null" ]]
then
echo "fetching latest X.Y version for core given core-driver-interface X.Y version: $coreDriverVersion, planType: FREE gave response: $coreFree. Please make sure all relevant cores have been pushed."
exit 1
fi
coreFree=$(echo $coreFree | jq .core | tr -d '"')

cd ..
./test/testExports.sh
if [[ $? -ne 0 ]]
then
echo "export test failed... exiting!"
exit 1
fi
cd .circleci

./setupAndTestBackendSDKWithFreeCore.sh $coreFree $coreDriverVersion $frontendDriverVersion
if [[ $? -ne 0 ]]
then
echo "test failed... exiting!"
exit 1
fi
rm -rf ../../supertokens-root
81 changes: 81 additions & 0 deletions .circleci/setupAndTestBackendSDKWithFreeCore.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
coreInfo=`curl -s -X GET \
"https://api.supertokens.io/0/core/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$1" \
-H 'api-version: 0'`
if [[ `echo $coreInfo | jq .tag` == "null" ]]
then
echo "fetching latest X.Y.Z version for core, X.Y version: $1, planType: FREE gave response: $coreInfo"
exit 1
fi
coreTag=$(echo $coreInfo | jq .tag | tr -d '"')
coreVersion=$(echo $coreInfo | jq .version | tr -d '"')

pluginInterfaceVersionXY=`curl -s -X GET \
"https://api.supertokens.io/0/core/dependency/plugin-interface/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$1" \
-H 'api-version: 0'`
if [[ `echo $pluginInterfaceVersionXY | jq .pluginInterface` == "null" ]]
then
echo "fetching latest X.Y version for plugin-interface, given core X.Y version: $1, planType: FREE gave response: $pluginInterfaceVersionXY"
exit 1
fi
pluginInterfaceVersionXY=$(echo $pluginInterfaceVersionXY | jq .pluginInterface | tr -d '"')

pluginInterfaceInfo=`curl -s -X GET \
"https://api.supertokens.io/0/plugin-interface/latest?password=$SUPERTOKENS_API_KEY&planType=FREE&mode=DEV&version=$pluginInterfaceVersionXY" \
-H 'api-version: 0'`
if [[ `echo $pluginInterfaceInfo | jq .tag` == "null" ]]
then
echo "fetching latest X.Y.Z version for plugin-interface, X.Y version: $pluginInterfaceVersionXY, planType: FREE gave response: $pluginInterfaceInfo"
exit 1
fi
pluginInterfaceTag=$(echo $pluginInterfaceInfo | jq .tag | tr -d '"')
pluginInterfaceVersion=$(echo $pluginInterfaceInfo | jq .version | tr -d '"')

echo "Testing with FREE core: $coreVersion, plugin-interface: $pluginInterfaceVersion"

cd ../../
git clone [email protected]:supertokens/supertokens-root.git
cd supertokens-root
if [[ $2 == "2.0" ]] || [[ $2 == "2.1" ]] || [[ $2 == "2.2" ]]
then
git checkout 36e5af1b9a4e3b07247d0cf333cf82a071a78681
fi
echo -e "core,$1\nplugin-interface,$pluginInterfaceVersionXY" > modules.txt
./loadModules --ssh
cd supertokens-core
git checkout $coreTag
cd ../supertokens-plugin-interface
git checkout $pluginInterfaceTag
cd ../
echo $SUPERTOKENS_API_KEY > apiPassword
./utils/setupTestEnvLocal
cd ../project/

# Set the script to exit on error
set -e

API_PORT=3030
ST_CONNECTION_URI=http://localhost:8081

# start test-server
pushd test/test-server
npm install
API_PORT=$API_PORT ST_CONNECTION_URI=$ST_CONNECTION_URI npm start &
popd

frontendDriverVersion=$3
# run tests
cd ../
git clone [email protected]:supertokens/backend-sdk-testing.git
cd backend-sdk-testing
git checkout $frontendDriverVersion
npm install
npm run build

if ! [[ -z "${CIRCLE_NODE_TOTAL}" ]]; then
API_PORT=$API_PORT TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npx mocha --node-option no-experimental-fetch -r test/fetch-polyfill.mjs --no-config --timeout 500000 $(npx mocha-split-tests -r ./runtime.log -t $CIRCLE_NODE_TOTAL -g $CIRCLE_NODE_INDEX -f 'test/**/*.test.js')
else
API_PORT=$API_PORT TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npm test
fi

# kill test-server
kill $(lsof -t -i:$API_PORT)
33 changes: 0 additions & 33 deletions .circleci/setupAndTestWithFreeCore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,36 +58,3 @@ if ! [[ -z "${CIRCLE_NODE_TOTAL}" ]]; then
else
TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npm test
fi

API_PORT=3030
ST_CONNECTION_URI=http://localhost:8081

# start test-server
pushd test/test-server
npm install
API_PORT=$API_PORT ST_CONNECTION_URI=$ST_CONNECTION_URI npm start &
popd

# lets read frontendDriverInterfaceSupported
frontendDriverJson=`cat ./frontendDriverInterfaceSupported.json`
# get versions
frontendDriverArray=`echo $frontendDriverJson | jq ".versions"`
# use latest version
frontendDriverVersion=`echo $frontendDriverArray | jq ".[-1]" | tr -d '"'`

# run tests
cd ../
git clone [email protected]:supertokens/backend-sdk-testing.git
cd backend-sdk-testing
git checkout $frontendDriverVersion
npm install
npm run build

if ! [[ -z "${CIRCLE_NODE_TOTAL}" ]]; then
API_PORT=$API_PORT TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npx mocha --node-option no-experimental-fetch -r test/fetch-polyfill.mjs --no-config --timeout 500000 $(npx mocha-split-tests -r ./runtime.log -t $CIRCLE_NODE_TOTAL -g $CIRCLE_NODE_INDEX -f 'test/**/*.test.js')
else
API_PORT=$API_PORT TEST_MODE=testing SUPERTOKENS_CORE_TAG=$coreTag NODE_PORT=8081 INSTALL_PATH=../supertokens-root npm test
fi

# kill test-server
kill $(lsof -t -i:$API_PORT)
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/node_modules
test/test-server/node_modules
/examples/**/node_modules
.DS_Store
/.history
Expand All @@ -12,4 +13,4 @@ releasePassword
/test_report
/temp_test_exports
/temp_*
/.nyc_output
/.nyc_output
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

## UNRELEASED

- Added OAuth2Provider recipe

## [20.0.2] - 2024-08-08

- Fixes an issue where `shouldDoAutomaticAccountLinking` was called without a primary user when linking in some cases.

## [20.0.1] - 2024-08-05

- Fixes an issue with `removeFromPayloadByMerge_internal` for `MultiFactorAuthClaim` where it was not retaining other claims while removing the claim from the payload.
- Updates testing with backend-sdk-testing repo to run against all supported FDI versions.

## [20.0.0] - 2024-07-24

### Changes
Expand Down Expand Up @@ -306,6 +319,10 @@ for (const tenant of tenantsRes.tenants) {

- `refreshPOST` and `refreshSession` now clears all user tokens upon CSRF failures and if no tokens are found. See the latest comment on https://github.com/supertokens/supertokens-node/issues/141 for more details.

## [18.0.2] - 2024-07-09

- `refreshPOST` and `refreshSession` now clears all user tokens upon CSRF failures and if no tokens are found. See the latest comment on https://github.com/supertokens/supertokens-node/issues/141 for more details.

## [18.0.1] - 2024-06-19

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion docs/classes/framework.BaseRequest.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/framework.BaseResponse.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/framework_custom.CollectingResponse.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/classes/framework_custom.PreParsedRequest.html

Large diffs are not rendered by default.

Loading
Loading