From bb3ab9b9036aa64ac2f04c96ee9311dadfcbb095 Mon Sep 17 00:00:00 2001 From: avdb13 Date: Sun, 24 Nov 2024 00:06:54 +0000 Subject: [PATCH] feat: add PKCE --- package.json | 2 +- .../create-or-edit-oauth-provider-modal.tsx | 13 +++++++ src/shared/components/home/login.tsx | 39 ++++++++++++++----- .../components/home/oauth/oauth-callback.tsx | 3 ++ .../home/oauth/oauth-provider-list-item.tsx | 4 ++ .../home/oauth/oauth-providers-tab.tsx | 1 + src/shared/utils/helpers/oauth.ts | 19 +++++++++ 7 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 src/shared/utils/helpers/oauth.ts diff --git a/package.json b/package.json index 143cd234..fa563280 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "inferno-router": "^8.2.3", "inferno-server": "^8.2.3", "jwt-decode": "^4.0.0", - "lemmy-js-client": "0.20.0-alpha.17", + "lemmy-js-client": "0.20.0-pkce.1", "lodash.isequal": "^4.5.0", "markdown-it": "^14.1.0", "markdown-it-bidi": "^0.2.0", diff --git a/src/shared/components/common/modal/create-or-edit-oauth-provider-modal.tsx b/src/shared/components/common/modal/create-or-edit-oauth-provider-modal.tsx index a0112f27..e7a63e44 100644 --- a/src/shared/components/common/modal/create-or-edit-oauth-provider-modal.tsx +++ b/src/shared/components/common/modal/create-or-edit-oauth-provider-modal.tsx @@ -51,6 +51,7 @@ interface ProviderTextFieldProps extends ProviderFieldProps { type ProviderBooleanProperties = | "enabled" + | "use_pkce" | "account_linking_enabled" | "auto_verify_email"; @@ -337,6 +338,18 @@ export default class CreateOrEditOAuthProviderModal extends Component< handleBooleanPropertyChange, )} /> + { show_nsfw: local_oauth_state.show_nsfw, username: local_oauth_state.username, answer: local_oauth_state.answer, + ...(local_oauth_state?.pkce_code_verifier && { + pkce_code_verifier: local_oauth_state.pkce_code_verifier, + }), }); switch (loginRes.state) { diff --git a/src/shared/components/home/oauth/oauth-provider-list-item.tsx b/src/shared/components/home/oauth/oauth-provider-list-item.tsx index e87ae3f1..b538e5a2 100644 --- a/src/shared/components/home/oauth/oauth-provider-list-item.tsx +++ b/src/shared/components/home/oauth/oauth-provider-list-item.tsx @@ -86,6 +86,10 @@ export default function OAuthProviderListItem({ i18nKey="oauth_account_linking_enabled" data={boolToYesNo(provider.account_linking_enabled)} /> +