From eae0e7647881b19bd8114e270204dbb12e7e4266 Mon Sep 17 00:00:00 2001 From: ase-101 Date: Wed, 24 Jan 2024 00:07:07 +0530 Subject: [PATCH 01/20] Version changed to 1.0.0 Signed-off-by: ase-101 --- pom.xml | 2 +- signup-service/pom.xml | 10 +++---- .../resources/application-default.properties | 18 +++---------- .../resources/application-test.properties | 26 ++++++++++--------- 4 files changed, 24 insertions(+), 32 deletions(-) diff --git a/pom.xml b/pom.xml index 42badbe2..0665c0c0 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ 4.0.0 io.mosip.signup signup-parent - 0.0.1-SNAPSHOT + 1.0.0-SNAPSHOT pom esignet-signup Parent project of MOSIP e-Signet diff --git a/signup-service/pom.xml b/signup-service/pom.xml index 1dfd5854..44211a91 100644 --- a/signup-service/pom.xml +++ b/signup-service/pom.xml @@ -15,7 +15,7 @@ io.mosip.signup signup-service - 0.0.1-SNAPSHOT + 1.0.0-SNAPSHOT signup-service Sign Up Service https://github.com/DGTDept/esignet-signup @@ -115,7 +115,7 @@ io.mosip.esignet esignet-core - 1.1.0 + 1.3.0-SNAPSHOT org.springframework.boot @@ -151,12 +151,12 @@ io.mosip.kernel kernel-core - 1.2.0.1-B1 + 1.2.0.1-B2 io.mosip.kernel kernel-logger-logback - 1.2.0.1-B1 + 1.2.0.1-B2 io.mosip.kernel @@ -172,7 +172,7 @@ io.mosip.esignet esignet-integration-api - 1.1.0 + 1.3.0-SNAPSHOT org.mockito diff --git a/signup-service/src/main/resources/application-default.properties b/signup-service/src/main/resources/application-default.properties index 978b8290..dd9c19d2 100644 --- a/signup-service/src/main/resources/application-default.properties +++ b/signup-service/src/main/resources/application-default.properties @@ -8,17 +8,7 @@ mosip.signup.password.pattern=^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[\\x5F\\W]) mosip.signup.password.max-length=20 mosip.signup.generate-challenge.blocked.timeout=300 mosip.signup.challenge.timeout=60 - mosip.signup.audit.description.max-length=2048 - -## Application Name -spring.application.name=signup - -server.port=8088 -server.servlet.path=/ -spring.mvc.servlet.path=${server.servlet.path} -server.servlet.context-path=/v1/signup -server.env.url=https://api-internal.camdgc-dev.mosip.net mosip.signup.password.min-length=8 mosip.signup.fullname.pattern=^[\\u1780-\\u17FF\\u19E0-\\u19FF\\u1A00-\\u1A9F\\u0020]{1,30}$ @@ -70,9 +60,9 @@ mosip.esignet.cache.expire-in-seconds={'challenge_generated': ${mosip.signup.una 'key_alias' : ${mosip.signup.verified.txn.timeout} } ## ------------------------------------- Auth adapter ------------------------------------------------------------------ -mosip.api.internal.url=https://api-internal.camdgc-dev.mosip.net -keycloak.external.url=https://iam.camdgc-dev.mosip.net -keycloak.internal.url=https://iam.camdgc-dev.mosip.net +mosip.api.internal.url=https://api-internal.dev.mosip.net +keycloak.external.url=https://iam.dev.mosip.net +keycloak.internal.url=https://iam.dev.mosip.net auth.server.validate.url=${mosip.api.internal.url}/v1/authmanager/authorize/admin/validateToken auth.server.admin.issuer.uri=${keycloak.external.url}/auth/realms/ auth-token-generator.rest.issuerUrl=${keycloak.internal.url}/auth/realms/mosip @@ -135,7 +125,7 @@ mosip.signup.ui.config.key-values={\ 'status.request.delay': ${mosip.signup.status.request.delay}, \ 'status.request.limit': ${mosip.signup.status.request.limit}, \ 'popup.timeout': 10, \ -'signin.redirect-url': 'https://esignet.camdgc-dev.mosip.net/authorize', \ +'signin.redirect-url': 'https://esignet.dev.mosip.net/authorize', \ 'identifier.allowed.characters': '^[0-9]+', \ 'identifier.length.min': 8, \ 'identifier.length.max': 9, \ diff --git a/signup-service/src/test/resources/application-test.properties b/signup-service/src/test/resources/application-test.properties index b1dba684..756dd857 100644 --- a/signup-service/src/test/resources/application-test.properties +++ b/signup-service/src/test/resources/application-test.properties @@ -79,9 +79,9 @@ mosip.esignet.cache.expire-in-seconds={'challenge_generated': ${mosip.signup.una 'key_alias' : ${mosip.signup.verified.txn.timeout} } ## ------------------------------------- Auth adapter ------------------------------------------------------------------ -mosip.kernel.authmanager.url=https://api-internal.camdgc-dev.mosip.net -keycloak.external.url=https://iam.camdgc-dev.mosip.net -keycloak.internal.url=https://iam.camdgc-dev.mosip.net +mosip.kernel.authmanager.url=https://api-internal.dev.mosip.net +keycloak.external.url=https://iam.dev.mosip.net +keycloak.internal.url=https://iam.dev.mosip.net auth.server.validate.url=${mosip.kernel.authmanager.url}/v1/authmanager/authorize/admin/validateToken auth.server.admin.issuer.uri=${keycloak.external.url}/auth/realms/ auth-token-generator.rest.issuerUrl=${keycloak.internal.url}/auth/realms/mosip @@ -106,10 +106,10 @@ mosip.service.exclude.auth.allowed.method=GET,POST ## -------------------------- External endpoints ----------------------------------------------------------------------- mosip.signup.generate-challenge.endpoint=${mosip.kernel.authmanager.url}/v1/otpmanager/otp/generate -mosip.signup.add-identity.endpoint=https://api-internal.camdgc-dev.mosip.net/idrepository/v1/identity/ -mosip.signup.generate-hash.endpoint=https://api-internal.camdgc-dev.mosip.net/v1/keymanager/generateArgon2Hash -mosip.signup.get-uin.endpoint=https://api-internal.camdgc-dev.mosip.net/v1/idgenerator/uin -mosip.signup.send-notification.endpoint=https://api-internal.camdgc-dev.mosip.net/v1/notifier/sms/send +mosip.signup.add-identity.endpoint=https://api-internal.dev.mosip.net/idrepository/v1/identity/ +mosip.signup.generate-hash.endpoint=https://api-internal.dev.mosip.net/v1/keymanager/generateArgon2Hash +mosip.signup.get-uin.endpoint=https://api-internal.dev.mosip.net/v1/idgenerator/uin +mosip.signup.send-notification.endpoint=https://api-internal.dev.mosip.net/v1/notifier/sms/send mosip.signup.add-identity.request.id=mosip.id.create mosip.signup.add-identity.request.version=v1 @@ -135,13 +135,15 @@ mosip.signup.ui.config.key-values={\ 'fullname.pattern': '${mosip.signup.fullname.pattern}', \ 'status.request.delay': '${mosip.signup.status.request.delay}', \ 'status.request.limit': '${mosip.signup.status.request.limit}', \ -'signin.redirect-url': 'https://esignet.camdgc-dev.mosip.net/authorize' \ +'signin.redirect-url': 'https://esignet.dev.mosip.net/authorize' \ } ## ----------------------------- SMS-message ----------------------------------------------------------------------------- -mosip.signup.otp-registration.sms.khm=ប្រើ XXXXXX ដើម្បីផ្ទៀងផ្ទាត់គណនី KhID របស់អ្នក។ -mosip.signup.otp-registration.sms.eng=Use XXXXXX to verify your KhID account. -mosip.signup.successfully.registration.sms.khm=ប្រើ XXXXXX ដើម្បីផ្ទៀងផ្ទាត់គណនី KhID របស់អ្នក។ -mosip.signup.successfully.registration.sms.eng=Use XXXXXX to verify your KhID account. +mosip.signup.sms-notification-template.send-otp.khm=4Z6U4Z+S4Z6a4Z6+IHtjaGFsbGVuZ2V9IOGeiuGevuGemOGfkuGelOGeuOGeleGfkuGekeGfgOGehOGeleGfkuGekeGetuGej+Gfi+GeguGejuGek+GeuCBLaElEIOGemuGelOGen+Gfi+GeouGfkuGek+GegOGflA== +mosip.signup.sms-notification-template.send-otp.eng=Use {challenge} to verify your KhID account. +mosip.signup.sms-notification-template.registration.khm=4Z6i4Z+S4Z6T4Z6A4Z6U4Z624Z6T4Z6F4Z674Z+H4Z6I4Z+S4Z6Y4Z+E4Z+H4Z6C4Z6O4Z6T4Z64IEtoSUQg4Z6K4Z+E4Z6Z4Z6H4Z+E4Z6C4Z6H4Z+Q4Z6Z4Z+U +mosip.signup.sms-notification-template.registration.eng=You successfully registered to KhID account. +mosip.signup.sms-notification-template.forgot-passsword.khm=4Z6i4Z+S4Z6T4Z6A4Z6U4Z624Z6T4Z6V4Z+S4Z6b4Z624Z6f4Z+L4Z6U4Z+S4Z6K4Z684Z6a4Z6W4Z624Z6A4Z+S4Z6Z4Z6f4Z6Y4Z+S4Z6E4Z624Z6P4Z+LIEtoSUQg4Z6K4Z+E4Z6Z4Z6H4Z+E4Z6C4Z6H4Z+Q4Z6Z4Z+U +mosip.signup.sms-notification-template.forgot-passsword.eng=You successfully changed KhID password. #------------------------------------------ Others --------------------------------------------------------------------- logging.level.io.mosip.signup=DEBUG From 2a1a70aac6f710cef1163ec572be2ed1c320518c Mon Sep 17 00:00:00 2001 From: ase-101 Date: Wed, 24 Jan 2024 00:13:44 +0530 Subject: [PATCH 02/20] Changed to develop version Signed-off-by: ase-101 --- pom.xml | 2 +- signup-service/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 0665c0c0..4e4b441e 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ 4.0.0 io.mosip.signup signup-parent - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT pom esignet-signup Parent project of MOSIP e-Signet diff --git a/signup-service/pom.xml b/signup-service/pom.xml index 44211a91..b41af416 100644 --- a/signup-service/pom.xml +++ b/signup-service/pom.xml @@ -15,7 +15,7 @@ io.mosip.signup signup-service - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT signup-service Sign Up Service https://github.com/DGTDept/esignet-signup From 6881b3a479fbcbafd7b0b35e4779e7f040768957 Mon Sep 17 00:00:00 2001 From: ase-101 Date: Wed, 24 Jan 2024 00:27:56 +0530 Subject: [PATCH 03/20] Removed camdgc reference Signed-off-by: ase-101 --- .../signup_001.postman_collection.json | 10 ++++------ .../mosip/signup/controllers/SignUpControllerTest.java | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/postman-collections/signup_001.postman_collection.json b/docs/postman-collections/signup_001.postman_collection.json index 3e22ec9f..b0464dbb 100644 --- a/docs/postman-collections/signup_001.postman_collection.json +++ b/docs/postman-collections/signup_001.postman_collection.json @@ -384,14 +384,12 @@ } ], "url": { - "raw": "https://api-internal.camdgc-dev.mosip.net/v1/signup/settings", - "protocol": "https", + "raw": "http://localhost:8088/v1/signup/settings", + "protocol": "http", "host": [ - "api-internal", - "camdgc-dev", - "mosip", - "net" + "localhost" ], + "port": "8088", "path": [ "v1", "signup", diff --git a/signup-service/src/test/java/io/mosip/signup/controllers/SignUpControllerTest.java b/signup-service/src/test/java/io/mosip/signup/controllers/SignUpControllerTest.java index 89a6fe43..d0bc5319 100644 --- a/signup-service/src/test/java/io/mosip/signup/controllers/SignUpControllerTest.java +++ b/signup-service/src/test/java/io/mosip/signup/controllers/SignUpControllerTest.java @@ -70,7 +70,7 @@ public void getSignupSettings_thenPass () throws Exception { .andExpect(jsonPath("$['response']['configs']['fullname.pattern']").value("^[\\u1780-\\u17FF\\u19E0-\\u19FF\\u1A00-\\u1A9F\\u0020]{1,30}$")) .andExpect(jsonPath("$['response']['configs']['status.request.delay']").value(20)) .andExpect(jsonPath("$['response']['configs']['status.request.limit']").value(10)) - .andExpect(jsonPath("$['response']['configs']['signin.redirect-url']").value("https://esignet.camdgc-dev.mosip.net/authorize")) + .andExpect(jsonPath("$['response']['configs']['signin.redirect-url']").value("https://esignet.dev.mosip.net/authorize")) .andExpect(jsonPath("$.errors").isEmpty()); } From 7a7bcab1603dbcb10adaf8118a57b966df815bcd Mon Sep 17 00:00:00 2001 From: pr Date: Wed, 24 Jan 2024 16:07:54 +0700 Subject: [PATCH 04/20] ES-710 Signed-off-by: pr --- .../src/main/resources/application-default.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/signup-service/src/main/resources/application-default.properties b/signup-service/src/main/resources/application-default.properties index 978b8290..70da9258 100644 --- a/signup-service/src/main/resources/application-default.properties +++ b/signup-service/src/main/resources/application-default.properties @@ -151,8 +151,8 @@ mosip.signup.sms-notification-template.send-otp.khm=4Z6U4Z+S4Z6a4Z6+IHtjaGFsbGVu mosip.signup.sms-notification-template.send-otp.eng=Use {challenge} to verify your KhID account. mosip.signup.sms-notification-template.registration.khm=4Z6i4Z+S4Z6T4Z6A4Z6U4Z624Z6T4Z6F4Z674Z+H4Z6I4Z+S4Z6Y4Z+E4Z+H4Z6C4Z6O4Z6T4Z64IEtoSUQg4Z6K4Z+E4Z6Z4Z6H4Z+E4Z6C4Z6H4Z+Q4Z6Z4Z+U mosip.signup.sms-notification-template.registration.eng=You successfully registered to KhID account. -mosip.signup.sms-notification-template.forgot-passsword.khm=4Z6i4Z+S4Z6T4Z6A4Z6U4Z624Z6T4Z6V4Z+S4Z6b4Z624Z6f4Z+L4Z6U4Z+S4Z6K4Z684Z6a4Z6W4Z624Z6A4Z+S4Z6Z4Z6f4Z6Y4Z+S4Z6E4Z624Z6P4Z+LIEtoSUQg4Z6K4Z+E4Z6Z4Z6H4Z+E4Z6C4Z6H4Z+Q4Z6Z4Z+U -mosip.signup.sms-notification-template.forgot-passsword.eng=You successfully changed KhID password. +mosip.signup.sms-notification-template.forgot-password.khm=4Z6i4Z+S4Z6T4Z6A4Z6U4Z624Z6T4Z6V4Z+S4Z6b4Z624Z6f4Z+L4Z6U4Z+S4Z6K4Z684Z6a4Z6W4Z624Z6A4Z+S4Z6Z4Z6f4Z6Y4Z+S4Z6E4Z624Z6P4Z+LIEtoSUQg4Z6K4Z+E4Z6Z4Z6H4Z+E4Z6C4Z6H4Z+Q4Z6Z4Z+U +mosip.signup.sms-notification-template.forgot-password.eng=You successfully changed KhID password. #------------------------------------------ Others --------------------------------------------------------------------- logging.level.io.mosip.signup=DEBUG From 52247511b09346e5538ce39d1dce44147547a305 Mon Sep 17 00:00:00 2001 From: Bunsy Date: Wed, 24 Jan 2024 16:42:40 +0700 Subject: [PATCH 05/20] fix: fix validation message translation Signed-off-by: Bunsy --- signup-ui/src/components/ui/form.tsx | 6 +++++- signup-ui/src/pages/shared/validation.ts | 18 +++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/signup-ui/src/components/ui/form.tsx b/signup-ui/src/components/ui/form.tsx index ffa832f9..3bbcd34f 100644 --- a/signup-ui/src/components/ui/form.tsx +++ b/signup-ui/src/components/ui/form.tsx @@ -9,6 +9,7 @@ import { FormProvider, useFormContext, } from "react-hook-form"; +import { useTranslation } from "react-i18next"; import { Label } from "~components/ui/label"; import { cn } from "~utils/cn"; @@ -146,7 +147,10 @@ const FormMessage = React.forwardRef< React.HTMLAttributes >(({ className, children, ...props }, ref) => { const { error, formMessageId } = useFormField(); - const body = error ? String(error?.message) : children; + const { t } = useTranslation(); + + // @ts-ignore + const body: React.ReactNode = error ? t(String(error.message)) : children; if (!body) { return null; diff --git a/signup-ui/src/pages/shared/validation.ts b/signup-ui/src/pages/shared/validation.ts index b6dc7242..dfb773f3 100644 --- a/signup-ui/src/pages/shared/validation.ts +++ b/signup-ui/src/pages/shared/validation.ts @@ -8,10 +8,10 @@ export const validateUsername = (settings: SettingsDto, t: TFunction) => .string() .trim() .matches(/^[^0].*$/, { - message: t("username_lead_zero_validation"), + message: "username_lead_zero_validation", excludeEmptyString: true, }) - .test("isUsernameValid", t("username_validation"), (value) => { + .test("isUsernameValid", "username_validation", (value) => { if (value === "") return true; return new RegExp(settings.response.configs["identifier.pattern"]).test( `${settings.response.configs["identifier.prefix"]}${value}` @@ -19,15 +19,15 @@ export const validateUsername = (settings: SettingsDto, t: TFunction) => }); export const validateCaptchaToken = (t: TFunction) => - yup.string().required(t("captcha_token_validation")); + yup.string().required("captcha_token_validation"); export const validateFullName = (settings: SettingsDto, t: TFunction) => yup .string() .strict(true) - .trim(t("full_name_all_spaces_validation")) + .trim("full_name_all_spaces_validation") .matches(new RegExp(settings.response.configs["fullname.pattern"]), { - message: t("full_name_in_lng_validation"), + message: "full_name_in_lng_validation", excludeEmptyString: true, }); @@ -41,7 +41,7 @@ export const validatePassword = (settings: SettingsDto, t: TFunction) => .string() .trim() .matches(new RegExp(settings.response.configs["password.pattern"]), { - message: t("password_validation"), + message: "password_validation", excludeEmptyString: true, }); @@ -55,12 +55,12 @@ export const validateConfirmPassword = ( .string() .trim() .matches(new RegExp(settings.response.configs["password.pattern"]), { - message: t("password_validation"), + message: "password_validation", excludeEmptyString: true, }) .oneOf( [yup.ref(passwordRef), ""], isRegister - ? t("register_password_validation_must_match") - : t("password_validation_must_match") + ? "register_password_validation_must_match" + : "password_validation_must_match" ); From 7cbdb09cdb9c6ce060eaababd997475011b3d9d8 Mon Sep 17 00:00:00 2001 From: Sreang Rathanak Date: Wed, 24 Jan 2024 17:26:03 +0700 Subject: [PATCH 06/20] Forgot password feature: Displayed incorrect error message when unregistered Username is entered. Signed-off-by: Sreang Rathanak --- signup-ui/public/locales/en.json | 6 ++--- signup-ui/public/locales/km.json | 8 +++---- .../src/pages/ResetPasswordPage/Otp/Otp.tsx | 3 ++- .../ResetPasswordPage/ResetPasswordPage.tsx | 6 ++--- .../ResetPasswordPopover.tsx | 23 ++++++++++++------- signup-ui/src/typings/types.ts | 12 ++++++++++ 6 files changed, 39 insertions(+), 19 deletions(-) diff --git a/signup-ui/public/locales/en.json b/signup-ui/public/locales/en.json index bf4eb82b..2e285463 100644 --- a/signup-ui/public/locales/en.json +++ b/signup-ui/public/locales/en.json @@ -121,9 +121,9 @@ "not_registered": "Not Registered", "reset_pwd_failed": "Reset Password Failed", "identifier_already_registered": "Identifier already registered", - "identifier_not_found": "Identifier not found", - "invalid_kba_challenge": "Invalid Fullname challenge", - "kba_challenge_not_found": "Fullname challenge not found", + "identifier_not_found": "Invalid number or name. Please enter a registered mobile number and full name.", + "invalid_kba_challenge": "Invalid number or name. Please enter a registered mobile number and full name.", + "kba_challenge_not_found": "Invalid number or name. Please enter a registered mobile number and full name.", "identity_inactive": "Identifier inactive", "fetch_identity_failed": "Fetch Identifier Failed", "challenge_format_and_type_mismatch": "Challenge format and type mismatch", diff --git a/signup-ui/public/locales/km.json b/signup-ui/public/locales/km.json index a0a4d10b..efac5a54 100644 --- a/signup-ui/public/locales/km.json +++ b/signup-ui/public/locales/km.json @@ -121,12 +121,12 @@ "not_registered": "មិនបានចុះឈ្មោះ", "reset_pwd_failed": "ការកំណត់ពាក្យសម្ងាត់ឡើងវិញបានបរាជ័យ", "identifier_already_registered": "អត្តសញ្ញាណបានចុះឈ្មោះរួចហើយ", - "identifier_not_found": "រកមិនឃើញអត្តសញ្ញាណ", - "invalid_kba_challenge": "ឈ្មោះមិនត្រឹមត្រូវ", - "kba_challenge_not_found": "រកមិនឃើញឈ្មោះ", + "identifier_not_found": "លេខទូរស័ព្ទ ឬឈ្មោះមិនត្រឹមត្រូវ។ សូមបញ្ចូលលេខទូរស័ព្ទនិងឈ្មោះដែលបានចុះឈ្មោះ។", + "invalid_kba_challenge": "លេខទូរស័ព្ទ ឬឈ្មោះមិនត្រឹមត្រូវ។ សូមបញ្ចូលលេខទូរស័ព្ទនិងឈ្មោះដែលបានចុះឈ្មោះ។", + "kba_challenge_not_found": "លេខទូរស័ព្ទ ឬឈ្មោះមិនត្រឹមត្រូវ។ សូមបញ្ចូលលេខទូរស័ព្ទនិងឈ្មោះដែលបានចុះឈ្មោះ។", "identity_inactive": "អត្តសញ្ញាណអសកម្ម", "fetch_identity_failed": "ទាញ​យក​លេខ​សម្គាល់​បាន​បរាជ័យ", - "challenge_format_and_type_mismatch": "ទម្រង់និងប្រភេទមិនត្រូវគ្នា", + "challenge_format_and_type_mismatch": "លេខទូរស័ព្ទ ឬឈ្មោះមិនត្រឹមត្រូវ។ សូមបញ្ចូលលេខទូរស័ព្ទនិងឈ្មោះដែលបានចុះឈ្មោះ។", "knowledgebase_mismatch": "លេខទូរស័ព្ទ ឬឈ្មោះមិនត្រឹមត្រូវ។ សូមបញ្ចូលលេខទូរស័ព្ទនិងឈ្មោះដែលបានចុះឈ្មោះ។", "IDR-IDC-001": "រកមិនឃើញតម្លៃដែលបានបញ្ចូល", "IDR-IDC-002": "តម្លៃដែលបានបញ្ចូលមិនត្រឹមត្រូវ", diff --git a/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx b/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx index 480120d1..d28846b7 100644 --- a/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx @@ -32,6 +32,7 @@ import { ResetPasswordForm, SettingsDto, VerifyChallengeRequestDto, + ResetPasswordPossibleInvalid, } from "~typings/types"; import { resetPasswordFormDefaultValues } from "../ResetPasswordPage"; @@ -203,7 +204,7 @@ export const Otp = ({ methods, settings }: OtpProps) => { onSuccess: ({ errors }) => { if (errors.length > 0) { if ( - ["invalid_transaction", "knowledgebase_mismatch"].includes( + ResetPasswordPossibleInvalid.includes( errors[0].errorCode ) ) { diff --git a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx index ff6345d1..a276e496 100644 --- a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx @@ -14,7 +14,7 @@ import { validatePassword, validateUsername, } from "~pages/shared/validation"; -import { ResetPasswordForm, SettingsDto } from "~typings/types"; +import { ResetPasswordForm, ResetPasswordPossibleInvalid, SettingsDto } from "~typings/types"; import Otp from "./Otp"; import ResetPassword from "./ResetPassword"; @@ -108,7 +108,7 @@ export const ResetPasswordPage = ({ settings }: ResetPasswordPageProps) => { if ( step === ResetPasswordStep.ResetPasswordConfirmation || (criticalError && - ["invalid_transaction", "knowledgebase_mismatch"].includes( + ["invalid_transaction", ...ResetPasswordPossibleInvalid].includes( criticalError.errorCode )) ) @@ -149,7 +149,7 @@ export const ResetPasswordPage = ({ settings }: ResetPasswordPageProps) => { return ( <> {criticalError && - ["invalid_transaction", "knowledgebase_mismatch"].includes( + ["invalid_transaction", ...ResetPasswordPossibleInvalid].includes( criticalError.errorCode ) && }
diff --git a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPopover.tsx b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPopover.tsx index bbdb3436..c6f32bc5 100644 --- a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPopover.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPopover.tsx @@ -1,6 +1,6 @@ import { useCallback } from "react"; import { useTranslation } from "react-i18next"; -import { useLocation } from "react-router-dom"; +import { useNavigate, useLocation } from "react-router-dom"; import { ReactComponent as FailedIconSvg } from "~assets/svg/failed-icon.svg"; import { RESET_PASSWORD } from "~constants/routes"; @@ -20,9 +20,11 @@ import { criticalErrorSelector, useResetPasswordStore, } from "./useResetPasswordStore"; +import { ResetPasswordPossibleInvalid } from "~typings/types"; export const ResetPasswordPopover = () => { const { t } = useTranslation(); + const navigate = useNavigate(); const { data: settings } = useSettings(); const { criticalError } = useResetPasswordStore( @@ -37,11 +39,16 @@ export const ResetPasswordPopover = () => { const handleAction = (e: any) => { e.preventDefault(); - window.location.href = getSignInRedirectURL( - settings?.response.configs["signin.redirect-url"], - fromSignInHash, - RESET_PASSWORD - ); + if(ResetPasswordPossibleInvalid.includes(criticalError?.errorCode!!)) { + navigate(0) + } else { + window.location.href = getSignInRedirectURL( + settings?.response.configs["signin.redirect-url"], + fromSignInHash, + RESET_PASSWORD + ); + } + }; return ( @@ -51,7 +58,7 @@ export const ResetPasswordPopover = () => { <> - {["knowledgebase_mismatch"].includes(criticalError?.errorCode!!) ? t("invalid") : t("error")} + {ResetPasswordPossibleInvalid.includes(criticalError?.errorCode!!) ? t("invalid") : t("error")} @@ -63,7 +70,7 @@ export const ResetPasswordPopover = () => { onClick={handleAction} className="w-full bg-primary" > - {["knowledgebase_mismatch"].includes(criticalError?.errorCode!!) ? t("retry") : t("okay")} + {ResetPasswordPossibleInvalid.includes(criticalError?.errorCode!!) ? t("retry") : t("okay")} diff --git a/signup-ui/src/typings/types.ts b/signup-ui/src/typings/types.ts index bac84afc..e8530d9d 100644 --- a/signup-ui/src/typings/types.ts +++ b/signup-ui/src/typings/types.ts @@ -48,6 +48,14 @@ const RegisterStatusPossibleErrors = [ export type RegisterStatusErrors = (typeof RegisterStatusPossibleErrors)[number]; +export const ResetPasswordPossibleInvalid = [ + "knowledgebase_mismatch", + "identifier_not_found", + "invalid_kba_challenge", + "challenge_format_and_type_mismatch", + "kba_challenge_not_found" +]; + const ResetPasswordPossibleErrors = [ "invalid_transaction", "not_registered", @@ -56,6 +64,10 @@ const ResetPasswordPossibleErrors = [ "invalid_request", "reset_pwd_failed", "knowledgebase_mismatch", + "identifier_not_found", + "invalid_kba_challenge", + "challenge_format_and_type_mismatch", + "kba_challenge_not_found", ] as const; export type ResetPasswordErrors = (typeof ResetPasswordPossibleErrors)[number]; From 11056191e8931a8f7c4e919a4bc03457bcf64954 Mon Sep 17 00:00:00 2001 From: Sreang Rathanak Date: Wed, 24 Jan 2024 17:41:51 +0700 Subject: [PATCH 07/20] Add missing invalid_transaction Signed-off-by: Sreang Rathanak --- signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx b/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx index d28846b7..d3639b7f 100644 --- a/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx @@ -204,7 +204,7 @@ export const Otp = ({ methods, settings }: OtpProps) => { onSuccess: ({ errors }) => { if (errors.length > 0) { if ( - ResetPasswordPossibleInvalid.includes( + ["invalid_transaction", ...ResetPasswordPossibleInvalid].includes( errors[0].errorCode ) ) { From 1335cad8d1d915bbce5dd9dbbbd3716547e5cf36 Mon Sep 17 00:00:00 2001 From: ase-101 Date: Wed, 24 Jan 2024 23:39:32 +0530 Subject: [PATCH 08/20] ES-628 Signed-off-by: ase-101 --- .../io/mosip/signup/helper/CryptoHelper.java | 67 ++++++++++++------- .../signup/services/CacheUtilService.java | 14 ++-- .../signup/services/RegistrationService.java | 4 +- .../resources/application-default.properties | 10 ++- .../src/main/resources/messages.properties | 1 + .../resources/application-test.properties | 14 ++-- 6 files changed, 67 insertions(+), 43 deletions(-) diff --git a/signup-service/src/main/java/io/mosip/signup/helper/CryptoHelper.java b/signup-service/src/main/java/io/mosip/signup/helper/CryptoHelper.java index 0ab5a883..c7ed6c38 100644 --- a/signup-service/src/main/java/io/mosip/signup/helper/CryptoHelper.java +++ b/signup-service/src/main/java/io/mosip/signup/helper/CryptoHelper.java @@ -1,39 +1,48 @@ package io.mosip.signup.helper; import io.mosip.esignet.core.util.IdentityProviderUtil; +import io.mosip.kernel.core.util.UUIDUtils; import io.mosip.signup.exception.SignUpException; import io.mosip.signup.services.CacheUtilService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import javax.crypto.*; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; import java.nio.charset.StandardCharsets; +import java.security.NoSuchAlgorithmException; import java.util.Arrays; +import static io.mosip.kernel.core.util.UUIDUtils.NAMESPACE_OID; + @Slf4j @Component public class CryptoHelper { - private static final String AES_TRANSFORMATION = "AES/CFB/PKCS5Padding"; - public static final String CACHE_KEY = "aes"; + public static final String ALIAS_CACHE_KEY = "CURRENT_ACTIVE_ALIAS"; + + @Value("${mosip.signup.cache.symmetric-algorithm-name}") + private String symmetricAlgorithm; @Autowired private CacheUtilService cacheUtilService; - public String symmetricEncrypt(String transactionId, String data, SecretKey secretKey) { + public String symmetricEncrypt(String data) { try { - Cipher cipher = Cipher.getInstance(AES_TRANSFORMATION); + + String keyAlias = getActiveKeyAlias(); + SecretKey secretKey = getSecretKey(keyAlias); + + Cipher cipher = Cipher.getInstance(symmetricAlgorithm); byte[] initializationVector = IdentityProviderUtil.generateSalt(cipher.getBlockSize()); byte[] secretDataBytes = data.getBytes(StandardCharsets.UTF_8); cipher.init(Cipher.ENCRYPT_MODE, secretKey, new IvParameterSpec(initializationVector)); byte[] encryptedBytes = cipher.doFinal(secretDataBytes, 0, secretDataBytes.length); - String keyAlias = getKeyAlias(transactionId); byte[] keyAliasBytes = keyAlias.getBytes(); - cacheUtilService.setSecretKeyBasedOnAlias(keyAlias, IdentityProviderUtil.b64Encode(secretKey.getEncoded())); byte[] output = new byte[cipher.getOutputSize(secretDataBytes.length)+cipher.getBlockSize()+keyAliasBytes.length]; System.arraycopy(encryptedBytes, 0, output, 0, encryptedBytes.length); @@ -49,12 +58,12 @@ public String symmetricEncrypt(String transactionId, String data, SecretKey secr public String symmetricDecrypt(String encryptedData) { try { - Cipher cipher = Cipher.getInstance(AES_TRANSFORMATION); + Cipher cipher = Cipher.getInstance(symmetricAlgorithm); byte[] data = IdentityProviderUtil.b64Decode(encryptedData); - byte[] keyAlias = Arrays.copyOfRange(data, data.length - 10, data.length); - byte[] iv = Arrays.copyOfRange(data, data.length-(cipher.getBlockSize()+10), data.length-10); - byte[] encryptedBytes = Arrays.copyOfRange(data, 0, data.length-(cipher.getBlockSize()+10)); + byte[] keyAlias = Arrays.copyOfRange(data, data.length-36, data.length); + byte[] iv = Arrays.copyOfRange(data, data.length-(cipher.getBlockSize()+36), data.length-36); + byte[] encryptedBytes = Arrays.copyOfRange(data, 0, data.length-(cipher.getBlockSize()+36)); String encodedSecretKey = cacheUtilService.getSecretKey(new String(keyAlias)); cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(IdentityProviderUtil.b64Decode(encodedSecretKey), "AES"), @@ -67,23 +76,31 @@ public String symmetricDecrypt(String encryptedData) { } - public SecretKey getSecretKey() { - String encodedSecretKey = cacheUtilService.getSecretKey(); + public SecretKey getSecretKey(String alias) { + String encodedSecretKey = cacheUtilService.getSecretKey(alias); + return new SecretKeySpec(IdentityProviderUtil.b64Decode(encodedSecretKey), "AES"); + } + + private String getActiveKeyAlias() { + String alias = cacheUtilService.getActiveKeyAlias(); + if(alias != null) + return alias; + + log.debug("No active alias found, generating new alias and AES key."); + alias = UUIDUtils.getUUID(NAMESPACE_OID, "signup-service").toString(); + generateSecretKey(alias); + return alias; + } + + private void generateSecretKey(String alias) { try { - if(encodedSecretKey == null) { - KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); - keyGenerator.init(256); - cacheUtilService.setSecretKey(CACHE_KEY, IdentityProviderUtil.b64Encode(keyGenerator.generateKey().getEncoded())); - encodedSecretKey = cacheUtilService.getSecretKey(); - } - return new SecretKeySpec(IdentityProviderUtil.b64Decode(encodedSecretKey), "AES"); - } catch (Exception e) { - log.error("Error getting secret key", e); + KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); + keyGenerator.init(256); + cacheUtilService.setSecretKey(alias, IdentityProviderUtil.b64Encode(keyGenerator.generateKey().getEncoded())); + cacheUtilService.setActiveKeyAlias(ALIAS_CACHE_KEY, alias); + } catch (NoSuchAlgorithmException e) { + log.error("Error generating secret key", e); throw new SignUpException("crypto_error"); } } - - private String getKeyAlias(String transactionId) { - return transactionId.substring(transactionId.length()-10); - } } diff --git a/signup-service/src/main/java/io/mosip/signup/services/CacheUtilService.java b/signup-service/src/main/java/io/mosip/signup/services/CacheUtilService.java index cd76a887..e4f1c08e 100644 --- a/signup-service/src/main/java/io/mosip/signup/services/CacheUtilService.java +++ b/signup-service/src/main/java/io/mosip/signup/services/CacheUtilService.java @@ -50,9 +50,9 @@ public String setSecretKey(String key, String secretKey) { return secretKey; } - @Cacheable(value = SignUpConstants.KEY_ALIAS, key = "#alias") - public String setSecretKeyBasedOnAlias(String alias, String secretKey) { - return secretKey; + @Cacheable(value = SignUpConstants.KEY_ALIAS, key = "#key") + public String setActiveKeyAlias(String key, String alias) { + return alias; } //---Getter--- @@ -75,11 +75,11 @@ public boolean isIdentifierBlocked(String identifier) { return value == null ? false : true; } - public String getSecretKey() { - return cacheManager.getCache(SignUpConstants.KEYSTORE).get(CryptoHelper.CACHE_KEY, String.class); + public String getSecretKey(String keyAlias) { + return cacheManager.getCache(SignUpConstants.KEYSTORE).get(keyAlias, String.class); } - public String getSecretKey(String alias) { - return cacheManager.getCache(SignUpConstants.KEY_ALIAS).get(alias, String.class); + public String getActiveKeyAlias() { + return cacheManager.getCache(SignUpConstants.KEY_ALIAS).get(CryptoHelper.ALIAS_CACHE_KEY, String.class); } } diff --git a/signup-service/src/main/java/io/mosip/signup/services/RegistrationService.java b/signup-service/src/main/java/io/mosip/signup/services/RegistrationService.java index 063377c1..4688cec7 100644 --- a/signup-service/src/main/java/io/mosip/signup/services/RegistrationService.java +++ b/signup-service/src/main/java/io/mosip/signup/services/RegistrationService.java @@ -405,9 +405,7 @@ private void checkActiveIdentityExists(String transactionId, } //set UIN in the cache to be further used for update UIN endpoint - SecretKey secretKey = cryptoHelper.getSecretKey(); - registrationTransaction.setUin(cryptoHelper.symmetricEncrypt(transactionId, - restResponseWrapper.getResponse().getIdentity().getUIN(), secretKey)); + registrationTransaction.setUin(cryptoHelper.symmetricEncrypt(restResponseWrapper.getResponse().getIdentity().getUIN())); } diff --git a/signup-service/src/main/resources/application-default.properties b/signup-service/src/main/resources/application-default.properties index 553dc9f6..8a44e091 100644 --- a/signup-service/src/main/resources/application-default.properties +++ b/signup-service/src/main/resources/application-default.properties @@ -37,6 +37,7 @@ mosip.signup.supported.challenge.otp.length=6 ## ------------------------------------- Cache configuration ----------------------------------------------------------- +mosip.signup.cache.symmetric-algorithm-name=AES/CFB/PKCS5Padding spring.cache.type=simple #spring.cache.type=redis @@ -50,13 +51,16 @@ mosip.esignet.cache.size={'challenge_generated': 200, \ 'challenge_verified': 200,\ 'status_check': 200,\ 'blocked_identifier':2000,\ - 'keystore' : 5, \ - 'key_alias' : 200 } + 'keystore' : 10, \ + 'key_alias' : 1 } + +## Note: keystore TTL should be more than the key_alias cache TTL. +## So that key rotation happens before the actual key is removed from the keystore cache. mosip.esignet.cache.expire-in-seconds={'challenge_generated': ${mosip.signup.unauthenticated.txn.timeout},\ 'challenge_verified': ${mosip.signup.verified.txn.timeout},\ 'status_check': ${mosip.signup.status-check.txn.timeout}, \ 'blocked_identifier': ${mosip.signup.generate-challenge.blocked.timeout},\ - 'keystore' : 10, \ + 'keystore' : 600, \ 'key_alias' : ${mosip.signup.verified.txn.timeout} } ## ------------------------------------- Auth adapter ------------------------------------------------------------------ diff --git a/signup-service/src/main/resources/messages.properties b/signup-service/src/main/resources/messages.properties index 5e09cc01..7c253419 100644 --- a/signup-service/src/main/resources/messages.properties +++ b/signup-service/src/main/resources/messages.properties @@ -7,3 +7,4 @@ invalid_challenge_channel=Invalid Challenge channel provided. invalid_no_of_challenges=Null or empty authentication challenges not allowed. invalid_auth_factor_type=Null or empty authentication factor type not allowed. invalid_challenge=Invalid Authentication challenge provided. +crypto_error=Internal Error, Please try again. diff --git a/signup-service/src/test/resources/application-test.properties b/signup-service/src/test/resources/application-test.properties index 756dd857..4e10d344 100644 --- a/signup-service/src/test/resources/application-test.properties +++ b/signup-service/src/test/resources/application-test.properties @@ -28,9 +28,12 @@ mosip.signup.identifier.regex=^\\+855[1-9]\\d{7,8}$ mosip.signup.identifier.prefix=+855 mosip.signup.supported-languages={'khm','eng'} mosip.signup.password.pattern=^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[\\x5F\\W])(?=.{8,20})[a-zA-Z0-9\\x5F\\W]{8,20}$ -mosip.signup.fullname.pattern=^[\\u1780-\\u17FF\\u19E0-\\u19FF\\u1A00-\\u1A9F\\u0020]{1,30}$ mosip.signup.password.max-length=20 -mosip.signup.password.min-length=6 +mosip.signup.generate-challenge.blocked.timeout=300 +mosip.signup.challenge.timeout=60 +mosip.signup.audit.description.max-length=2048 +mosip.signup.password.min-length=8 +mosip.signup.fullname.pattern=^[\\u1780-\\u17FF\\u19E0-\\u19FF\\u1A00-\\u1A9F\\u0020]{1,30}$ ## Time given to generate and verify the challenge in seconds. ## Default resend delay is 60 seconds, with 3 attempts, so 60*3=180 seconds. @@ -55,7 +58,7 @@ mosip.signup.supported.challenge-types={'OTP', 'KBA'} mosip.signup.supported.challenge.otp.length=6 ## ------------------------------------- Cache configuration ----------------------------------------------------------- - +mosip.signup.cache.symmetric-algorithm-name=AES/CFB/PKCS5Padding spring.cache.type=simple #spring.cache.type=redis @@ -70,12 +73,13 @@ mosip.esignet.cache.size={'challenge_generated': 200, \ 'status_check': 200,\ 'blocked_identifier':2000,\ 'keystore' : 5, \ - 'key_alias' : 200 } + 'key_alias' : 1 } + mosip.esignet.cache.expire-in-seconds={'challenge_generated': ${mosip.signup.unauthenticated.txn.timeout},\ 'challenge_verified': ${mosip.signup.verified.txn.timeout},\ 'status_check': ${mosip.signup.status-check.txn.timeout}, \ 'blocked_identifier': ${mosip.signup.generate-challenge.blocked.timeout},\ - 'keystore' : 10, \ + 'keystore' : 600, \ 'key_alias' : ${mosip.signup.verified.txn.timeout} } ## ------------------------------------- Auth adapter ------------------------------------------------------------------ From 19e5f543c448db89f7dad6cb330466a21992bea1 Mon Sep 17 00:00:00 2001 From: Bunsy Date: Thu, 25 Jan 2024 10:55:45 +0700 Subject: [PATCH 09/20] fix: remove deprecated t param Signed-off-by: Bunsy --- .../src/pages/ResetPasswordPage/ResetPasswordPage.tsx | 9 ++++----- signup-ui/src/pages/SignUpPage/SignUpPage.tsx | 10 +++++----- signup-ui/src/pages/shared/validation.ts | 9 ++++----- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx index ff6345d1..a45bec29 100644 --- a/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/ResetPasswordPage.tsx @@ -59,9 +59,9 @@ export const ResetPasswordPage = ({ settings }: ResetPasswordPageProps) => { () => [ // Step 1 - UserInfo yup.object({ - username: validateUsername(settings, t), - fullname: validateFullName(settings, t), - captchaToken: validateCaptchaToken(t), + username: validateUsername(settings), + fullname: validateFullName(settings), + captchaToken: validateCaptchaToken(), }), // Step 2 - Otp yup.object({ @@ -69,11 +69,10 @@ export const ResetPasswordPage = ({ settings }: ResetPasswordPageProps) => { }), // Step 3 - ResetPassword yup.object({ - newPassword: validatePassword(settings, t), + newPassword: validatePassword(settings), confirmNewPassword: validateConfirmPassword( "newPassword", settings, - t, false ), }), diff --git a/signup-ui/src/pages/SignUpPage/SignUpPage.tsx b/signup-ui/src/pages/SignUpPage/SignUpPage.tsx index b6412fa5..66de3f71 100644 --- a/signup-ui/src/pages/SignUpPage/SignUpPage.tsx +++ b/signup-ui/src/pages/SignUpPage/SignUpPage.tsx @@ -76,8 +76,8 @@ export const SignUpPage = ({ settings }: SignUpPageProps) => { () => [ // Step 1 - Phone Validation yup.object({ - phone: validateUsername(settings, t), - captchaToken: validateCaptchaToken(t), + phone: validateUsername(settings), + captchaToken: validateCaptchaToken(), }), // Step 2 - OTP Validation yup.object({ @@ -88,9 +88,9 @@ export const SignUpPage = ({ settings }: SignUpPageProps) => { // Step 4 - Account Setup Validation yup.object({ username: yup.string(), - fullNameInKhmer: validateFullName(settings, t), - password: validatePassword(settings, t), - confirmPassword: validateConfirmPassword("password", settings, t, true), + fullNameInKhmer: validateFullName(settings), + password: validatePassword(settings), + confirmPassword: validateConfirmPassword("password", settings, true), consent: yup.bool().oneOf([true], t("terms_and_conditions_validation")), }), // Step 5 - Register Status Validation diff --git a/signup-ui/src/pages/shared/validation.ts b/signup-ui/src/pages/shared/validation.ts index dfb773f3..ace34bce 100644 --- a/signup-ui/src/pages/shared/validation.ts +++ b/signup-ui/src/pages/shared/validation.ts @@ -3,7 +3,7 @@ import * as yup from "yup"; import { SettingsDto } from "~typings/types"; -export const validateUsername = (settings: SettingsDto, t: TFunction) => +export const validateUsername = (settings: SettingsDto) => yup .string() .trim() @@ -18,10 +18,10 @@ export const validateUsername = (settings: SettingsDto, t: TFunction) => ); }); -export const validateCaptchaToken = (t: TFunction) => +export const validateCaptchaToken = () => yup.string().required("captcha_token_validation"); -export const validateFullName = (settings: SettingsDto, t: TFunction) => +export const validateFullName = (settings: SettingsDto) => yup .string() .strict(true) @@ -36,7 +36,7 @@ export const validateOtp = (settings: SettingsDto) => .string() .matches(new RegExp(`^\\d{${settings.response.configs["otp.length"]}}$`)); -export const validatePassword = (settings: SettingsDto, t: TFunction) => +export const validatePassword = (settings: SettingsDto) => yup .string() .trim() @@ -48,7 +48,6 @@ export const validatePassword = (settings: SettingsDto, t: TFunction) => export const validateConfirmPassword = ( passwordRef: string, settings: SettingsDto, - t: TFunction, isRegister: boolean ) => yup From 6e1925c200aa45f270d3bbc588f4ff21b69c5942 Mon Sep 17 00:00:00 2001 From: pr Date: Thu, 25 Jan 2024 11:18:43 +0700 Subject: [PATCH 10/20] ES-709 Signed-off-by: pr --- .../src/main/java/io/mosip/signup/helper/AuditHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signup-service/src/main/java/io/mosip/signup/helper/AuditHelper.java b/signup-service/src/main/java/io/mosip/signup/helper/AuditHelper.java index dc03d0b0..13f8e384 100644 --- a/signup-service/src/main/java/io/mosip/signup/helper/AuditHelper.java +++ b/signup-service/src/main/java/io/mosip/signup/helper/AuditHelper.java @@ -45,7 +45,7 @@ public void sendAuditTransaction(AuditEvent auditEvent, AuditEventType eventType restRequestWrapper.setRequesttime(getUTCDateTime()); String description = signUpException != null ? - ExceptionUtils.getStackTrace(signUpException) : null; + ExceptionUtils.getStackTrace(signUpException) : auditEvent.toString() + " " + eventType.toString(); if (description != null && description.length() > auditDescriptionMaxLength) { description = description.substring(0, auditDescriptionMaxLength); } From d446f5fdb5baf663c036c84335d9dc7a4fbf4d5f Mon Sep 17 00:00:00 2001 From: ase-101 Date: Thu, 25 Jan 2024 13:33:34 +0530 Subject: [PATCH 11/20] Fixed review comments Signed-off-by: ase-101 --- .../main/java/io/mosip/signup/helper/CryptoHelper.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/signup-service/src/main/java/io/mosip/signup/helper/CryptoHelper.java b/signup-service/src/main/java/io/mosip/signup/helper/CryptoHelper.java index c7ed6c38..a405d442 100644 --- a/signup-service/src/main/java/io/mosip/signup/helper/CryptoHelper.java +++ b/signup-service/src/main/java/io/mosip/signup/helper/CryptoHelper.java @@ -27,6 +27,12 @@ public class CryptoHelper { @Value("${mosip.signup.cache.symmetric-algorithm-name}") private String symmetricAlgorithm; + @Value("${mosip.signup.cache.symmetric-key.algorithm-name:AES}") + private String symmetricKeyAlgorithm; + + @Value("${mosip.signup.cache.symmetric-key.size:256}") + private int symmetricKeySize; + @Autowired private CacheUtilService cacheUtilService; @@ -94,8 +100,8 @@ private String getActiveKeyAlias() { private void generateSecretKey(String alias) { try { - KeyGenerator keyGenerator = KeyGenerator.getInstance("AES"); - keyGenerator.init(256); + KeyGenerator keyGenerator = KeyGenerator.getInstance(symmetricKeyAlgorithm); + keyGenerator.init(symmetricKeySize); cacheUtilService.setSecretKey(alias, IdentityProviderUtil.b64Encode(keyGenerator.generateKey().getEncoded())); cacheUtilService.setActiveKeyAlias(ALIAS_CACHE_KEY, alias); } catch (NoSuchAlgorithmException e) { From d7b190a522eca3fdff4199ae08adacf7143a9b72 Mon Sep 17 00:00:00 2001 From: Bunsy Date: Fri, 26 Jan 2024 13:24:48 +0700 Subject: [PATCH 12/20] feat: subtract attempt on success Signed-off-by: Bunsy --- .../src/pages/ResetPasswordPage/Otp/Otp.tsx | 23 +++++++++++-------- signup-ui/src/pages/SignUpPage/Otp/Otp.tsx | 21 +++++++++++------ 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx b/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx index d3639b7f..71b2ad09 100644 --- a/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx @@ -30,9 +30,9 @@ import { Error, GenerateChallengeRequestDto, ResetPasswordForm, + ResetPasswordPossibleInvalid, SettingsDto, VerifyChallengeRequestDto, - ResetPasswordPossibleInvalid, } from "~typings/types"; import { resetPasswordFormDefaultValues } from "../ResetPasswordPage"; @@ -129,15 +129,10 @@ export const Otp = ({ methods, settings }: OtpProps) => { }; return generateChallengeMutation.mutate(generateChallengeRequestDto, { - onSuccess: ({ errors }) => { + onSuccess: ({ response, errors }) => { pinInputRef.current?.clear(); setValue("otp", "", { shouldValidate: true }); - setResendAttempts((resendAttempt) => resendAttempt - 1); - restartResendOtpTotalSecs( - getTimeoutTime(settings.response.configs["resend.delay"]) - ); - if (errors && errors.length > 0) { if (errors[0].errorCode === "invalid_transaction") { setCriticalError(errors[0]); @@ -145,6 +140,13 @@ export const Otp = ({ methods, settings }: OtpProps) => { setChallengeVerificationError(errors[0]); } } + + if (errors.length === 0 && response?.status === "SUCCESS") { + setResendAttempts((resendAttempt) => resendAttempt - 1); + restartResendOtpTotalSecs( + getTimeoutTime(settings.response.configs["resend.delay"]) + ); + } }, }); } @@ -204,9 +206,10 @@ export const Otp = ({ methods, settings }: OtpProps) => { onSuccess: ({ errors }) => { if (errors.length > 0) { if ( - ["invalid_transaction", ...ResetPasswordPossibleInvalid].includes( - errors[0].errorCode - ) + [ + "invalid_transaction", + ...ResetPasswordPossibleInvalid, + ].includes(errors[0].errorCode) ) { setCriticalError(errors[0]); } else { diff --git a/signup-ui/src/pages/SignUpPage/Otp/Otp.tsx b/signup-ui/src/pages/SignUpPage/Otp/Otp.tsx index db62dcb3..6d015781 100644 --- a/signup-ui/src/pages/SignUpPage/Otp/Otp.tsx +++ b/signup-ui/src/pages/SignUpPage/Otp/Otp.tsx @@ -125,15 +125,10 @@ export const Otp = ({ methods, settings }: OtpProps) => { }; return generateChallengeMutation.mutate(generateChallengeRequestDto, { - onSuccess: ({ errors }) => { + onSuccess: ({ response, errors }) => { pinInputRef.current?.clear(); setValue("otp", "", { shouldValidate: true }); - setResendAttempts((resendAttempt) => resendAttempt - 1); - restartResendOtpTotalSecs( - getTimeoutTime(settings.response.configs["resend.delay"]) - ); - if (errors && errors.length > 0) { if (errors[0].errorCode === "invalid_transaction") { setCriticalError(errors[0]); @@ -141,6 +136,13 @@ export const Otp = ({ methods, settings }: OtpProps) => { setChallengeVerificationError(errors[0]); } } + + if (errors.length === 0 && response?.status === "SUCCESS") { + setResendAttempts((resendAttempt) => resendAttempt - 1); + restartResendOtpTotalSecs( + getTimeoutTime(settings.response.configs["resend.delay"]) + ); + } }, }); } @@ -194,7 +196,12 @@ export const Otp = ({ methods, settings }: OtpProps) => { return verifyChallengeMutation.mutate(verifyChallengeRequestDto, { onSuccess: ({ errors }) => { if (errors.length > 0) { - if (["already-registered", "identifier_already_registered"].includes(errors[0].errorCode)) { + if ( + [ + "already-registered", + "identifier_already_registered", + ].includes(errors[0].errorCode) + ) { setStep(SignUpStep.PhoneStatus); } else if (errors[0].errorCode === "invalid_transaction") { setCriticalError(errors[0]); From b3f451538de98473a5bd86dfc8147f5cbeacd64d Mon Sep 17 00:00:00 2001 From: Bunsy Date: Fri, 26 Jan 2024 13:31:05 +0700 Subject: [PATCH 13/20] fix: convert otp blocked to minutes Signed-off-by: Bunsy --- signup-ui/src/components/resend-attempt.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/signup-ui/src/components/resend-attempt.tsx b/signup-ui/src/components/resend-attempt.tsx index a428f452..64fa451c 100644 --- a/signup-ui/src/components/resend-attempt.tsx +++ b/signup-ui/src/components/resend-attempt.tsx @@ -9,7 +9,7 @@ interface ResendAttemptProps { export const ResendAttempt = ({ currentAttempts, totalAttempts, - attemptRetryAfter = 5, + attemptRetryAfter = 300, }: ResendAttemptProps) => { const { t } = useTranslation(); return ( @@ -19,7 +19,7 @@ export const ResendAttempt = ({ {t("attempts_left", { attemptLeft: currentAttempts, totalAttempt: totalAttempts, - attemptRetryAfter: attemptRetryAfter, + attemptRetryAfter: attemptRetryAfter / 60, })} )} From 0c3179ba7c09ca7c7a72a77bc1996ea507f026c6 Mon Sep 17 00:00:00 2001 From: bunsy23 Date: Mon, 29 Jan 2024 07:29:09 +0700 Subject: [PATCH 14/20] feat: show retry after countdown is zero Signed-off-by: bunsy23 --- signup-ui/public/locales/en.json | 3 ++- signup-ui/public/locales/km.json | 3 ++- signup-ui/src/components/resend-attempt.tsx | 4 +++- signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx | 3 ++- signup-ui/src/pages/SignUpPage/Otp/Otp.tsx | 3 ++- signup-ui/src/resources.d.ts | 1 + 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/signup-ui/public/locales/en.json b/signup-ui/public/locales/en.json index 2e285463..a5b54e36 100644 --- a/signup-ui/public/locales/en.json +++ b/signup-ui/public/locales/en.json @@ -62,7 +62,8 @@ "page_under_construction_detail": "Our experts are working hard to make this page available. Meanwhile, we request you to please visit after some time.", "something_went_wrong": "Something went wrong!", "something_went_wrong_detail": "Our experts are working hard to make things working again.", - "attempts_left": "{attemptLeft, plural, =0 {0 of {totalAttempt} attempts left. Please try again after {attemptRetryAfter} minutes.} other {{attemptLeft} of {totalAttempt} attempts left}}", + "attempts_left": "{attemptLeft, plural, =0 {0 of {totalAttempt} attempts left} other {{attemptLeft} of {totalAttempt} attempts left}}", + "attempts_left_and_retry": "{attemptLeft, plural, =0 {0 of {totalAttempt} attempts left. Please try again after {attemptRetryAfter} minutes.} other {{attemptLeft} of {totalAttempt} attempts left}}", "captcha_token_validation": "Please verify that you are a human.", "username_validation": "Enter a valid username", "username_lead_zero_validation": "Number cannot start with zero. Enter a valid mobile number.", diff --git a/signup-ui/public/locales/km.json b/signup-ui/public/locales/km.json index efac5a54..c9bdb9ea 100644 --- a/signup-ui/public/locales/km.json +++ b/signup-ui/public/locales/km.json @@ -62,7 +62,8 @@ "page_under_construction_detail": "អ្នកជំនាញកំពុងធ្វើការដើម្បីឱ្យទំព័រនេះអាចប្រើប្រាស់បាន។ សូមចូលម្ដងទៀតនៅពេលក្រោយ។", "something_went_wrong": "មានអ្វីមួយខុសប្រក្រតី!", "something_went_wrong_detail": "អ្នកជំនាញកំពុងធ្វើការដើម្បីឱ្យអ្វីៗដំណើរការឡើងវិញ។", - "attempts_left": "{attemptLeft, plural, =0 {ការព្យាយាមនៅសល់ 0 នៃ {totalAttempt}។ សូមព្យាយាមម្តងទៀតនៅ {attemptRetryAfter} នាទីបន្ទាប់។} other {ការព្យាយាមនៅសល់ {attemptLeft} នៃ {totalAttempt}}}", + "attempts_left": "{attemptLeft, plural, =0 {ការព្យាយាមនៅសល់ 0 នៃ {totalAttempt}} other {ការព្យាយាមនៅសល់ {attemptLeft} នៃ {totalAttempt}}}", + "attempts_left_and_retry": "{attemptLeft, plural, =0 {ការព្យាយាមនៅសល់ 0 នៃ {totalAttempt}។ សូមព្យាយាមម្តងទៀតនៅ {attemptRetryAfter} នាទីបន្ទាប់។} other {ការព្យាយាមនៅសល់ {attemptLeft} នៃ {totalAttempt}}}", "captcha_token_validation": "សូមបញ្ជាក់ថាអ្នកជាមនុស្ស", "username_validation": "សូមបញ្ចូលឈ្មោះអ្នកប្រើប្រាស់ត្រឹមត្រូវ", "username_lead_zero_validation": "លេខមិនអាចចាប់ផ្តើមដោយលេខសូន្យបានទេ។បញ្ចូលលេខទូរស័ព្ទដែលត្រឹមត្រូវ។", diff --git a/signup-ui/src/components/resend-attempt.tsx b/signup-ui/src/components/resend-attempt.tsx index 64fa451c..cef25ff8 100644 --- a/signup-ui/src/components/resend-attempt.tsx +++ b/signup-ui/src/components/resend-attempt.tsx @@ -4,19 +4,21 @@ interface ResendAttemptProps { currentAttempts: number; totalAttempts: number; attemptRetryAfter?: number; + showRetry?: boolean; } export const ResendAttempt = ({ currentAttempts, totalAttempts, attemptRetryAfter = 300, + showRetry = false, }: ResendAttemptProps) => { const { t } = useTranslation(); return ( <> {currentAttempts < totalAttempts && (
- {t("attempts_left", { + {t(showRetry ? "attempts_left_and_retry" : "attempts_left", { attemptLeft: currentAttempts, totalAttempt: totalAttempts, attemptRetryAfter: attemptRetryAfter / 60, diff --git a/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx b/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx index 71b2ad09..59b9c120 100644 --- a/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx +++ b/signup-ui/src/pages/ResetPasswordPage/Otp/Otp.tsx @@ -352,9 +352,10 @@ export const Otp = ({ methods, settings }: OtpProps) => { currentAttempts={resendAttempts} totalAttempts={settings.response.configs["resend.attempts"]} attemptRetryAfter={settings.response.configs["otp.blocked"]} + showRetry={resendAttempts === 0 && resendOtpTotalSecs === 0} /> )} - {resendAttempts === 0 && ( + {resendAttempts === 0 && resendOtpTotalSecs === 0 && (