mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-21 11:35:34 +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:
parent
06028c35bc
commit
c481d92948
28
apps/web/src/connectors/duo-redirect.html
Normal file
28
apps/web/src/connectors/duo-redirect.html
Normal 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>
|
1
apps/web/src/connectors/duo-redirect.scss
Normal file
1
apps/web/src/connectors/duo-redirect.scss
Normal file
@ -0,0 +1 @@
|
||||
@import "../scss/styles.scss";
|
36
apps/web/src/connectors/duo-redirect.ts
Normal file
36
apps/web/src/connectors/duo-redirect.ts
Normal 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));
|
||||
}
|
||||
});
|
@ -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: {
|
||||
|
Loading…
Reference in New Issue
Block a user