From b02728c57a428bc3f700b6ac121a1d236229ce33 Mon Sep 17 00:00:00 2001 From: Peter Hayes Date: Fri, 26 Aug 2016 11:43:58 -0700 Subject: [PATCH 1/8] changed cookie parsing behavior for fork --- index.js | 20 +++++++++++--------- package.json | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index 2241d974..3c992f45 100644 --- a/index.js +++ b/index.js @@ -498,6 +498,17 @@ function getcookie(req, name, secrets) { var raw; var val; + // DOJO CHANGE - First attempt to used a parsed objectfor the cookies, falling back + // to parsing the cookie only if this doesn't exist. This is the reverse of normal. + // Since we're already parsing the cookies in previous middleware, this is safe, and it + // allows us to copy the `dojo_teach_login.sid` or other site-specific cookie to overwrite + // the `dojo_login.sid` value. This in turn allows a user to be signed in as both a + // parent and a teacher and a student at the same time. + if (!val && req.signedCookies) { + val = req.signedCookies[name]; + } + + // read from cookie header if (header) { var cookies = cookie.parse(header); @@ -518,15 +529,6 @@ function getcookie(req, name, secrets) { } } - // back-compat read from cookieParser() signedCookies data - if (!val && req.signedCookies) { - val = req.signedCookies[name]; - - if (val) { - deprecate('cookie should be available in req.headers.cookie'); - } - } - // back-compat read from cookieParser() cookies data if (!val && req.cookies) { raw = req.cookies[name]; diff --git a/package.json b/package.json index 47dfa5e8..02130e67 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "express-session", + "name": "@classdojo/express-session", "version": "1.14.1", "description": "Simple session middleware for Express", "author": "TJ Holowaychuk (http://tjholowaychuk.com)", From fdfd47703e516769015d727717c491afac1ca07b Mon Sep 17 00:00:00 2001 From: Peter Hayes Date: Fri, 26 Aug 2016 11:44:47 -0700 Subject: [PATCH 2/8] updated readme --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index f052c876..6d4d7f87 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +# NOTE +We've forked this because it doesn't play nicely with our cookie system - one global one and one for each of teach/home/student. +The only change is the block of commented out code in the `getcookie` method. + + # express-session [![NPM Version][npm-image]][npm-url] From 9d89011286ff59fea6c8debdf8de0ee036916a41 Mon Sep 17 00:00:00 2001 From: Peter Hayes Date: Fri, 26 Aug 2016 11:59:40 -0700 Subject: [PATCH 3/8] bug fix --- index.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 3c992f45..f9de5fa0 100644 --- a/index.js +++ b/index.js @@ -504,13 +504,13 @@ function getcookie(req, name, secrets) { // allows us to copy the `dojo_teach_login.sid` or other site-specific cookie to overwrite // the `dojo_login.sid` value. This in turn allows a user to be signed in as both a // parent and a teacher and a student at the same time. - if (!val && req.signedCookies) { + if (req.signedCookies) { val = req.signedCookies[name]; } // read from cookie header - if (header) { + if (!val && header) { var cookies = cookie.parse(header); raw = cookies[name]; diff --git a/package.json b/package.json index 02130e67..bd38e01c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@classdojo/express-session", - "version": "1.14.1", + "version": "1.14.2", "description": "Simple session middleware for Express", "author": "TJ Holowaychuk (http://tjholowaychuk.com)", "contributors": [ From e99c2eb4b2a4cf36adf96f03f9f03ba672d991d3 Mon Sep 17 00:00:00 2001 From: Peter Hayes Date: Fri, 26 Aug 2016 17:15:30 -0700 Subject: [PATCH 4/8] changed cookie decision logic --- index.js | 7 +++---- package.json | 4 ++-- test/session.js | 3 ++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index f9de5fa0..b87f55bc 100644 --- a/index.js +++ b/index.js @@ -498,19 +498,18 @@ function getcookie(req, name, secrets) { var raw; var val; - // DOJO CHANGE - First attempt to used a parsed objectfor the cookies, falling back - // to parsing the cookie only if this doesn't exist. This is the reverse of normal. + // DOJO CHANGE - Use a parsed object for the cookies, instead of parsing them here. // Since we're already parsing the cookies in previous middleware, this is safe, and it // allows us to copy the `dojo_teach_login.sid` or other site-specific cookie to overwrite // the `dojo_login.sid` value. This in turn allows a user to be signed in as both a // parent and a teacher and a student at the same time. if (req.signedCookies) { - val = req.signedCookies[name]; + return req.signedCookies[name]; } // read from cookie header - if (!val && header) { + if (header) { var cookies = cookie.parse(header); raw = cookies[name]; diff --git a/package.json b/package.json index bd38e01c..2ca0c5e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@classdojo/express-session", - "version": "1.14.2", + "version": "1.14.3", "description": "Simple session middleware for Express", "author": "TJ Holowaychuk (http://tjholowaychuk.com)", "contributors": [ @@ -38,7 +38,7 @@ "node": ">= 0.8.0" }, "scripts": { - "test": "mocha --bail --reporter spec test/", + "test": "mocha --reporter spec test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/", "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec test/" } diff --git a/test/session.js b/test/session.js index f553d1c5..940ba9b4 100644 --- a/test/session.js +++ b/test/session.js @@ -2148,7 +2148,8 @@ describe('session()', function(){ }) describe('cookieParser()', function () { - it('should read from req.cookies', function(done){ + // only test that fails with dojo changes, because it's about the order of cookie parsing. + xit('should read from req.cookies', function(done){ var app = express() .use(cookieParser()) .use(function(req, res, next){ req.headers.cookie = 'foo=bar'; next() }) From 0162ac687827c83b07bac1cb86e3e75bb88f2599 Mon Sep 17 00:00:00 2001 From: Federico Rampazzo Date: Wed, 22 Jul 2020 16:26:58 +0000 Subject: [PATCH 5/8] Fix name / repo in package.json --- package.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 29b0055c..fe714022 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,10 @@ "Douglas Christopher Wilson ", "Joe Wagner " ], - "repository": "expressjs/session", + "repository": { + "type": "git", + "url": "ssh://git@github.com/classdojo/session.git" + }, "license": "MIT", "dependencies": { "cookie": "0.3.1", @@ -45,4 +48,4 @@ "test-travis": "nyc npm test -- --no-exit", "version": "node scripts/version-history.js && git add HISTORY.md" } -} +} \ No newline at end of file From b0537a92e4d5828461364047c37a0e7c95b24773 Mon Sep 17 00:00:00 2001 From: Federico Rampazzo Date: Sat, 1 Aug 2020 14:41:56 +0000 Subject: [PATCH 6/8] Add github packages .npmrc/.yarnrc --- .npmrc | 1 + .yarnrc | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 .npmrc create mode 100644 .yarnrc diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..f0bf8d57 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +@classdojo:registry=https://npm.pkg.github.com diff --git a/.yarnrc b/.yarnrc new file mode 100644 index 00000000..8faf0a10 --- /dev/null +++ b/.yarnrc @@ -0,0 +1,2 @@ +registry "https://registry.npmjs.org/" +"@classdojo:registry" "https://npm.pkg.github.com" From 29d93bb68b725a20945f00162b95ba1d1fb0a1ad Mon Sep 17 00:00:00 2001 From: Matthew Huie Date: Wed, 20 Dec 2023 19:55:43 +0000 Subject: [PATCH 7/8] Change CI to use k8s shared runners --- .github/workflows/ci.yml | 314 +++++++++++++++++++-------------------- 1 file changed, 157 insertions(+), 157 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e662fb3..5e24e6f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,195 +1,195 @@ name: ci on: -- pull_request -- push + - pull_request + - push jobs: test: - runs-on: ubuntu-latest + runs-on: ["self-hosted", "general-ubuntu-amd"] strategy: matrix: name: - - Node.js 0.8 - - Node.js 0.10 - - Node.js 0.12 - - io.js 1.x - - io.js 2.x - - io.js 3.x - - Node.js 4.x - - Node.js 5.x - - Node.js 6.x - - Node.js 7.x - - Node.js 8.x - - Node.js 9.x - - Node.js 10.x - - Node.js 11.x - - Node.js 12.x - - Node.js 13.x - - Node.js 14.x - - Node.js 15.x - - Node.js 16.x - - Node.js 17.x - - Node.js 18.x + - Node.js 0.8 + - Node.js 0.10 + - Node.js 0.12 + - io.js 1.x + - io.js 2.x + - io.js 3.x + - Node.js 4.x + - Node.js 5.x + - Node.js 6.x + - Node.js 7.x + - Node.js 8.x + - Node.js 9.x + - Node.js 10.x + - Node.js 11.x + - Node.js 12.x + - Node.js 13.x + - Node.js 14.x + - Node.js 15.x + - Node.js 16.x + - Node.js 17.x + - Node.js 18.x include: - - name: Node.js 0.8 - node-version: "0.8" - npm-i: mocha@2.5.3 supertest@1.1.0 - npm-rm: nyc + - name: Node.js 0.8 + node-version: "0.8" + npm-i: mocha@2.5.3 supertest@1.1.0 + npm-rm: nyc - - name: Node.js 0.10 - node-version: "0.10" - npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0 + - name: Node.js 0.10 + node-version: "0.10" + npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0 - - name: Node.js 0.12 - node-version: "0.12" - npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0 + - name: Node.js 0.12 + node-version: "0.12" + npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0 - - name: io.js 1.x - node-version: "1.8" - npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0 + - name: io.js 1.x + node-version: "1.8" + npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0 - - name: io.js 2.x - node-version: "2.5" - npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0 + - name: io.js 2.x + node-version: "2.5" + npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0 - - name: io.js 3.x - node-version: "3.3" - npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0 + - name: io.js 3.x + node-version: "3.3" + npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0 - - name: Node.js 4.x - node-version: "4.9" - npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2 + - name: Node.js 4.x + node-version: "4.9" + npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2 - - name: Node.js 5.x - node-version: "5.12" - npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2 + - name: Node.js 5.x + node-version: "5.12" + npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2 - - name: Node.js 6.x - node-version: "6.17" - npm-i: mocha@6.2.2 nyc@14.1.1 supertest@6.1.6 + - name: Node.js 6.x + node-version: "6.17" + npm-i: mocha@6.2.2 nyc@14.1.1 supertest@6.1.6 - - name: Node.js 7.x - node-version: "7.10" - npm-i: mocha@6.2.2 nyc@14.1.1 supertest@6.1.6 + - name: Node.js 7.x + node-version: "7.10" + npm-i: mocha@6.2.2 nyc@14.1.1 supertest@6.1.6 - - name: Node.js 8.x - node-version: "8.17" - npm-i: mocha@7.2.0 + - name: Node.js 8.x + node-version: "8.17" + npm-i: mocha@7.2.0 - - name: Node.js 9.x - node-version: "9.11" - npm-i: mocha@7.2.0 + - name: Node.js 9.x + node-version: "9.11" + npm-i: mocha@7.2.0 - - name: Node.js 10.x - node-version: "10.24" - npm-i: mocha@8.4.0 + - name: Node.js 10.x + node-version: "10.24" + npm-i: mocha@8.4.0 - - name: Node.js 11.x - node-version: "11.15" - npm-i: mocha@8.4.0 + - name: Node.js 11.x + node-version: "11.15" + npm-i: mocha@8.4.0 - - name: Node.js 12.x - node-version: "12.22" - npm-i: mocha@9.2.2 + - name: Node.js 12.x + node-version: "12.22" + npm-i: mocha@9.2.2 - - name: Node.js 13.x - node-version: "13.14" - npm-i: mocha@9.2.2 + - name: Node.js 13.x + node-version: "13.14" + npm-i: mocha@9.2.2 - - name: Node.js 14.x - node-version: "14.19" + - name: Node.js 14.x + node-version: "14.19" - - name: Node.js 15.x - node-version: "15.14" + - name: Node.js 15.x + node-version: "15.14" - - name: Node.js 16.x - node-version: "16.15" + - name: Node.js 16.x + node-version: "16.15" - - name: Node.js 17.x - node-version: "17.9" + - name: Node.js 17.x + node-version: "17.9" - - name: Node.js 18.x - node-version: "18.0" + - name: Node.js 18.x + node-version: "18.0" steps: - - uses: actions/checkout@v2 - - - name: Install Node.js ${{ matrix.node-version }} - shell: bash -eo pipefail -l {0} - run: | - nvm install --default ${{ matrix.node-version }} - if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then - nvm install --alias=npm 0.10 - nvm use ${{ matrix.node-version }} - sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")" - npm config set strict-ssl false - fi - dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" - - - name: Configure npm - run: npm config set shrinkwrap false - - - name: Remove npm module(s) ${{ matrix.npm-rm }} - run: npm rm --silent --save-dev ${{ matrix.npm-rm }} - if: matrix.npm-rm != '' - - - name: Install npm module(s) ${{ matrix.npm-i }} - run: npm install --save-dev ${{ matrix.npm-i }} - if: matrix.npm-i != '' - - - name: Setup Node.js version-specific dependencies - shell: bash - run: | - # eslint for linting - # - remove on Node.js < 10 - if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then - node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ - grep -E '^eslint(-|$)' | \ - sort -r | \ - xargs -n1 npm rm --silent --save-dev - fi - - - name: Install Node.js dependencies - run: npm install - - - name: List environment - id: list_env - shell: bash - run: | - echo "node@$(node -v)" - echo "npm@$(npm -v)" - npm -s ls ||: - (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }' - - - name: Run tests - shell: bash - run: | - if npm -ps ls nyc | grep -q nyc; then - npm run test-ci - else - npm test - fi - - - name: Lint code - if: steps.list_env.outputs.eslint != '' - run: npm run lint - - - name: Collect code coverage - uses: coverallsapp/github-action@master - if: steps.list_env.outputs.nyc != '' - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - flag-name: run-${{ matrix.test_number }} - parallel: true + - uses: actions/checkout@v2 + + - name: Install Node.js ${{ matrix.node-version }} + shell: bash -eo pipefail -l {0} + run: | + nvm install --default ${{ matrix.node-version }} + if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then + nvm install --alias=npm 0.10 + nvm use ${{ matrix.node-version }} + sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")" + npm config set strict-ssl false + fi + dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH" + + - name: Configure npm + run: npm config set shrinkwrap false + + - name: Remove npm module(s) ${{ matrix.npm-rm }} + run: npm rm --silent --save-dev ${{ matrix.npm-rm }} + if: matrix.npm-rm != '' + + - name: Install npm module(s) ${{ matrix.npm-i }} + run: npm install --save-dev ${{ matrix.npm-i }} + if: matrix.npm-i != '' + + - name: Setup Node.js version-specific dependencies + shell: bash + run: | + # eslint for linting + # - remove on Node.js < 10 + if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then + node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \ + grep -E '^eslint(-|$)' | \ + sort -r | \ + xargs -n1 npm rm --silent --save-dev + fi + + - name: Install Node.js dependencies + run: npm install + + - name: List environment + id: list_env + shell: bash + run: | + echo "node@$(node -v)" + echo "npm@$(npm -v)" + npm -s ls ||: + (npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }' + + - name: Run tests + shell: bash + run: | + if npm -ps ls nyc | grep -q nyc; then + npm run test-ci + else + npm test + fi + + - name: Lint code + if: steps.list_env.outputs.eslint != '' + run: npm run lint + + - name: Collect code coverage + uses: coverallsapp/github-action@master + if: steps.list_env.outputs.nyc != '' + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + flag-name: run-${{ matrix.test_number }} + parallel: true coverage: needs: test runs-on: ubuntu-latest steps: - - name: Upload code coverage - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.github_token }} - parallel-finished: true + - name: Upload code coverage + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.github_token }} + parallel-finished: true From 59ae064e409363568deda9f882394e49fd8af6d8 Mon Sep 17 00:00:00 2001 From: Matthew Huie Date: Thu, 21 Dec 2023 18:28:13 +0000 Subject: [PATCH 8/8] Change CI to use k8s shared runners --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e24e6f0..492a03fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -186,7 +186,7 @@ jobs: coverage: needs: test - runs-on: ubuntu-latest + runs-on: ["self-hosted", "general-ubuntu-amd"] steps: - name: Upload code coverage uses: coverallsapp/github-action@master