1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-21 16:18:28 +01:00

[PM-5384] Create Duo Redirect Connector (#7594)

* create duo redirect connector

* update webpack and duo_code name

* add handoff message

* remove CSP, center handoff message

---------

Co-authored-by: Jake Fink <jfink@bitwarden.com>
This commit is contained in:
rr-bw 2024-01-18 13:26:02 -08:00 committed by GitHub
parent 06028c35bc
commit c481d92948
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 71 additions and 0 deletions

View File

@ -0,0 +1,28 @@
<!doctype html>
<html class="theme_light">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"
/>
<title>Bitwarden Duo Redirect Connector</title>
</head>
<body class="layout_frontend">
<div class="mt-5 d-flex justify-content-center">
<div>
<img src="../images/logo-dark@2x.png" class="mb-4 logo" alt="Bitwarden" />
<div id="content">
<p class="text-center">
<i
class="bwi bwi-spinner bwi-spin bwi-2x text-muted"
title="Loading"
aria-hidden="true"
></i>
</p>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1 @@
@import "../scss/styles.scss";

View File

@ -0,0 +1,36 @@
import { getQsParam } from "./common";
require("./duo-redirect.scss");
const mobileDesktopCallback = "bitwarden://duo-callback";
window.addEventListener("load", () => {
const client = getQsParam("client");
const code = getQsParam("duo_code");
if (client === "browser" || client === "web") {
const channel = new BroadcastChannel("duoResult");
channel.postMessage({ code: code });
channel.close();
const handOffMessage = ("; " + document.cookie)
.split("; duoHandOffMessage=")
.pop()
.split(";")
.shift();
document.cookie = "duoHandOffMessage=;SameSite=strict;max-age=0";
const content = document.getElementById("content");
content.innerHTML = "";
const p = document.createElement("p");
p.className = "text-center";
p.innerText = handOffMessage;
content.appendChild(p);
} else if (client === "mobile" || client === "desktop") {
document.location.replace(mobileDesktopCallback + "?code=" + encodeURIComponent(code));
}
});

View File

@ -129,6 +129,11 @@ const plugins = [
filename: "captcha-mobile-connector.html",
chunks: ["connectors/captcha"],
}),
new HtmlWebpackPlugin({
template: "./src/connectors/duo-redirect.html",
filename: "duo-redirect-connector.html",
chunks: ["connectors/duo-redirect"],
}),
new CopyWebpackPlugin({
patterns: [
{ from: "./src/.nojekyll" },
@ -317,6 +322,7 @@ const webpackConfig = {
"connectors/duo": "./src/connectors/duo.ts",
"connectors/sso": "./src/connectors/sso.ts",
"connectors/captcha": "./src/connectors/captcha.ts",
"connectors/duo-redirect": "./src/connectors/duo-redirect.ts",
theme_head: "./src/theme.js",
},
optimization: {