Skip to content

Commit

Permalink
Merge pull request #44 from kinde-oss/peter/feat/support-multiple-aud…
Browse files Browse the repository at this point in the history
…iences

feat: support multiple audiences
  • Loading branch information
DaveOrDead authored Jan 23, 2024
2 parents e71146d + 8712dcc commit db341e1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
13 changes: 9 additions & 4 deletions lib/sdk/oauth2-flows/AuthCodeAbstract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,6 @@ export abstract class AuthCodeAbstract {
scope: this.config.scope ?? AuthCodeAbstract.DEFAULT_TOKEN_SCOPES,
};

if (this.config.audience) {
searchParamsObject.audience = this.config.audience;
}

if (options.start_page) {
searchParamsObject.start_page = options.start_page;
}
Expand All @@ -275,6 +271,15 @@ export abstract class AuthCodeAbstract {
for (const key in searchParamsObject)
searchParams.append(key, searchParamsObject[key]);

if (this.config.audience) {
const audienceArray = Array.isArray(this.config.audience) ? this.config.audience : [this.config.audience];

audienceArray
.forEach((aud) => {
searchParams.append('audience', aud);
});
}

return searchParams;
}
}
7 changes: 6 additions & 1 deletion lib/sdk/oauth2-flows/ClientCredentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ export class ClientCredentials {
});

if (this.config.audience) {
searchParams.append('audience', this.config.audience);
const audienceArray = Array.isArray(this.config.audience) ? this.config.audience : [this.config.audience];

audienceArray
.forEach((aud) => {
searchParams.append('audience', aud);
});
}

return new URLSearchParams(searchParams);
Expand Down
2 changes: 1 addition & 1 deletion lib/sdk/oauth2-flows/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface OAuth2FlowOptions {
clientId: string;
logoutRedirectURL: string;
authDomain: string;
audience?: string;
audience?: string | string[];
scope?: string;
}

Expand Down

0 comments on commit db341e1

Please sign in to comment.