add audience param to implicit oauth grant closes #1008 (#1009)

This commit is contained in:
Drew Delianides 2018-06-26 09:31:37 -06:00 committed by Gregory Schier
parent b4caac21ed
commit 3b58c994f8
4 changed files with 9 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import { globalBeforeEach } from '../../../__jest__/before-each';
const AUTHORIZE_URL = 'https://foo.com/authorizeAuthCode'; const AUTHORIZE_URL = 'https://foo.com/authorizeAuthCode';
const CLIENT_ID = 'client_123'; const CLIENT_ID = 'client_123';
const REDIRECT_URI = 'https://foo.com/redirect'; const REDIRECT_URI = 'https://foo.com/redirect';
const AUDIENCE = 'https://foo.com/userinfo';
const SCOPE = 'scope_123'; const SCOPE = 'scope_123';
const STATE = 'state_123'; const STATE = 'state_123';
@ -21,7 +22,8 @@ describe('implicit', () => {
CLIENT_ID, CLIENT_ID,
REDIRECT_URI, REDIRECT_URI,
SCOPE, SCOPE,
STATE STATE,
AUDIENCE
); );
expect(result).toEqual({ expect(result).toEqual({

View File

@ -128,7 +128,8 @@ async function _getOAuth2ImplicitHeader(
authentication.responseType, authentication.responseType,
authentication.redirectUrl, authentication.redirectUrl,
authentication.scope, authentication.scope,
authentication.state authentication.state,
authentication.audience
); );
return _updateOAuth2Token(requestId, results); return _updateOAuth2Token(requestId, results);

View File

@ -13,7 +13,8 @@ export default async function(
responseType: string = c.RESPONSE_TYPE_TOKEN, responseType: string = c.RESPONSE_TYPE_TOKEN,
redirectUri: string = '', redirectUri: string = '',
scope: string = '', scope: string = '',
state: string = '' state: string = '',
audience: string = ''
): Promise<Object> { ): Promise<Object> {
const params = [ const params = [
{ name: c.P_RESPONSE_TYPE, value: responseType }, { name: c.P_RESPONSE_TYPE, value: responseType },
@ -32,6 +33,7 @@ export default async function(
redirectUri && params.push({ name: c.P_REDIRECT_URI, value: redirectUri }); redirectUri && params.push({ name: c.P_REDIRECT_URI, value: redirectUri });
scope && params.push({ name: c.P_SCOPE, value: scope }); scope && params.push({ name: c.P_SCOPE, value: scope });
state && params.push({ name: c.P_STATE, value: state }); state && params.push({ name: c.P_STATE, value: state });
audience && params.push({ name: c.P_AUDIENCE, value: audience });
// Add query params to URL // Add query params to URL
const qs = buildQueryStringFromParams(params); const qs = buildQueryStringFromParams(params);

View File

@ -458,7 +458,7 @@ class OAuth2Auth extends React.PureComponent<Props, State> {
} else if (grantType === GRANT_TYPE_IMPLICIT) { } else if (grantType === GRANT_TYPE_IMPLICIT) {
basicFields = [authorizationUrl, clientId, redirectUri, enabled]; basicFields = [authorizationUrl, clientId, redirectUri, enabled];
advancedFields = [responseType, scope, state, tokenPrefix]; advancedFields = [responseType, scope, state, tokenPrefix, audience];
} }
return { basic: basicFields, advanced: advancedFields }; return { basic: basicFields, advanced: advancedFields };