Skip to content

Ci update core actions #168

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 23 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3821ef6
Updated doc for extension grants
Nov 28, 2021
46a429a
build(deps-dev): bump sinon from 12.0.1 to 13.0.1
dependabot[bot] Feb 1, 2022
ae6d7bf
build(deps-dev): bump mocha from 9.1.2 to 9.2.2
dependabot[bot] Mar 11, 2022
24b6342
build(deps-dev): bump eslint from 8.2.0 to 8.11.0
dependabot[bot] Mar 14, 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
d5be6ab
Merge pull request #133 from node-oauth/dependabot/npm_and_yarn/eslin…
jankapunkt Mar 18, 2022
91c5955
Merge pull request #132 from node-oauth/dependabot/npm_and_yarn/mocha…
jankapunkt Mar 18, 2022
f74634c
Merge pull request #128 from node-oauth/dependabot/npm_and_yarn/sinon…
jankapunkt 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
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
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
e01e841
Merge pull request #135 from node-oauth/release-4.2.0
jankapunkt Jun 6, 2022
ca50278
Merge branch 'v4.3.0-dev' into ci-update-core-actions
jankapunkt Oct 31, 2022
92ae07c
ci: update workflows to actions core v3
jankapunkt Oct 31, 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
40 changes: 21 additions & 19 deletions .github/workflows/tests-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '12'
- run: npm audit --production # no audit for dev dependencies
node-version: 16
# 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

Expand All @@ -38,18 +40,18 @@ jobs:
needs: [audit]
strategy:
matrix:
node: [12, 14, 16]
node: [14, 16, 18]
steps:
- name: Checkout ${{ matrix.node }}
uses: actions/checkout@v2
uses: actions/checkout@v3

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

- name: Cache dependencies ${{ matrix.node }}
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
Expand Down Expand Up @@ -79,26 +81,26 @@ jobs:
needs: [unittest]
strategy:
matrix:
node: [12, 14] # TODO get running for node 16
node: [14, 16, 18] # TODO get running for node 16+
steps:
# checkout this repo
- name: Checkout ${{ matrix.node }}
uses: actions/checkout@v2
uses: actions/checkout@v3

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

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

- name: Cache dependencies ${{ matrix.node }}
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node }}-node-oauth/express-oauth-server-${{ hashFiles('github/testing/express/**/package-lock.json') }}
Expand All @@ -120,10 +122,10 @@ jobs:
runs-on: ubuntu-latest
needs: [integrationtests]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 12
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm i
- run: npm publish --dry-run
Expand All @@ -137,11 +139,11 @@ jobs:
contents: read
packages: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
# we always publish targeting the lowest supported node version
node-version: 12
node-version: 16
registry-url: $registry-url(npm)
- run: npm i
- run: npm publish --dry-run
Expand Down
31 changes: 27 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,46 @@ on:
- release-* # on release we run an extended workflow so no need for this

jobs:
lint:
name: Javascript standard lint
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3

- name: setup node
uses: actions/setup-node@v3
with:
node-version: 16

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

unittest:
name: unit tests
runs-on: ubuntu-latest
needs: [lint]
strategy:
matrix:
node: [12, 14, 16]
node: [14, 16, 18]
steps:
- name: Checkout ${{ matrix.node }}
uses: actions/checkout@v2
uses: actions/checkout@v3

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

- name: Cache dependencies ${{ matrix.node }}
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
Expand Down
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.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@node-oauth/oauth2-server",
"description": "Complete, framework-agnostic, compliant and well tested module for implementing an OAuth2 Server in node.js",
"version": "4.1.1",
"version": "4.2.0",
"keywords": [
"oauth",
"oauth2"
Expand Down Expand Up @@ -35,7 +35,7 @@
"eslint": "8.4.1",
"mocha": "9.2.2",
"nyc": "15.1.0",
"sinon": "12.0.1"
"sinon": "13.0.1"
},
"license": "MIT",
"engines": {
Expand Down