-
Start selling to enterprise customers with just a few lines of code.
-
Implement features like single sign-on in minutes instead of months.
+
+
+
+
-
-
-
-
-
Java Magic Link Example
-
- @if(state != null)
-
-
-
Your state param: ${state}
-
+
+
+
+
+
Login Successful
+
+
+
+
+ Key
+ Value
+
+
+ Email
+ ${profile.email}
+
+
+ User ID
+ ${profile.id}
+
+
+ Connection Type
+ ${profile.connectionType}
+
+
+ Connection ID
+ ${profile.connectionId}
+
+ @if(state != null)
+
+ State
+ ${state}
+
+ @endif
+
+
- @endif
-
-
-
- Email
- ID
- Connection Type
-
-
- ${profile.email}
- ${profile.id}
- ${profile.connectionType}
-
-
-
-
-
-
+
diff --git a/java-magic-link-example/src/main/jte/sent.jte b/java-magic-link-example/src/main/jte/sent.jte
index 35ef88f..168ea06 100644
--- a/java-magic-link-example/src/main/jte/sent.jte
+++ b/java-magic-link-example/src/main/jte/sent.jte
@@ -1,15 +1,52 @@
@param String email
+@param String link
-
+
-
-
-
-
-
-
-
A magic link has been sent to your email: ${email}
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Here is your Magic Link, ${email}
+
+
+
\ No newline at end of file
diff --git a/java-magic-link-example/src/resources/main.css b/java-magic-link-example/src/resources/main.css
index 5abb1d8..43ee516 100644
--- a/java-magic-link-example/src/resources/main.css
+++ b/java-magic-link-example/src/resources/main.css
@@ -1,257 +1,388 @@
body {
- font-family: Inter, sans-serif;
- background-color: #f9f9fb;
-
+ font-family: Inter, sans-serif;
+ background-color: #f9f9fb;
}
.container_login {
- display: flex;
- flex-direction: column;
- justify-content: center;
- margin: auto;
- width: 30%;
- height: 90vh;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ margin: auto;
+ width: 30%;
+ height: 90vh;
}
.container_login img {
- height: 150px;
+ height: 150px;
}
.container_login h1 {
- font-size: 65px;
- color: #111111;
- position: relative;
- bottom: 10px;
+ font-size: 65px;
+ color: #111111;
+ position: relative;
+ bottom: 10px;
}
.flex {
- display: flex;
- justify-content: center;
+ display: flex;
+ justify-content: center;
+ align-items: center;
}
.flex_column {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
}
-.space-between {
- justify-content: space-between;
+.m-top-20 {
+ margin-top: 20px;
}
.width-75 {
- width: 75%;
+ width: 75%;
}
.width-40vw {
- width: 40vw;
+ width: 40vw;
+}
+
+.width-25vw {
+ width: 25vw;
+}
+
+.width-18vw {
+ width: 18vw;
+}
+
+.width-225px {
+ width: 225px;
+}
+
+.width-941px {
+ width: 941px;
+}
+
+.width-335 {
+ width: 335px;
+}
+
+.height-315 {
+ height: 315px;
+}
+
+.height-40vh {
+ height: 40vw;
+}
+
+.height-80vh {
+ height: 80vh;
+}
+
+.height-100vh {
+ height: 100vh;
+}
+
+.space-between {
+ justify-content: space-between;
}
.container_success {
- display: flex;
- flex-direction: column;
- justify-content: center;
- margin: auto;
- width: 100%;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ margin: auto;
+ width: 100%;
}
.heading_div {
- margin: 25px 0px 25px 0px;
+ margin: 35px 0px 0px 0px;
}
.heading_text_div {
- align-self: center;
+ align-self: center;
}
.container_success {
- display: flex;
- flex-direction: column;
- justify-content: center;
- margin: auto;
- width: 100%;
- background-size: cover;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ margin: auto;
+ width: 100%;
+ background-size: cover;
+}
+
+.text_input {
+ border: 1px solid #555555;
+ border-radius: 10px;
+ margin: 10px 0px 7px 0px;
+ padding: 5px;
+ height: 35px;
+ text-align: center;
+}
+
+.code-input {
+ width: 75px;
+ height: 100px;
+ margin: 0px 5px 30px 5px;
+ font-size: 60px;
+ color: darkslategray;
+}
+
+.qr_div {
+ align-self: center;
+ margin-top: 45px;
+}
+
+.qr_code {
+ width: 7vw;
+ max-width: 100px;
+}
+
+.factor_card {
+ border: 1px solid #555555;
+ border-radius: 10px;
+ width: 20vw;
+ margin: 0px 15px 0px 15px;
+ padding: 25px;
+}
+
+.card {
+ border: 1px solid #555555;
+ border-radius: 10px;
+ margin: 0px 15px 0px 15px;
+ padding: 25px 50px;
+ margin-bottom: 20px;
+}
+
+.profile_card {
+ width: 40vw;
+ overflow: scroll;
+ background: white;
+ box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
}
.button {
- background-color: #6363f1;
- border: 2px solid #6363f1;
- border-radius: 26px;
- color: white;
- padding: 8px 16px;
- text-align: center;
- text-decoration: none;
- display: inline-block;
- font-size: 16px;
- margin: 4px 2px;
- transition-duration: 0.4s;
- cursor: pointer;
- box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
+ background-color: #6363f1;
+ border: 2px solid #6363f1;
+ border-radius: 10px;
+ color: white;
+ padding: 8px 16px;
+ text-align: center;
+ text-decoration: none;
+ display: inline-block;
+ font-size: 16px;
+ margin: 4px 2px;
+ transition-duration: 0.4s;
+ cursor: pointer;
+ box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
}
.button-outline {
- background-color: #f9f9fb;
- color: #6363f1;
- padding: 8px 16px;
+ background-color: #f9f9fb;
+ color: #6363f1;
+ padding: 8px 16px;
+}
+
+.button-sm {
+ padding: 8px 16px;
}
.button:hover,
.button-outline:hover {
- background-color: #555555;
- border: 2px solid #555555;
- color: white;
+ background-color: #555555;
+ border: 2px solid #555555;
+ color: white;
}
.sales-button {
- margin-left: 10px;
+ margin-left: 10px;
}
.login_button {
- width: 95%;
- box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
+ width: 100%;
+ box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
+ background-color: white;
+ color: ;
+}
+
+.login_button:hover {
+ border-color: #6363f1;
+ color: #292929;
}
h2,
h1 {
- text-align: center;
- color: #555555;
+ text-align: center;
+ color: #555555;
}
.logged_in_div_right {
- width: 60%;
- height: 90vh;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- position: relative;
- bottom: 10%;
- /* background-color: #f9f9fb; */
+ width: 60%;
+ height: 90vh;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ position: relative;
+ bottom: 10%;
}
.logged_in_div_left {
- width: 40%;
- height: 125vh;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: left;
- background-color: #f9f9fb;
- margin-left: 4vw;
+ width: 40%;
+ height: 100vh;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: left;
+ background-color: #f9f9fb;
+ margin-left: 4vw;
}
.logged_in_div_left div {
- justify-content: left;
- position: relative;
- bottom: 20%;
+ justify-content: left;
+ position: relative;
+ bottom: 20%;
}
.logged_in_div_left h1 {
- color: #111111;
- font-size: 75px;
- text-align: left;
- margin-bottom: 0px;
- font-weight: normal;
- letter-spacing: -.05em;
+ color: #111111;
+ font-size: 75px;
+ text-align: left;
+ margin-bottom: 0px;
+ font-weight: normal;
+ letter-spacing: -0.05em;
}
.home-hero-gradient {
- background-image: linear-gradient(45deg, #a163f1, #6363f1 22%, #3498ea 40%, #40dfa3 67%, rgba(64, 223, 163, 0));
- background-size: 150% 100%;
- background-repeat: no-repeat;
- -webkit-background-clip: text;
- -webkit-text-fill-color: transparent;
- background-clip: text;
- animation: intro-gradient 1.2s cubic-bezier(0.85, 0.26, 0.89, 0.93);
- animation-iteration-count: 1;
- animation-fill-mode: backwards;
- animation-delay: 0.4s;
- text-align: left;
- font-size: 75px;
- letter-spacing: -.05em;
- font-weight: normal;
- margin-top: 0px;
+ background-image: linear-gradient(
+ 45deg,
+ #a163f1,
+ #6363f1 22%,
+ #3498ea 40%,
+ #40dfa3 67%,
+ rgba(64, 223, 163, 0)
+ );
+ background-size: 150% 100%;
+ background-repeat: no-repeat;
+ -webkit-background-clip: text;
+ -webkit-text-fill-color: transparent;
+ background-clip: text;
+ animation: intro-gradient 1.2s cubic-bezier(0.85, 0.26, 0.89, 0.93);
+ animation-iteration-count: 1;
+ animation-fill-mode: backwards;
+ animation-delay: 0.4s;
+ text-align: left;
+ font-size: 75px;
+ letter-spacing: -0.05em;
+ font-weight: normal;
+ margin-top: 0px;
}
.title-text {
- margin-top: -50px;
+ margin-bottom: -50px;
}
.title-subtext {
- color: gray;
- line-height: 10px;
- margin-bottom: 15px;
- font-weight: 200;
+ color: gray;
+ line-height: 10px;
+ margin-bottom: 15px;
+ font-weight: 200;
}
.logged_in_div_left button {
- padding: 8px 22px;
- box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
-}
-
-div.text_box {
- background-color: #f9f9fb;
- width: 40vw;
- max-height: 30vh;
- padding: 10px;
- word-wrap: break-word;
- overflow: scroll;
- border-width: 3px;
- border-style: solid;
- border-image:
- linear-gradient(#a163f1, #6363f1 22%, #3498ea 40%, #40dfa3 67%, rgba(64, 223, 163, 0)) 0 100%;
+ padding: 8px 22px;
+ box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
}
.logged_in_nav {
- display: flex;
- justify-content: space-between;
- background-color: #f9f9fb;
- height: 60px;
- padding: 15px 30px 15px 30px;
+ display: flex;
+ justify-content: space-between;
+ background-color: #f9f9fb;
+
+ padding: 15px 30px 15px 30px;
+ z-index: 1000;
- z-index: 1000;
}
.logged_in_nav p {
- padding: 4px 0px 0px 15px;
- line-height: 1;
- color: #29363d;
+ padding: 4px 0px 0px 15px;
+ line-height: 1;
+ color: #29363d;
}
.logged_in_nav img {
- height: 50px;
+ height: 50px;
}
.nav-item {
- color: black;
- border: 2px solid #f9f9fb;
- background-color: #f9f9fb;
- box-shadow: none;
- border-radius: 5px;
+ color: black;
+ border: 2px solid #f9f9fb;
+ background-color: #f9f9fb;
+ box-shadow: none;
+ border-radius: 5px;
}
.blog-nav-button {
- margin-right: 20px;
- background-color: #f9f9fb;
- border: 2px solid #f9f9fb;
+ margin-right: 20px;
+ background-color: #f9f9fb;
+ border: 2px solid #f9f9fb;
}
.nav-item:hover {
- background-color: #f9f9fb;
- border: 2px solid #f9f9fb;
- color: #a6a4a4;
+ background-color: #f9f9fb;
+ border: 2px solid #f9f9fb;
+ color: #a6a4a4;
}
-pre.prettyprint {
- border: none !important;
+.workos-logo {
+ position: relative;
+ top: 38px;
+ padding-right: 25px;
+ height: 75px !important;
}
-.text_input {
- border: 1px solid #555555;
- border-radius: 10px;
- margin: 20px 0px 7px 0px;
- padding: 5px;
- height: 35px;
- width: 18vw;
- text-align: center;
-}
\ No newline at end of file
+.webhooks_container {
+ width: 45vw;
+ padding: 25px;
+ max-height: 450px;
+ overflow-y: scroll;
+}
+
+.mb-0 {
+ margin-bottom: 0px;
+}
+
+.mb-20 {
+ margin-botton: 20px;
+}
+
+.google_button {
+ background-image: url("./images/google-button.png");
+ background-size: cover;
+}
+
+.microsoft_button {
+ background-image: url("./images/microsoft-button.png");
+ background-size: cover;
+}
+
+.saml_button {
+ background-image: url("./images/saml-button.png");
+ background-size: cover;
+}
+
+.error_message {
+ color: #6363f1;
+ margin-top: 0px;
+ font-size: 12px;
+}
+
+#noborder {
+ border: none;
+}
+
+#noborder > :first-child {
+ display: none;
+}
diff --git a/java-mfa-example/src/main/java/com/workos/java/examples/MfaApp.java b/java-mfa-example/src/main/java/com/workos/java/examples/MfaApp.java
index f48699e..21302d3 100644
--- a/java-mfa-example/src/main/java/com/workos/java/examples/MfaApp.java
+++ b/java-mfa-example/src/main/java/com/workos/java/examples/MfaApp.java
@@ -1,4 +1,5 @@
package com.workos.java.examples;
+
import com.workos.WorkOS;
import com.workos.mfa.MfaApi;
import com.workos.mfa.MfaApi.EnrollFactorOptions;
@@ -20,6 +21,7 @@
public class MfaApp {
+
private final WorkOS workos;
private final String clientId;
@@ -45,10 +47,13 @@ public MfaApp() {
public void home(Context ctx) {
- if(ctx.sessionAttribute("arrayFactorList") != null) {
+ if (ctx.sessionAttribute("arrayFactorList") != null) {
ArrayList
factorIdList = ctx.sessionAttribute("factorIdList");
- ArrayList factorList = ctx.sessionAttribute("arrayFactorList");
- ctx.render("home.jte", Collections.singletonMap("factorIdList", factorIdList));
+ ArrayList factorList = ctx.sessionAttribute("arrayFactorList");
+ Map jteParams = new HashMap<>();
+ jteParams.put("factorList", factorList);
+ System.out.println(jteParams);
+ ctx.render("home.jte", jteParams);
} else {
ctx.render("home.jte");
}
@@ -86,7 +91,7 @@ public void verify_factor(Context ctx) {
ctx.render("challenge_result.jte", jteParams);
} catch (Exception e) {
- if(e.equals(null)) {
+ if (e.equals(null)) {
ctx.render("error.jte");
}
Map jteParams = new HashMap<>();
@@ -101,7 +106,7 @@ public void challenge_factor(Context ctx) {
String smsCode = ctx.formParam("sms_message");
String currentFactorId = ctx.sessionAttribute("currentFactorId");
- if(factorType.equals("sms")) {
+ if (factorType.equals("sms")) {
ChallengeFactorOptions options = MfaApi.ChallengeFactorOptions.builder()
.authenticationFactorId(currentFactorId)
.smsTemplate(smsCode)
@@ -109,10 +114,10 @@ public void challenge_factor(Context ctx) {
Challenge challenge = workos.mfa.challengeFactor(options);
ctx.sessionAttribute("currentChallengeId", challenge.id);
- ctx.render ("challenge_factor.jte");
+ ctx.render("challenge_factor.jte");
}
- if(factorType.equals("totp")) {
+ if (factorType.equals("totp")) {
ChallengeFactorOptions options = MfaApi.ChallengeFactorOptions.builder()
.authenticationFactorId(currentFactorId)
.build();
@@ -120,14 +125,14 @@ public void challenge_factor(Context ctx) {
Challenge challenge = workos.mfa.challengeFactor(options);
ctx.sessionAttribute("currentChallengeId", challenge.id);
} catch (Exception e) {
- if(e.equals(null)) {
+ if (e.equals(null)) {
ctx.render("error.jte");
}
Map jteParams = new HashMap<>();
jteParams.put("error", e.getMessage());
ctx.render("error.jte", jteParams);
}
- ctx.render ("challenge_factor.jte");
+ ctx.render("challenge_factor.jte");
}
}
@@ -142,35 +147,35 @@ public void factor_detail(Context ctx) {
jteParams.put("createdAt", currentFactor.createdAt);
jteParams.put("type", currentFactor.type);
- switch(currentFactor.type) {
+ switch (currentFactor.type) {
case "sms":
jteParams.put("phoneNumber", currentFactor.sms.phoneNumber);
jteParams.put("factorId", currentFactor.id);
jteParams.put("createdAt", currentFactor.createdAt);
jteParams.put("type", currentFactor.type);
break;
- case "totp":
+ case "totp":
jteParams.put("factorId", currentFactor.id);
jteParams.put("createdAt", currentFactor.createdAt);
jteParams.put("type", currentFactor.type);
jteParams.put("qrCode", currentFactor.totp.qrCode);
break;
- default:
- String error = "Invalid type";
- String errorMessage = "Type must be either 'sms' or 'totp'";
- jteParams.put("error", error);
- jteParams.put("errorMessage", errorMessage);
- ctx.render("error.jte", jteParams);
+ default:
+ String error = "Invalid type";
+ String errorMessage = "Type must be either 'sms' or 'totp'";
+ jteParams.put("error", error);
+ jteParams.put("errorMessage", errorMessage);
+ ctx.render("error.jte", jteParams);
}
ctx.render("factor_detail.jte", jteParams);
}
- public void enroll_factor_details(Context ctx ) {
+ public void enroll_factor_details(Context ctx) {
ctx.render("enroll_factor.jte");
}
- public void enroll_totp_factor(Context ctx ) {
+ public void enroll_totp_factor(Context ctx) {
JsonNode jsonNode = ctx.bodyAsClass(JsonNode.class);
String issuer = jsonNode.get("issuer").asText();
String user = jsonNode.get("user").asText();
@@ -186,7 +191,7 @@ public void enroll_totp_factor(Context ctx ) {
Factor factor = workos.mfa.enrollFactor(options);
String factorId = factor.id;
- if(ctx.sessionAttribute("factorList") != null) {
+ if (ctx.sessionAttribute("factorList") != null) {
ArrayList factorIdList = ctx.sessionAttribute("factorIdList");
factorIdList.add(factorId);
ctx.sessionAttribute("factorIdList", factorIdList);
@@ -206,7 +211,7 @@ public void enroll_totp_factor(Context ctx ) {
ctx.sessionAttribute("arrayFactorList", list);
ctx.status(200).json(factor);
} catch (Exception e) {
- if(e.equals(null)) {
+ if (e.equals(null)) {
ctx.render("error.jte");
}
Map jteParams = new HashMap<>();
@@ -228,7 +233,7 @@ public void enroll_sms_factor(Context ctx) {
Factor factor = workos.mfa.enrollFactor(options);
String factorId = factor.id;
- if(ctx.sessionAttribute("factorList") != null) {
+ if (ctx.sessionAttribute("factorList") != null) {
ArrayList factorIdList = ctx.sessionAttribute("factorIdList");
factorIdList.add(factorId);
ctx.sessionAttribute("factorIdList", factorIdList);
@@ -248,7 +253,7 @@ public void enroll_sms_factor(Context ctx) {
ctx.sessionAttribute("arrayFactorList", list);
ctx.redirect("/");
} catch (Exception e) {
- if(e.equals(null)) {
+ if (e.equals(null)) {
ctx.render("error.jte");
}
Map jteParams = new HashMap<>();
@@ -257,7 +262,7 @@ public void enroll_sms_factor(Context ctx) {
}
}
- public void clear_session(Context ctx ) {
+ public void clear_session(Context ctx) {
ctx.sessionAttribute("factorList", null);
ctx.sessionAttribute("arrayFactorList", null);
ctx.sessionAttribute("factorIdList", null);
diff --git a/java-mfa-example/src/main/jte/challenge_factor.jte b/java-mfa-example/src/main/jte/challenge_factor.jte
index c21ee83..4677ba9 100644
--- a/java-mfa-example/src/main/jte/challenge_factor.jte
+++ b/java-mfa-example/src/main/jte/challenge_factor.jte
@@ -7,32 +7,24 @@