From b96a682eb8bcd2597a1e47ae3bd9b85737c120c0 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 3 Aug 2022 16:34:36 +0200 Subject: [PATCH] Client - add PKCE support when authorizing an app --- .../src/components/User/UserApps/AuthorizeUserApp.vue | 10 +++++++++- fittrackee_client/src/store/modules/oauth2/actions.ts | 6 ++++++ fittrackee_client/src/types/oauth.ts | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/fittrackee_client/src/components/User/UserApps/AuthorizeUserApp.vue b/fittrackee_client/src/components/User/UserApps/AuthorizeUserApp.vue index c373bdd1..c471f402 100644 --- a/fittrackee_client/src/components/User/UserApps/AuthorizeUserApp.vue +++ b/fittrackee_client/src/components/User/UserApps/AuthorizeUserApp.vue @@ -73,7 +73,15 @@ redirect_uri: `${route.query.redirect_uri}`, response_type: `${route.query.response_type}`, scope: `${route.query.scope}`, - state: `${route.query.state}`, + state: `${route.query.state ? route.query.state : ''}`, + code_challenge: `${ + route.query.code_challenge ? route.query.code_challenge : '' + }`, + code_challenge_method: `${ + route.query.code_challenge_method + ? route.query.code_challenge_method + : '' + }`, }) } diff --git a/fittrackee_client/src/store/modules/oauth2/actions.ts b/fittrackee_client/src/store/modules/oauth2/actions.ts index 54c62c9c..69d6b8f4 100644 --- a/fittrackee_client/src/store/modules/oauth2/actions.ts +++ b/fittrackee_client/src/store/modules/oauth2/actions.ts @@ -43,6 +43,12 @@ export const actions: ActionTree & IOAuth2Actions = { if (payload.state) { form.set('state', payload.state) } + if (payload.code_challenge) { + form.set('code_challenge', payload.code_challenge) + } + if (payload.code_challenge_method) { + form.set('code_challenge_method', payload.code_challenge_method) + } authApi .post('oauth/authorize', form, { diff --git a/fittrackee_client/src/types/oauth.ts b/fittrackee_client/src/types/oauth.ts index e2b552d2..7a6f6b4b 100644 --- a/fittrackee_client/src/types/oauth.ts +++ b/fittrackee_client/src/types/oauth.ts @@ -27,5 +27,7 @@ export interface IOAuth2ClientAuthorizePayload { redirect_uri: string response_type: string scope: string - state?: string + state: string + code_challenge: string + code_challenge_method: string }