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

Release 5.0.0 #194

Merged
merged 65 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from 13 commits
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
2 changes: 1 addition & 1 deletion .github/workflows/tests-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
- run: |
cd github/testing/express
npm i
npm install ../../../
npm install https://github.com/node-oauth/node-oauth2-server.git#${{ github.ref_name }}
npm run test

# todo repeat with other adapters
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- drop support for Node 14 (EOL), setting Node 16 as `engine` in `package.json`
- this is a breaking change, because **it removes callback support** for
`OAuthServer` and your model implementation.
- fixed missing await in calling generateAuthorizationCode in AuthorizeHandler

## 4.2.0
### Fixed
Expand Down
56 changes: 24 additions & 32 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for Node OAuth2 Server 4.0
// Type definitions for Node OAuth2 Server 5.0
// Definitions by: Robbie Van Gorkom <https://github.com/vangorra>,
// Charles Irick <https://github.com/cirick>,
// Daniel Fischer <https://github.com/d-fischer>,
Expand All @@ -23,8 +23,7 @@ declare class OAuth2Server {
authenticate(
request: OAuth2Server.Request,
response: OAuth2Server.Response,
options?: OAuth2Server.AuthenticateOptions,
callback?: OAuth2Server.Callback<OAuth2Server.Token>
options?: OAuth2Server.AuthenticateOptions
): Promise<OAuth2Server.Token>;

/**
Expand All @@ -33,8 +32,7 @@ declare class OAuth2Server {
authorize(
request: OAuth2Server.Request,
response: OAuth2Server.Response,
options?: OAuth2Server.AuthorizeOptions,
callback?: OAuth2Server.Callback<OAuth2Server.AuthorizationCode>
options?: OAuth2Server.AuthorizeOptions
): Promise<OAuth2Server.AuthorizationCode>;

/**
Expand All @@ -43,8 +41,7 @@ declare class OAuth2Server {
token(
request: OAuth2Server.Request,
response: OAuth2Server.Response,
options?: OAuth2Server.TokenOptions,
callback?: OAuth2Server.Callback<OAuth2Server.Token>
options?: OAuth2Server.TokenOptions
): Promise<OAuth2Server.Token>;
}

Expand Down Expand Up @@ -238,11 +235,6 @@ declare namespace OAuth2Server {
extendedGrantTypes?: { [key: string]: typeof AbstractGrantType } | undefined;
}

/**
* Represents a generic callback structure for model callbacks
*/
type Callback<T> = (err?: any, result?: T) => void;

/**
* For returning falsey parameters in cases of failure
*/
Expand All @@ -253,53 +245,53 @@ declare namespace OAuth2Server {
* Invoked to generate a new access token.
*
*/
generateAccessToken?(client: Client, user: User, scope: string | string[], callback?: Callback<string>): Promise<string>;
generateAccessToken?(client: Client, user: User, scope: string | string[]): Promise<string>;

/**
* Invoked to retrieve a client using a client id or a client id/client secret combination, depending on the grant type.
*
*/
getClient(clientId: string, clientSecret: string, callback?: Callback<Client | Falsey>): Promise<Client | Falsey>;
getClient(clientId: string, clientSecret: string): Promise<Client | Falsey>;

/**
* Invoked to save an access token and optionally a refresh token, depending on the grant type.
*
*/
saveToken(token: Token, client: Client, user: User, callback?: Callback<Token>): Promise<Token | Falsey>;
saveToken(token: Token, client: Client, user: User): Promise<Token | Falsey>;
}

interface RequestAuthenticationModel {
/**
* Invoked to retrieve an existing access token previously saved through Model#saveToken().
*
*/
getAccessToken(accessToken: string, callback?: Callback<Token>): Promise<Token | Falsey>;
getAccessToken(accessToken: string): Promise<Token | Falsey>;

/**
* Invoked during request authentication to check if the provided access token was authorized the requested scopes.
*
*/
verifyScope(token: Token, scope: string | string[], callback?: Callback<boolean>): Promise<boolean>;
verifyScope(token: Token, scope: string | string[]): Promise<boolean>;
}

interface AuthorizationCodeModel extends BaseModel, RequestAuthenticationModel {
/**
* Invoked to generate a new refresh token.
*
*/
generateRefreshToken?(client: Client, user: User, scope: string | string[], callback?: Callback<string>): Promise<string>;
generateRefreshToken?(client: Client, user: User, scope: string | string[]): Promise<string>;

/**
* Invoked to generate a new authorization code.
*
*/
generateAuthorizationCode?(client: Client, user: User, scope: string | string[], callback?: Callback<string>): Promise<string>;
generateAuthorizationCode?(client: Client, user: User, scope: string | string[]): Promise<string>;

/**
* Invoked to retrieve an existing authorization code previously saved through Model#saveAuthorizationCode().
*
*/
getAuthorizationCode(authorizationCode: string, callback?: Callback<AuthorizationCode>): Promise<AuthorizationCode | Falsey>;
getAuthorizationCode(authorizationCode: string): Promise<AuthorizationCode | Falsey>;

/**
* Invoked to save an authorization code.
Expand All @@ -308,20 +300,20 @@ declare namespace OAuth2Server {
saveAuthorizationCode(
code: Pick<AuthorizationCode, 'authorizationCode' | 'expiresAt' | 'redirectUri' | 'scope' | 'codeChallenge' | 'codeChallengeMethod'>,
client: Client,
user: User,
callback?: Callback<AuthorizationCode>): Promise<AuthorizationCode | Falsey>;
user: User
): Promise<AuthorizationCode | Falsey>;

/**
* Invoked to revoke an authorization code.
*
*/
revokeAuthorizationCode(code: AuthorizationCode, callback?: Callback<boolean>): Promise<boolean>;
revokeAuthorizationCode(code: AuthorizationCode): Promise<boolean>;

/**
* Invoked to check if the requested scope is valid for a particular client/user combination.
*
*/
validateScope?(user: User, client: Client, scope: string | string[], callback?: Callback<string | Falsey>): Promise<string | string[] | Falsey>;
validateScope?(user: User, client: Client, scope: string | string[]): Promise<string | string[] | Falsey>;

/**
* Invoked to check if the provided `redirectUri` is valid for a particular `client`.
Expand All @@ -335,53 +327,53 @@ declare namespace OAuth2Server {
* Invoked to generate a new refresh token.
*
*/
generateRefreshToken?(client: Client, user: User, scope: string | string[], callback?: Callback<string>): Promise<string>;
generateRefreshToken?(client: Client, user: User, scope: string | string[]): Promise<string>;

/**
* Invoked to retrieve a user using a username/password combination.
*
*/
getUser(username: string, password: string, callback?: Callback<User | Falsey>): Promise<User | Falsey>;
getUser(username: string, password: string): Promise<User | Falsey>;

/**
* Invoked to check if the requested scope is valid for a particular client/user combination.
*
*/
validateScope?(user: User, client: Client, scope: string | string[], callback?: Callback<string | Falsey>): Promise<string | string[] | Falsey>;
validateScope?(user: User, client: Client, scope: string | string[]): Promise<string | string[] | Falsey>;
}

interface RefreshTokenModel extends BaseModel, RequestAuthenticationModel {
/**
* Invoked to generate a new refresh token.
*
*/
generateRefreshToken?(client: Client, user: User, scope: string | string[], callback?: Callback<string>): Promise<string>;
generateRefreshToken?(client: Client, user: User, scope: string | string[]): Promise<string>;

/**
* Invoked to retrieve an existing refresh token previously saved through Model#saveToken().
*
*/
getRefreshToken(refreshToken: string, callback?: Callback<RefreshToken>): Promise<RefreshToken | Falsey>;
getRefreshToken(refreshToken: string): Promise<RefreshToken | Falsey>;

/**
* Invoked to revoke a refresh token.
*
*/
revokeToken(token: RefreshToken | Token, callback?: Callback<boolean>): Promise<boolean>;
revokeToken(token: RefreshToken | Token): Promise<boolean>;
}

interface ClientCredentialsModel extends BaseModel, RequestAuthenticationModel {
/**
* Invoked to retrieve the user associated with the specified client.
*
*/
getUserFromClient(client: Client, callback?: Callback<User | Falsey>): Promise<User | Falsey>;
getUserFromClient(client: Client): Promise<User | Falsey>;

/**
* Invoked to check if the requested scope is valid for a particular client/user combination.
*
*/
validateScope?(user: User, client: Client, scope: string | string[], callback?: Callback<string | Falsey>): Promise<string | string[] | Falsey>;
validateScope?(user: User, client: Client, scope: string | string[]): Promise<string | string[] | Falsey>;
}

interface ExtensionModel extends BaseModel, RequestAuthenticationModel {}
Expand Down
6 changes: 3 additions & 3 deletions lib/handlers/authorize-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ AuthorizeHandler.prototype.handle = async function(request, response) {

const requestedScope = this.getScope(request);
const validScope = await this.validateScope(user, client, requestedScope);
const authorizationCode = this.generateAuthorizationCode(client, user, validScope);
const authorizationCode = await this.generateAuthorizationCode(client, user, validScope);

const ResponseType = this.getResponseType(request);
const codeChallenge = this.getCodeChallenge(request);
Expand Down Expand Up @@ -369,7 +369,7 @@ AuthorizeHandler.prototype.updateResponse = function(response, redirectUri, stat
};

AuthorizeHandler.prototype.getCodeChallenge = function(request) {
return request.body.code_challenge;
return request.body.code_challenge || request.query.code_challenge;
};

/**
Expand All @@ -380,7 +380,7 @@ AuthorizeHandler.prototype.getCodeChallenge = function(request) {
* (see https://www.rfc-editor.org/rfc/rfc7636#section-4.4)
*/
AuthorizeHandler.prototype.getCodeChallengeMethod = function(request) {
const algorithm = request.body.code_challenge_method;
const algorithm = request.body.code_challenge_method || request.query.code_challenge_method;

if (algorithm && !pkce.isValidMethod(algorithm)) {
throw new InvalidRequestError(`Invalid request: transform algorithm '${algorithm}' not supported`);
Expand Down
2 changes: 1 addition & 1 deletion 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.3.0",
"version": "5.0.0-rc.1",
"keywords": [
"oauth",
"oauth2"
Expand Down
7 changes: 4 additions & 3 deletions test/integration/handlers/authorize-handler_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,9 @@ describe('AuthorizeHandler integration', function() {
getClient: function() {
return client;
},
saveAuthorizationCode: function() {
return { authorizationCode: 12345, client: client };
generateAuthorizationCode: async () => 'some-code',
saveAuthorizationCode: async function(code) {
return { authorizationCode: code.authorizationCode, client: client };
}
};
const handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model });
Expand All @@ -586,7 +587,7 @@ describe('AuthorizeHandler integration', function() {
return handler.handle(request, response)
.then(function(data) {
data.should.eql({
authorizationCode: 12345,
authorizationCode: 'some-code',
client: client
});
})
Expand Down
Loading