Skip to content

Release 5.0.0 #194

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 65 commits into from
Nov 6, 2023
Merged
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
9b68723
relase(pre): 5.0.0-rc.0
jankapunkt Jun 22, 2023
8dd11fe
fix(pkce): get code_challenge and _method from query if not present i…
jankapunkt Jul 10, 2023
cc643fe
fix(pkce): get code_challenge and _method from query if not present i…
jankapunkt Jul 12, 2023
69cdd2c
Fix generateAuthorizationCode not being awaited
MaximilianGaedig Aug 2, 2023
f198623
Update authorization_code test
MaximilianGaedig Aug 2, 2023
47916a7
fix: await generateAuthorizationCode in authorize-handler
jankapunkt Aug 2, 2023
f869d39
fix(ci): install oauth2-server from current ref in actions
jankapunkt Aug 2, 2023
35a02b9
Merge pull request #205 from node-oauth/fix-ci-release-tests
jankapunkt Aug 2, 2023
aeffa48
docs: update changelog
jankapunkt Aug 2, 2023
7ebf3aa
types: update supported version to 5.0.0
jankapunkt Aug 2, 2023
471af88
release: 5.0.0-rc.1
jankapunkt Aug 2, 2023
3bffe8b
Removed callback support in typings.
shrihari-prakash Aug 4, 2023
6cfb8f0
Merge pull request #211 from shrihari-prakash/release-5.0.0
jankapunkt Aug 4, 2023
f6db51a
Fixed getUserFromClient not awaited.
shrihari-prakash Aug 15, 2023
fc8f4dc
Merge branch 'node-oauth:release-5.0.0' into release-5.0.0
shrihari-prakash Aug 15, 2023
bfc4e8f
Added tests.
shrihari-prakash Aug 15, 2023
204aa1d
Merge branch 'release-5.0.0' of https://github.com/node-oauth/node-oa…
shrihari-prakash Aug 15, 2023
76c1c62
Merge branch 'release-5.0.0' of https://github.com/shrihari-prakash/n…
shrihari-prakash Aug 15, 2023
c299425
fix: await getUserFromClient in client credentials grant
jankapunkt Aug 15, 2023
c6682a6
publish 5.0.0-rc.2
jankapunkt Aug 15, 2023
704d917
tests(compliance): added client credential workflow compliance tests
jankapunkt Aug 17, 2023
f0259db
tests(integration): grant types integration tests model integration c…
jankapunkt Aug 17, 2023
9bf64c4
tests(integration): deep cover refresh-token grant type
jankapunkt Aug 22, 2023
92cc613
tests(integration): deep cover authenticte handler
jankapunkt Aug 22, 2023
323c91b
tests(unit): improve coverage for TokenModel
jankapunkt Aug 22, 2023
fde0915
tests(unit): improve coverage for crypto util
jankapunkt Aug 22, 2023
c0593ef
tests(integration): deep-cover model integration in AuthorizeHandler …
jankapunkt Aug 22, 2023
c1fb9d4
tests: add deep integration tests (part I)
jankapunkt Aug 26, 2023
6758bff
Merge branch 'development' into release-5.0.0
jankapunkt Aug 29, 2023
028e020
update minimum nodejs version in release test workflow
jorenvandeweyer Aug 29, 2023
a42dc06
rewrote the scope validation
jorenvandeweyer Sep 9, 2023
2221751
removed callbacks from docs
jorenvandeweyer Sep 9, 2023
716b52e
forgot a single scope
jorenvandeweyer Sep 10, 2023
3e30107
release 5.0.0-rc,3
jankapunkt Sep 18, 2023
9c8c05b
Merge branch 'development' into release-5.0.0
jankapunkt Sep 18, 2023
45eb687
Merge branch 'release-5.0.0' into feature/scope-validation
jankapunkt Sep 27, 2023
8ce21a4
Merge branch 'feature/scope-validation' of github.com:jorenvandeweyer…
jorenvandeweyer Sep 27, 2023
0d4e5f3
added extra test for coverage
jorenvandeweyer Sep 27, 2023
d50cb2d
fix: use array scope and do not ignore scope on refresh token call
jankapunkt Sep 28, 2023
ed1f8a3
Merge branch 'development' into release-5.0.0
jankapunkt Sep 28, 2023
6d7a990
remove invalid bearer token that was used in test
jorenvandeweyer Sep 28, 2023
85d0a79
Merge pull request #243 from jorenvandeweyer/bugfix/invalid-bearer
jankapunkt Sep 28, 2023
1c40926
publish 5.0.0-rc.4
jankapunkt Sep 29, 2023
da3dc54
fix typing of revokeToken
jorenvandeweyer Oct 7, 2023
782af2a
Merge pull request #247 from jorenvandeweyer/bugfix/revoke-token-typing
jankapunkt Oct 8, 2023
d41585b
pass client to model function
jorenvandeweyer Oct 25, 2023
d012193
fixed typo
jorenvandeweyer Oct 26, 2023
b97f6c7
Merge pull request #256 from jorenvandeweyer/feature/pass-client-to-g…
jankapunkt Oct 26, 2023
ca43d4a
fix(pkce): get code challenge and method from either body or query (r…
jankapunkt Nov 1, 2023
eb9f123
build: publish release 5.0.0-rc.5
jankapunkt Nov 1, 2023
7e2abee
docs: add readthedocs v2 config file
jankapunkt Nov 6, 2023
f3e2438
docs: sphinx conf updated to v2 compatible
jankapunkt Nov 6, 2023
6d27e3f
docs: merged master docs into 5.0.0
jankapunkt Nov 6, 2023
1da9837
docs: add migrating to v5 topic
jankapunkt Nov 6, 2023
ff8cdad
docs: add missing adapters and getting started guide
jankapunkt Nov 6, 2023
f06f2fd
docs: update sphinx conf and index toc
jankapunkt Nov 6, 2023
7f18e08
docs: use requirements files to install themes and plugins
jankapunkt Nov 6, 2023
da9ce1a
docs: update rtd config
jankapunkt Nov 6, 2023
3991a8c
docs: remove requirements
jankapunkt Nov 6, 2023
72f3675
docs: remove build using requirements files
jankapunkt Nov 6, 2023
fb59e30
docs: add multiple documentation links
jankapunkt Nov 6, 2023
937d9a7
docs: fix table of contents
jankapunkt Nov 6, 2023
a4f2145
docs: add sphinx rtd theme
jankapunkt Nov 6, 2023
1858669
docs: install sphinx theme with python
jankapunkt Nov 6, 2023
a7a1b25
published release 5.0.0
jankapunkt Nov 6, 2023
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
Prev Previous commit
Next Next commit
tests(compliance): added client credential workflow compliance tests
  • Loading branch information
jankapunkt committed Aug 17, 2023
commit 704d917c95661c65a555f9f55570b6751c63ea9b
142 changes: 142 additions & 0 deletions test/compliance/client-credential-workflow_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/**
* 4.4. Client Credentials Grant
*
* The client can request an access token using only its client
* credentials (or other supported means of authentication) when the
* client is requesting access to the protected resources under its
* control, or those of another resource owner that have been previously
* arranged with the authorization server (the method of which is beyond
* the scope of this specification).
*
* The client credentials grant type MUST only be used by confidential
* clients.
*
* @see https://www.rfc-editor.org/rfc/rfc6749#section-4.4
*/

const OAuth2Server = require('../..');
const DB = require('../helpers/db');
const createModel = require('../helpers/model');
const createRequest = require('../helpers/request');
const Response = require('../../lib/response');

require('chai').should();

const db = new DB();
// this user represents requests in the name of an external server
// TODO: we should discuss, if we can make user optional for client credential workflows
// as it's not desired to have an extra fake-user representing a server just to pass validation
const userDoc = { id: 'machine2-123456789', name: 'machine2' };
db.saveUser(userDoc);

const oAuth2Server = new OAuth2Server({
model: {
...createModel(db),
getUserFromClient: async function (_client) {
// in a machine2machine setup we might not have a dedicated "user"
// but we need to return a truthy response to
const client = db.findClient(_client.id, _client.secret);
return client && { ...userDoc };
}
}
});

const clientDoc = db.saveClient({
id: 'client-credential-test-client',
secret: 'client-credential-test-secret',
grants: ['client_credentials']
});

const enabledScope = 'read write';

describe('ClientCredentials Workflow Compliance (4.4)', function () {
describe('Access Token Request (4.4.1)', function () {
/**
* 4.4.2. Access Token Request
*
* The client makes a request to the token endpoint by adding the
* following parameters using the "application/x-www-form-urlencoded"
* format per Appendix B with a character encoding of UTF-8 in the HTTP
* request entity-body:
*
* grant_type
* REQUIRED. Value MUST be set to "client_credentials".
*
* scope
* OPTIONAL. The scope of the access request as described by
* Section 3.3.
*
* The client MUST authenticate with the authorization server as
* described in Section 3.2.1.
*/
it('authenticates the client with valid credentials', async function () {
const response = new Response();
const request = createRequest({
body: {
grant_type: 'client_credentials',
scope: enabledScope
},
headers: {
'authorization': 'Basic ' + Buffer.from(clientDoc.id + ':' + clientDoc.secret).toString('base64'),
'content-type': 'application/x-www-form-urlencoded'
},
method: 'POST',
});

const token = await oAuth2Server.token(request, response);

response.status.should.equal(200);
response.headers.should.deep.equal( { 'cache-control': 'no-store', pragma: 'no-cache' });
response.body.token_type.should.equal('Bearer');
response.body.access_token.should.equal(token.accessToken);
response.body.expires_in.should.be.a('number');
response.body.scope.should.equal(enabledScope);
('refresh_token' in response.body).should.equal(false);

token.accessToken.should.be.a('string');
token.accessTokenExpiresAt.should.be.a('date');
('refreshToken' in token).should.equal(false);
('refreshTokenExpiresAt' in token).should.equal(false);
token.scope.should.equal(enabledScope);

db.accessTokens.has(token.accessToken).should.equal(true);
db.refreshTokens.has(token.refreshToken).should.equal(false);
});

/**
* 7. Accessing Protected Resources
*
* The client accesses protected resources by presenting the access
* token to the resource server. The resource server MUST validate the
* access token and ensure that it has not expired and that its scope
* covers the requested resource. The methods used by the resource
* server to validate the access token (as well as any error responses)
* are beyond the scope of this specification but generally involve an
* interaction or coordination between the resource server and the
* authorization server.
*/
it('enables an authenticated request using the access token', async function () {
const [accessToken] = [...db.accessTokens.entries()][0];
const response = new Response();
const request = createRequest({
query: {},
headers: {
'authorization': `Bearer ${accessToken}`
},
method: 'GET',
});

const token = await oAuth2Server.authenticate(request, response);
token.accessToken.should.equal(accessToken);
token.user.should.deep.equal(userDoc);
token.client.should.deep.equal(clientDoc);
token.scope.should.equal(enabledScope);

response.status.should.equal(200);
// there should be no information in the response as it
// should only add information, if permission is denied
response.body.should.deep.equal({});
response.headers.should.deep.equal({});
});
});
});