Skip to content

Release 4.2.0 #135

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

Merged
merged 80 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
d3b335f
ci: ignore test.yml workflow on release-* branches PRs #36
jankapunkt Oct 18, 2021
8c080ff
ci: add tests-release.yml workflow to test release-integrity
jankapunkt Oct 18, 2021
c6459b8
ci: add release.yml to release a new version to registries
jankapunkt Oct 18, 2021
f4fc33b
ci(tests): make coverage generate lcov.info file
jankapunkt Oct 26, 2021
02e0a4d
ci(tests): make coverage generate lcov.info file as well as html #36
jankapunkt Oct 26, 2021
ac7bb86
ci(tests): fix spelling in coverage test script #36
jankapunkt Oct 26, 2021
3821ef6
Updated doc for extension grants
Nov 28, 2021
4ca8032
fix(handlers): skip varcheck for state when allowEmptyState
jankapunkt Nov 29, 2021
52ee11d
Merge pull request #88 from node-oauth/release-4.1.1
HappyZombies Nov 29, 2021
b56afcd
fixes issue 89, point 18, original pr 646
Dec 5, 2021
3df52fd
supported custom validateRedirectUri
Dec 5, 2021
91f27f8
Supported state in case of denial
Dec 5, 2021
5824f79
feature(): Supported state in case of denialMerge pull request #99 fr…
jankapunkt Dec 10, 2021
aca48ce
fix(handlers): skip varcheck for state when allowEmptyState #89 #93
jankapunkt Dec 10, 2021
88ef515
added test for `validateRedirectUri`
jorenvandeweyer Dec 11, 2021
0a86e69
updated documentation
jorenvandeweyer Dec 11, 2021
98a9d19
better implementation of validateRedirectUri
jorenvandeweyer Dec 11, 2021
8719d83
Bearer regular expression matching in authenticate handler
Dec 12, 2021
ff9a5d2
fixed misssing return statement in doc (#98)
FStefanni Dec 13, 2021
292774e
build(deps-dev): bump eslint from 8.2.0 to 8.4.1 (#102)
dependabot[bot] Dec 13, 2021
4ff1f07
added @node-oauth/formats module, removed is.js tests
jwerre Dec 13, 2021
10fe55d
feature(core): extract is.js into standalone package @node-oauth/form…
jankapunkt Dec 14, 2021
10bca68
Bump sinon from 11.1.2 to 12.0.1 (#74)
dependabot[bot] Dec 18, 2021
643e091
build(deps-dev): bump eslint from 8.2.0 to 8.4.1 (#106)
dependabot[bot] Dec 18, 2021
92bea82
Integration test password grant (#100)
jorenvandeweyer Dec 19, 2021
3a1e433
added warning in docs, added extra tests that actually use parameters
jorenvandeweyer Dec 19, 2021
29e081b
Merge branch 'development' into issue_89_4_482
jorenvandeweyer Dec 19, 2021
9fab017
feature(authorize): allow custom implementations of validateRedirectU…
jankapunkt Dec 20, 2021
4921a1c
fix(handler): deny access when body.allowed is 'false' (#94)
jankapunkt Dec 20, 2021
d1ba63c
fix(request): set WWW-Authenticate header for invalid requests oauthj…
jankapunkt Jan 7, 2022
7174693
Merge branch 'development' into ci-release-package
jankapunkt Jan 13, 2022
13aacce
feature(ci): release workflow only runs on non-draft pull requests
jankapunkt Jan 13, 2022
edd8160
fix(ci): use actions v2 for setting up node
jankapunkt Jan 13, 2022
69a3043
fix(ci): use code-ql only on non-draft releases
jankapunkt Jan 13, 2022
36e13eb
fix(ci): fix audit job syntax error
jankapunkt Jan 13, 2022
4188547
fix(ci): fix publish jobs syntax error
jankapunkt Jan 13, 2022
ecb072e
fix(ci): fix publish jobs syntax error
jankapunkt Jan 13, 2022
510546b
fix(ci): fix check coverage
jankapunkt Jan 13, 2022
88a7bfe
fix(ci): run workflows also only on push for non-draft PR
jankapunkt Jan 13, 2022
d6ec7d8
fix(ci): fix tets.yml semantic error
jankapunkt Jan 13, 2022
e556def
fix(ci): release-workflow trigger on push to PR
jankapunkt Jan 13, 2022
465b786
fix(ci): add lcov reporter to test:coverage
jankapunkt Jan 13, 2022
b7867e7
fix(ci): use oauthjs/express-oauth-server for integration testing
jankapunkt Jan 13, 2022
3167a8e
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
c99001c
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
fd9ead8
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
aee6d92
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
916c613
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
a47e867
fix(ci): use node-oauth/express-oauth-server for integration test
jankapunkt Jan 13, 2022
8073105
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
06e6b4c
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
099d063
fix(ci): fix path for integration test
jankapunkt Jan 13, 2022
f4bfae8
fix(ci): exclude node 16 to get running
jankapunkt Jan 13, 2022
9c70236
build(ci): add --access-public flag to npm publish
jankapunkt Jan 18, 2022
458e3f8
build(deps-dev): bump chai from 4.3.4 to 4.3.6
dependabot[bot] Jan 26, 2022
c97d0e3
ci: disable release workflow until decision is made pro automated rel…
jankapunkt Feb 1, 2022
72538a3
fix(core): Bearer regular expression matching in authenticate handler…
jankapunkt Feb 1, 2022
fff992d
Update package-lock.json
FStefanni Mar 15, 2022
937f229
Update package.json
FStefanni Mar 15, 2022
6d2f653
Update CHANGELOG.md
FStefanni Mar 15, 2022
f4caeb6
feature(ci): release workflow added #117
jankapunkt Mar 18, 2022
08d4cd3
refactor(ci): remove unused ci workflow
jankapunkt Mar 18, 2022
3e514df
Merge pull request #124 from node-oauth/dependabot/npm_and_yarn/chai-…
jankapunkt Mar 18, 2022
ac68291
Merge pull request #134 from node-oauth/remove-release-workflow
Uzlopak Mar 18, 2022
274a54d
Update docs/misc/extension-grants.rst
FStefanni Mar 30, 2022
1269719
docs: Update extension-grants.rst with example #92
jankapunkt Mar 30, 2022
34bbd0f
remove package-lock.json and set .npmrc to not create package-lock.js…
Uzlopak Apr 14, 2022
d0a14d7
use npm i instad of npm ci in workflows
Uzlopak Apr 14, 2022
f0254db
add yarn.lock to .gitignore and .npmingnore
Uzlopak Apr 14, 2022
19c8ced
RefreshTokenGrant: update error messages
chrisfranko Apr 16, 2022
de3f039
Merge pull request #143 from chrisfranko/development
HappyZombies Apr 18, 2022
802d28f
update changelog
jankapunkt Jun 2, 2022
62f3c4d
update dev-dependencies
jankapunkt Jun 2, 2022
9ae7f1e
fix(docs): re-add accidentally removed changelog for release 4.1.1
jankapunkt Jun 2, 2022
7050a91
Merge pull request #141 from Uzlopak/remove-package-lock-json
jankapunkt Jun 3, 2022
ccf836e
Merge branch 'development' into release-4.2.0
jankapunkt Jun 3, 2022
7ef6ec0
fix(ci): run npm install befire npm audit to provide temporary packag…
jankapunkt Jun 3, 2022
98da6bc
fix(ci): run npm install befire npm audit to provide temporary packag…
jankapunkt Jun 3, 2022
4ac0430
Merge branch 'master' into release-4.2.0
jankapunkt Jun 3, 2022
5c3d361
update(build): set package version to 4.2.0
jankapunkt Jun 5, 2022
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
1 change: 1 addition & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ name: "CodeQL Semantic Analysis"
on:
push: # all pushes
pull_request: # all PR
types: [review_requested, ready_for_review] # only non-draft PR
schedule:
- cron: '0 2 * * *' # every night at 2am

Expand Down
151 changes: 151 additions & 0 deletions .github/workflows/tests-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: Tests for Release

on:
push:
branches:
- release-* # all release-<version> branches
pull_request:
# only non-draft PR and when there are "pushes" to the open PR
types: [review_requested, ready_for_review, synchronize]
branches:
- release-* # all release-<version> branches


jobs:
# STEP 1 - NPM Audit

# Before we even test a thing we want to have a clean audit! Since this is
# sufficient to be done using the lowest node version, we can easily use
# a fixed one:

audit:
name: NPM Audit
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '12'
# install to create local package-lock.json but don't cache the files
# also: no audit for dev dependencies
- run: npm i --package-lock-only && npm audit --production

# STEP 2 - basic unit tests

# This is the standard unit tests as we do in the basic tests for every PR
unittest:
name: Basic unit tests
runs-on: ubuntu-latest
needs: [audit]
strategy:
matrix:
node: [12, 14, 16]
steps:
- name: Checkout ${{ matrix.node }}
uses: actions/checkout@v2

- name: Setup node ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- name: Cache dependencies ${{ matrix.node }}
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}

# for this workflow we also require npm audit to pass
- run: npm i
- run: npm run test:coverage

# with the following action we enforce PRs to have a high coverage
# and ensure, changes are tested well enough so that coverage won't fail
- name: check coverage
uses: VeryGoodOpenSource/very_good_coverage@v1.2.0
with:
path: './coverage/lcov.info'
min_coverage: 95

# STEP 3 - Integration tests

# Since our release may affect several packages that depend on it we need to
# cover the closest ones, like adapters and examples.

integrationtests:
name: Extended integration tests
runs-on: ubuntu-latest
needs: [unittest]
strategy:
matrix:
node: [12, 14] # TODO get running for node 16
steps:
# checkout this repo
- name: Checkout ${{ matrix.node }}
uses: actions/checkout@v2

# checkout express-adapter repo
- name: Checkout express-adapter ${{ matrix.node }}
uses: actions/checkout@v2
with:
repository: node-oauth/express-oauth-server
path: github/testing/express

- name: Setup node ${{ matrix.node }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}

- name: Cache dependencies ${{ matrix.node }}
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node }}-node-oauth/express-oauth-server-${{ hashFiles('github/testing/express/**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}-node-oauth/express-oauth-server

# in order to test the adapter we need to use the current checkout
# and install it as local dependency
# we just cloned and install it as local dependency
- run: |
cd github/testing/express
npm i
npm install ../../../
npm run test

# todo repeat with other adapters

publish-npm-dry:
runs-on: ubuntu-latest
needs: [integrationtests]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- run: npm i
- run: npm publish --dry-run
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

publish-github-dry:
needs: [integrationtests]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
# we always publish targeting the lowest supported node version
node-version: 12
registry-url: $registry-url(npm)
- run: npm i
- run: npm publish --dry-run
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
60 changes: 16 additions & 44 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,21 @@
name: Test suite
name: Tests

# This workflow runs standard unit tests to ensure basic integrity and avoid
# regressions on pull-requests (and pushes)

on:
push:
branches:
- master # allthough master is push protected we still keep it
- master # allthough master is push protected we still keep it
- development
pull_request: # runs on all PR
pull_request: # runs on all PR
branches-ignore:
- release-* # on release we run an extended workflow so no need for this

jobs:
# ----------------------------------
# uncomment when a linter is added
# ----------------------------------

# lintjs:
# name: Javascript lint
# runs-on: ubuntu-latest
# steps:
# - name: checkout
# uses: actions/checkout@v2
#
# - name: setup node
# uses: actions/setup-node@v1
# with:
# node-version: '12.x'
#
# - name: cache dependencies
# uses: actions/cache@v1
# with:
# path: ~/.npm
# key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-node-
# - run: npm ci
# - run: npm run lint

unittest:
name: unit tests
runs-on: ubuntu-latest
# uncomment when a linter is added
# needs: [lintjs]
strategy:
matrix:
node: [12, 14, 16]
Expand All @@ -58,18 +35,13 @@ jobs:
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ matrix.node }}
- run: npm ci
- run: npm i
- run: npm run test:coverage

# ----------------------------------
# uncomment when a linter is added
# ----------------------------------

# - name: check coverage
# uses: devmasx/coverage-check-action@v1.2.0
# with:
# type: lcov
# result_path: coverage/lcov.info
# min_coverage: 90
# token: ${{github.token}}

# with the following action we enforce PRs to have a high coverage
# and ensure, changes are tested well enough so that coverage won't fail
- name: check coverage
uses: VeryGoodOpenSource/very_good_coverage@v1.2.0
with:
path: './coverage/lcov.info'
min_coverage: 95
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ tramp
# coverage
coverage
.nyc_output

package-lock.json
yarn.lock
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
test/
package-lock.json
yarn.lock
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
## Changelog

## 4.2.0
### Fixed
- fix(core): Bearer regular expression matching in authenticate handler #105
- fix(request): set WWW-Authenticate header for invalid requests #96 oauthjs#646
- fix(handler): deny access when body.allowed is 'false' (#94)
- fix(handlers): skip varcheck for state when allowEmptyState #89 #93

### Added
- supported custom validateRedirectUri
- feature: Supported state in case of denialMerge #99
- Bearer regular expression matching in authenticate handler
- docs: Update extension-grants.rst with example #92
- feature(core): extract is.js into standalone package @node-oauth/formats #55
- feature(authorize): allow custom implementations of validateRedirectUri via model #89 p.4
- support custom validateRedirectUri()
- allow to implement model.validateRedirectUri
- updated AuthorizeHandler
- default conforms with RFC 6819 Section-5.2.3.5

### Tests
- Integration test password grant (#100)
* test example
* created db & model factories
* added refresh_token grant type test
* removed failing test, not implemented feature
* add reference to issue
* client authentication test
* random client credentials in test
* replace math.random by crypto.randomBytes

### CI
- refactor(ci): remove unused ci workflow
- fix(ci): use node-oauth/express-oauth-server for integration test

## 4.1.1

### Added
Expand Down
46 changes: 45 additions & 1 deletion docs/misc/extension-grants.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,51 @@
Extension Grants
==================

.. todo:: Describe how to implement extension grants.
Create a subclass of ``AbstractGrantType`` and create methods `handle` and `saveToken` along with other required methods according to your needs:

.. code-block:: js

const OAuth2Server = require('oauth2-server');
const AbstractGrantType = OAuth2Server.AbstractGrantType;
const InvalidArgumentError = OAuth2Server.InvalidArgumentError;
const InvalidRequestError = OAuth2Server.InvalidRequestError;

class MyCustomGrantType extends AbstractGrantType {
constructor(opts) {
super(opts);
}

async handle(request, client) {
if (!request) throw new InvalidArgumentError('Missing `request`');
if (!client) throw new InvalidArgumentError('Missing `client`');

let scope = this.getScope(request);
let user = await this.getUserBySomething(request);

return this.saveToken(user, client, scope);
}

async saveToken(user, client, scope) {
this.validateScope(user, client, scope);

let token = {
accessToken: await this.generateAccessToken(client, user, scope),
accessTokenExpiresAt: this.getAccessTokenExpiresAt(),
refreshToken: await this.generateRefreshToken(client, user, scope),
refreshTokenExpiresAt: this.getRefreshTokenExpiresAt(),
scope: scope
};

return this.model.saveToken(token, client, user);
}

async getUserBySomething(request) {
//Get user's data by corresponding data (FB User ID, Google, etc.), etc.
}
}

module.exports = MyCustomGrantType;

Extension grants are registered through :ref:`OAuth2Server#token() <OAuth2Server#token>` (``options.extendedGrantTypes``).

This might require you to approve the new ``grant_type`` for a particular ``client`` if you do checks on valid grant types.
1 change: 1 addition & 0 deletions docs/model/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Model functions used by the authorization code grant:
- :ref:`Model#saveAuthorizationCode`
- :ref:`Model#revokeAuthorizationCode`
- :ref:`Model#validateScope`
- :ref:`Model#validateRedirectUri`

--------

Expand Down
Loading