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

fix(auth/external): add some missing url params for external auth PKCE exchanges #2812

Merged
merged 3 commits into from
Sep 12, 2023

Conversation

ThatOneBro
Copy link
Member

Closes #2810

@ThatOneBro ThatOneBro requested a review from a team as a code owner September 12, 2023 01:04
@vercel
Copy link

vercel bot commented Sep 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
medplum-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 12, 2023 1:49am
medplum-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 12, 2023 1:49am

@ThatOneBro ThatOneBro changed the title feat(auth/external): add some missing fields to PKCE search params fix(auth/external): add some missing fields to PKCE search params Sep 12, 2023
packages/core/src/client.ts Outdated Show resolved Hide resolved
@@ -1053,12 +1051,22 @@ export class MedplumClient extends EventTarget {
redirectUri: string,
loginRequest: BaseLoginRequest
): string {
const { codeChallenge, codeChallengeMethod } = loginRequest;
if (!codeChallengeMethod) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this always true? I think PKCE is optional for external auth.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the way that it's implemented there is always a call to ensureCodeChallenge() as far as I can tell. I'll double check

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently the only place where client.getExternalAuthRedirectUri() is called:

const loginRequest = await this.ensureCodeChallenge(baseLogin);
window.location.assign(this.getExternalAuthRedirectUri(authorizeUrl, clientId, redirectUri, loginRequest));

So in the current codebase it will always have a codeChallenge and codeChallengeMethod. I think in this case it's better to do this check because if they aren't there in the current codebase it is likely a bug and not intentional.

I could see a case for it being more general maybe, but if it's not planned yet then this is probably better IMO.

packages/core/src/client.ts Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Sep 12, 2023

Coverage Status

coverage: 94.154% (+0.003%) from 94.151% when pulling 90eb5ac on derrick-add-code-challenge-pkce into 1cd9119 on main.

@ThatOneBro ThatOneBro changed the title fix(auth/external): add some missing fields to PKCE search params fix(auth/external): add some missing url params for external auth PKCE exchanges Sep 12, 2023
@sonarcloud
Copy link

sonarcloud bot commented Sep 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@ThatOneBro ThatOneBro added this pull request to the merge queue Sep 12, 2023
Merged via the queue into main with commit e20ad3b Sep 12, 2023
12 checks passed
@ThatOneBro ThatOneBro deleted the derrick-add-code-challenge-pkce branch September 12, 2023 20:30
codyebberson added a commit that referenced this pull request Sep 13, 2023
Use data migrations in version numbers (#2816)
Fixes #2784 - Data migrations framework (#2786)
Fixes #2817 - add jose to bot lambda layer (#2818)
Move "public" resources into R4 Project (#2591)
fix(auth/external): add some missing url params for external auth `PKCE` exchanges (#2812)
Experiment: remove prettier from ESLint config, try out Biome (Rome fork) (#2748)
Fixes #2808 - handle observation groups in DiagnosticReportDisplay (#2809)
Adding content for Titan case study (#2806)
QuestionnaireForm Cleanup (#2801)
UI Clone for Lab Order Questionnaire (#2787)
Lab order bot (#2791)
Blog Post: GraphQL vs. Rest (#2781)
Fixes #2761 - docs for bot logs and aws athena (#2779)
Adding EMPI documentation (#2754)
Example on Lab Ordering demo (#2716)
Fixed links on about page (#2777)
Adding blog material (#2776)
Fixes #2771 - handle numeric return values from bots (#2775)
New www 'about' page (#2770)
github-merge-queue bot pushed a commit that referenced this pull request Sep 13, 2023
Use data migrations in version numbers (#2816)
Fixes #2784 - Data migrations framework (#2786)
Fixes #2817 - add jose to bot lambda layer (#2818)
Move "public" resources into R4 Project (#2591)
fix(auth/external): add some missing url params for external auth `PKCE` exchanges (#2812)
Experiment: remove prettier from ESLint config, try out Biome (Rome fork) (#2748)
Fixes #2808 - handle observation groups in DiagnosticReportDisplay (#2809)
Adding content for Titan case study (#2806)
QuestionnaireForm Cleanup (#2801)
UI Clone for Lab Order Questionnaire (#2787)
Lab order bot (#2791)
Blog Post: GraphQL vs. Rest (#2781)
Fixes #2761 - docs for bot logs and aws athena (#2779)
Adding EMPI documentation (#2754)
Example on Lab Ordering demo (#2716)
Fixed links on about page (#2777)
Adding blog material (#2776)
Fixes #2771 - handle numeric return values from bots (#2775)
New www 'about' page (#2770)
@reshmakh reshmakh added this to the September 15, 2023 milestone Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getExternalAuthRedirectUri doesn't add PKCE parameters to URL
4 participants