-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use authentication code grant instead of password grant. (#3)
- Loading branch information
Showing
9 changed files
with
138 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Change Log | ||
|
||
## v2.0.0 | ||
|
||
v2.0.0 adds support for the OAuth 2 authorization code grant, used by CollectionSpace 8.0. | ||
|
||
### Breaking Changes | ||
|
||
- The session login method now issues a request for a token using the OAuth 2 authorization code grant, instead of the password grant. This requires a CollectionSpace 8.0 server. A login attempt to an older CollectionSpace server will fail. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "cspace-client", | ||
"version": "1.1.8", | ||
"version": "2.0.0-rc.1", | ||
"description": "CollectionSpace client for browsers and Node.js", | ||
"author": "Ray Lee <[email protected]>", | ||
"license": "ECL-2.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,31 +14,23 @@ describe('session', () => { | |
|
||
it('should set default options', () => { | ||
session().config().should.deep.equal({ | ||
username: '', | ||
authCode: '', | ||
codeVerifier: '', | ||
redirectUri: '', | ||
}); | ||
}); | ||
|
||
it('should override default options with passed options', () => { | ||
const config = { | ||
username: '[email protected]', | ||
password: 'secret', | ||
authCode: 'abcd', | ||
codeVerifier: '123', | ||
redirectUri: '/authorized', | ||
}; | ||
|
||
session(config).config().should.deep.equal({ | ||
username: '[email protected]', | ||
}); | ||
}); | ||
}); | ||
|
||
describe('#config()', () => { | ||
it('should omit the password', () => { | ||
const config = { | ||
username: '[email protected]', | ||
password: 'secret', | ||
}; | ||
|
||
session(config).config().should.deep.equal({ | ||
username: '[email protected]', | ||
authCode: 'abcd', | ||
codeVerifier: '123', | ||
redirectUri: '/authorized', | ||
}); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,10 @@ const clientConfig = { | |
}; | ||
|
||
const sessionConfig = { | ||
username: '[email protected]', | ||
password: 'secret', | ||
authCode: 'abcd', | ||
clientId: 'cpace-ui', | ||
codeVerifier: '123', | ||
redirectUri: '/authorized', | ||
}; | ||
|
||
let accessToken; | ||
|
@@ -42,17 +44,17 @@ describe(`token management on ${clientConfig.url}`, function suite() { | |
.be.rejected | ||
)); | ||
|
||
it('reuses the stored token in a new session with no user', () => { | ||
it('reuses the stored token in a new session with no auth code', () => { | ||
const newSession = cspace.session(); | ||
|
||
return newSession.read('something').should.eventually | ||
.be.fulfilled | ||
.and.have.deep.property('data.presentedToken', accessToken); | ||
}); | ||
|
||
it('does not reuse the stored token in a new session with a different user', () => { | ||
it('does not reuse the stored token in a new session with an auth code', () => { | ||
const newSession = cspace.session({ | ||
username: '[email protected]', | ||
authCode: 'xyz', | ||
}); | ||
|
||
return newSession.read('something').should.eventually | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters