-
Notifications
You must be signed in to change notification settings - Fork 396
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #507 from auth0/custom-auth-params
[SDK-2529] Add ability to pass custom params to refresh grant and code exchange
- Loading branch information
Showing
5 changed files
with
106 additions
and
10 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
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 |
---|---|---|
|
@@ -3,6 +3,8 @@ import { withApi } from '../fixtures/default-settings'; | |
import { get } from '../auth0-session/fixtures/helpers'; | ||
import { Session } from '../../src'; | ||
import { refreshTokenExchange, refreshTokenRotationExchange } from '../fixtures/oidc-nocks'; | ||
import { makeIdToken } from '../auth0-session/fixtures/cert'; | ||
import nock from 'nock'; | ||
|
||
describe('get access token', () => { | ||
afterEach(teardown); | ||
|
@@ -242,4 +244,36 @@ describe('get access token', () => { | |
const { idToken: newIdToken } = await get(baseUrl, '/api/session', { cookieJar }); | ||
expect(newIdToken).toBeUndefined(); | ||
}); | ||
|
||
test('should pass custom auth params in refresh grant request body', async () => { | ||
const idToken = makeIdToken({ | ||
iss: `${withApi.issuerBaseURL}/`, | ||
aud: withApi.clientID, | ||
email: '[email protected]', | ||
name: 'john doe', | ||
sub: '123' | ||
}); | ||
|
||
const spy = jest.fn(); | ||
nock(`${withApi.issuerBaseURL}`) | ||
.post('/oauth/token', /grant_type=refresh_token/) | ||
.reply(200, (_, body) => { | ||
spy(body); | ||
return { | ||
access_token: 'new-token', | ||
id_token: idToken, | ||
token_type: 'Bearer', | ||
expires_in: 750, | ||
scope: 'read:foo write:foo' | ||
}; | ||
}); | ||
|
||
const baseUrl = await setup(withApi, { | ||
getAccessTokenOptions: { refresh: true, authorizationParams: { baz: 'qux' } } | ||
}); | ||
const cookieJar = await login(baseUrl); | ||
const { accessToken } = await get(baseUrl, '/api/access-token', { cookieJar }); | ||
expect(accessToken).toEqual('new-token'); | ||
expect(spy).toHaveBeenCalledWith(expect.stringContaining('baz=qux')); | ||
}); | ||
}); |