From 515a525b58b8961bd7f5c3c967119685fb068094 Mon Sep 17 00:00:00 2001 From: Janak Amarasena Date: Fri, 1 Dec 2023 17:47:01 +0530 Subject: [PATCH 1/6] Add state param for api based auth --- .../magiclink/MagicLinkAuthenticator.java | 17 +++++++++++++++++ .../MagicLinkAuthenticatorConstants.java | 2 ++ 2 files changed, 19 insertions(+) diff --git a/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticator.java b/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticator.java index c02a8e4..8d07de8 100644 --- a/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticator.java +++ b/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticator.java @@ -65,6 +65,7 @@ import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.UUID; import java.util.concurrent.TimeUnit; import static org.wso2.carbon.identity.application.authentication.framework.util.FrameworkConstants.RequestParams.RESTART_FLOW; @@ -212,6 +213,15 @@ protected void initiateAuthenticationRequest(HttpServletRequest request, HttpSer if (StringUtils.isNotEmpty(magicToken)) { String expiryTime = TimeUnit.SECONDS.toMinutes(getExpiryTime()) + " " + TimeUnit.MINUTES.name().toLowerCase(); + if (Boolean.parseBoolean((String) context.getProperty(IS_API_BASED))) { + /* Setting a state param to the request for the client to be able to correlate the + magic link coming to the app in API based authentication flow. The code is written in + this manner as it is not possible to dynamically set params to the email template. */ + String state = UUID.randomUUID().toString(); + context.setProperty(MagicLinkAuthenticatorConstants.AUTHENTICATOR_NAME + + MagicLinkAuthenticatorConstants.STATE_PARAM_SUFFIX, state); + magicToken = magicToken + "&" + MagicLinkAuthenticatorConstants.STATE_PARAM + "=" + state; + } triggerEvent(user, context, magicToken, expiryTime); } } @@ -660,6 +670,13 @@ public Optional getAuthInitiationData(AuthenticationContext c requiredParams.add(MLT); authenticatorData.setRequiredParams(requiredParams); setAuthParams(authenticatorData); + Map additionalAuthenticationParams = new HashMap<>(); + String state = (String) context.getProperty(MagicLinkAuthenticatorConstants.AUTHENTICATOR_NAME + + MagicLinkAuthenticatorConstants.STATE_PARAM_SUFFIX); + additionalAuthenticationParams.put(MagicLinkAuthenticatorConstants.STATE_PARAM, state); + AdditionalData additionalData = new AdditionalData(); + additionalData.setAdditionalAuthenticationParams(additionalAuthenticationParams); + authenticatorData.setAdditionalData(additionalData); } return Optional.of(authenticatorData); diff --git a/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticatorConstants.java b/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticatorConstants.java index 9f044ca..10e069a 100644 --- a/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticatorConstants.java +++ b/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticatorConstants.java @@ -56,6 +56,8 @@ private MagicLinkAuthenticatorConstants() { public static final String EXPIRYTIME = "expiry-time"; public static final String IS_API_BASED_AUTHENTICATION_SUPPORTED = "isAPIBasedAuthenticationSupported"; public static final String CALLBACK_URL = "callbackUrl"; + public static final String STATE_PARAM_SUFFIX = "_state_param"; + public static final String STATE_PARAM = "state"; /** * Constants related to log management. From e7e394b41510b4d992f29f765c0320a16a91ead6 Mon Sep 17 00:00:00 2001 From: WSO2 Builder Date: Fri, 1 Dec 2023 12:34:27 +0000 Subject: [PATCH 2/6] [WSO2 Release] [Jenkins #373] [Release 1.1.18] prepare release v1.1.18 --- .../pom.xml | 2 +- .../pom.xml | 2 +- pom.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml b/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml index c0d3da7..445720d 100644 --- a/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml +++ b/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.local.auth.magiclink identity-local-auth-magiclink ../../pom.xml - 1.1.18-SNAPSHOT + 1.1.18 4.0.0 diff --git a/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml b/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml index ff3aff6..22e9f64 100644 --- a/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml @@ -20,7 +20,7 @@ identity-local-auth-magiclink org.wso2.carbon.identity.local.auth.magiclink - 1.1.18-SNAPSHOT + 1.1.18 ../../pom.xml diff --git a/pom.xml b/pom.xml index 5a41f69..28ed99d 100644 --- a/pom.xml +++ b/pom.xml @@ -27,13 +27,13 @@ org.wso2.carbon.identity.local.auth.magiclink identity-local-auth-magiclink pom - 1.1.18-SNAPSHOT + 1.1.18 WSO2 Carbon - MagicLink Authenticator https://github.com/wso2-extensions/identity-local-auth-magiclink.git scm:git:https://github.com/wso2-extensions/identity-local-auth-magiclink.git scm:git:https://github.com/wso2-extensions/identity-local-auth-magiclink.git - HEAD + v1.1.18 components/org.wso2.carbon.identity.application.authenticator.magiclink From 30cd58a2168d0b46cf871463f5dadf5d94437a64 Mon Sep 17 00:00:00 2001 From: WSO2 Builder Date: Fri, 1 Dec 2023 12:34:28 +0000 Subject: [PATCH 3/6] [WSO2 Release] [Jenkins #373] [Release 1.1.18] prepare for next development iteration --- .../pom.xml | 2 +- .../pom.xml | 2 +- pom.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml b/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml index 445720d..28f5949 100644 --- a/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml +++ b/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.local.auth.magiclink identity-local-auth-magiclink ../../pom.xml - 1.1.18 + 1.1.19-SNAPSHOT 4.0.0 diff --git a/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml b/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml index 22e9f64..52b642f 100644 --- a/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml @@ -20,7 +20,7 @@ identity-local-auth-magiclink org.wso2.carbon.identity.local.auth.magiclink - 1.1.18 + 1.1.19-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index 28ed99d..4f84817 100644 --- a/pom.xml +++ b/pom.xml @@ -27,13 +27,13 @@ org.wso2.carbon.identity.local.auth.magiclink identity-local-auth-magiclink pom - 1.1.18 + 1.1.19-SNAPSHOT WSO2 Carbon - MagicLink Authenticator https://github.com/wso2-extensions/identity-local-auth-magiclink.git scm:git:https://github.com/wso2-extensions/identity-local-auth-magiclink.git scm:git:https://github.com/wso2-extensions/identity-local-auth-magiclink.git - v1.1.18 + HEAD components/org.wso2.carbon.identity.application.authenticator.magiclink From c16e30e85e5d2077daed444bb5901c176e9259ab Mon Sep 17 00:00:00 2001 From: Hasanthi Dissanayake Date: Sat, 2 Dec 2023 09:55:33 +0530 Subject: [PATCH 4/6] Add i18nkey as a metadata --- .../authenticator/magiclink/MagicLinkAuthenticator.java | 6 ++++++ .../magiclink/MagicLinkAuthenticatorConstants.java | 1 + 2 files changed, 7 insertions(+) diff --git a/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticator.java b/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticator.java index 947e56c..b65e8b9 100644 --- a/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticator.java +++ b/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticator.java @@ -361,6 +361,12 @@ public String getName() { return MagicLinkAuthenticatorConstants.AUTHENTICATOR_NAME; } + @Override + public String getI18nKey() { + + return MagicLinkAuthenticatorConstants.AUTHENTICATOR_MAGIC_LINK; + } + /** * Method to Trigger the Magic Link event. * diff --git a/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticatorConstants.java b/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticatorConstants.java index 6080c83..d1d0e90 100644 --- a/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticatorConstants.java +++ b/components/org.wso2.carbon.identity.application.authenticator.magiclink/src/main/java/org/wso2/carbon/identity/application/authenticator/magiclink/MagicLinkAuthenticatorConstants.java @@ -29,6 +29,7 @@ private MagicLinkAuthenticatorConstants() { } public static final String AUTHENTICATOR_NAME = "MagicLinkAuthenticator"; + public static final String AUTHENTICATOR_MAGIC_LINK = "authenticator.magic.link"; public static final String MLT = "mlt"; public static final String AUTHENTICATOR_FRIENDLY_NAME = "Magic Link"; public static final String MAGIC_LINK_NOTIFICATION_PAGE = "authenticationendpoint/magic_link_notification.do"; From 706447be3d0b9b57d52ec2d5c6ca8262d1dded32 Mon Sep 17 00:00:00 2001 From: WSO2 Builder Date: Mon, 4 Dec 2023 03:52:46 +0000 Subject: [PATCH 5/6] [WSO2 Release] [Jenkins #375] [Release 1.1.19] prepare release v1.1.19 --- .../pom.xml | 2 +- .../pom.xml | 2 +- pom.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml b/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml index 28f5949..631cbae 100644 --- a/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml +++ b/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.local.auth.magiclink identity-local-auth-magiclink ../../pom.xml - 1.1.19-SNAPSHOT + 1.1.19 4.0.0 diff --git a/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml b/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml index 52b642f..9f9c257 100644 --- a/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml @@ -20,7 +20,7 @@ identity-local-auth-magiclink org.wso2.carbon.identity.local.auth.magiclink - 1.1.19-SNAPSHOT + 1.1.19 ../../pom.xml diff --git a/pom.xml b/pom.xml index 4f84817..a24b59e 100644 --- a/pom.xml +++ b/pom.xml @@ -27,13 +27,13 @@ org.wso2.carbon.identity.local.auth.magiclink identity-local-auth-magiclink pom - 1.1.19-SNAPSHOT + 1.1.19 WSO2 Carbon - MagicLink Authenticator https://github.com/wso2-extensions/identity-local-auth-magiclink.git scm:git:https://github.com/wso2-extensions/identity-local-auth-magiclink.git scm:git:https://github.com/wso2-extensions/identity-local-auth-magiclink.git - HEAD + v1.1.19 components/org.wso2.carbon.identity.application.authenticator.magiclink From 4e8ae6f4b0dc9820d9a4511a93252abb37397a61 Mon Sep 17 00:00:00 2001 From: WSO2 Builder Date: Mon, 4 Dec 2023 03:52:47 +0000 Subject: [PATCH 6/6] [WSO2 Release] [Jenkins #375] [Release 1.1.19] prepare for next development iteration --- .../pom.xml | 2 +- .../pom.xml | 2 +- pom.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml b/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml index 631cbae..4717680 100644 --- a/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml +++ b/components/org.wso2.carbon.identity.application.authenticator.magiclink/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.identity.local.auth.magiclink identity-local-auth-magiclink ../../pom.xml - 1.1.19 + 1.1.20-SNAPSHOT 4.0.0 diff --git a/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml b/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml index 9f9c257..17bead2 100644 --- a/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml +++ b/features/org.wso2.carbon.identity.local.auth.magiclink.server.feature/pom.xml @@ -20,7 +20,7 @@ identity-local-auth-magiclink org.wso2.carbon.identity.local.auth.magiclink - 1.1.19 + 1.1.20-SNAPSHOT ../../pom.xml diff --git a/pom.xml b/pom.xml index a24b59e..778b9a6 100644 --- a/pom.xml +++ b/pom.xml @@ -27,13 +27,13 @@ org.wso2.carbon.identity.local.auth.magiclink identity-local-auth-magiclink pom - 1.1.19 + 1.1.20-SNAPSHOT WSO2 Carbon - MagicLink Authenticator https://github.com/wso2-extensions/identity-local-auth-magiclink.git scm:git:https://github.com/wso2-extensions/identity-local-auth-magiclink.git scm:git:https://github.com/wso2-extensions/identity-local-auth-magiclink.git - v1.1.19 + HEAD components/org.wso2.carbon.identity.application.authenticator.magiclink