fist commit
Cette révision appartient à :
révision
5e5b4c5983
16 files changed
+1837
No files matched your search
@@ -0,0 +1,147 @@
|
||||
const DEFAULTS = {
|
||||
issuer: "https://auth.domain.net",
|
||||
protectedHosts: ["domain.net", "domain.net2"],
|
||||
pollIntervalMs: 60000
|
||||
};
|
||||
|
||||
let state = {
|
||||
status: "checking",
|
||||
username: "",
|
||||
expiresAt: null,
|
||||
error: ""
|
||||
};
|
||||
|
||||
async function settings() {
|
||||
return {
|
||||
...DEFAULTS,
|
||||
...(await browser.storage.local.get(DEFAULTS))
|
||||
};
|
||||
}
|
||||
|
||||
function hostMatches(host, suffix) {
|
||||
const normalized = String(suffix || "")
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replace(/^\*\./, "");
|
||||
|
||||
return normalized && (
|
||||
host === normalized ||
|
||||
host.endsWith("." + normalized)
|
||||
);
|
||||
}
|
||||
|
||||
async function refreshSession() {
|
||||
const cfg = await settings();
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
cfg.issuer.replace(/\/$/, "") + "/user/api/info",
|
||||
{
|
||||
method: "GET",
|
||||
credentials: "include",
|
||||
cache: "no-store"
|
||||
}
|
||||
);
|
||||
|
||||
if (response.status === 401) {
|
||||
state = {
|
||||
status: "anonymous",
|
||||
username: "",
|
||||
expiresAt: null,
|
||||
error: ""
|
||||
};
|
||||
} else if (!response.ok) {
|
||||
throw new Error("HTTP " + response.status);
|
||||
} else {
|
||||
const data = await response.json();
|
||||
|
||||
state = {
|
||||
status: "authenticated",
|
||||
username: data.username || "",
|
||||
expiresAt: null,
|
||||
error: ""
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
state = {
|
||||
...state,
|
||||
status: "unavailable",
|
||||
error: error.message || String(error)
|
||||
};
|
||||
}
|
||||
|
||||
await browser.storage.local.set({ sessionState: state });
|
||||
|
||||
await browser.tabs.query({}).then(tabs => {
|
||||
for (const tab of tabs) {
|
||||
if (tab.id) {
|
||||
browser.tabs.sendMessage(
|
||||
tab.id,
|
||||
{ type: "SSO_STATE", state }
|
||||
).catch(() => {});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
browser.runtime.onMessage.addListener(async message => {
|
||||
if (message?.type === "SSO_IS_HOST_ALLOWED") {
|
||||
const cfg = await settings();
|
||||
|
||||
return (cfg.protectedHosts || []).some(suffix =>
|
||||
hostMatches(message.host, suffix)
|
||||
);
|
||||
}
|
||||
|
||||
if (message?.type === "SSO_GET_STATE") {
|
||||
return refreshSession();
|
||||
}
|
||||
|
||||
if (message?.type === "SSO_LOGOUT") {
|
||||
const cfg = await settings();
|
||||
const response = await fetch(
|
||||
cfg.issuer.replace(/\/$/, "") + "/logout",
|
||||
{
|
||||
method: "POST",
|
||||
credentials: "include",
|
||||
cache: "no-store"
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
"Déconnexion refusée (HTTP " + response.status + ")"
|
||||
);
|
||||
}
|
||||
|
||||
state = {
|
||||
status: "anonymous",
|
||||
username: "",
|
||||
expiresAt: null,
|
||||
error: ""
|
||||
};
|
||||
|
||||
await browser.storage.local.set({ sessionState: state });
|
||||
|
||||
await browser.tabs.query({}).then(tabs => {
|
||||
for (const tab of tabs) {
|
||||
if (tab.id) {
|
||||
browser.tabs.sendMessage(
|
||||
tab.id,
|
||||
{ type: "SSO_STATE", state }
|
||||
).catch(() => {});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
});
|
||||
|
||||
browser.runtime.onInstalled.addListener(() => refreshSession());
|
||||
browser.runtime.onStartup.addListener(() => refreshSession());
|
||||
|
||||
refreshSession();
|
||||
setInterval(refreshSession, DEFAULTS.pollIntervalMs);
|
||||
@@ -0,0 +1,307 @@
|
||||
(async () => {
|
||||
if (
|
||||
window.top !== window ||
|
||||
document.getElementById("skynet-sso-bar")
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const allowed = await browser.runtime.sendMessage({
|
||||
type: "SSO_IS_HOST_ALLOWED",
|
||||
host: location.hostname
|
||||
}).catch(() => false);
|
||||
|
||||
if (!allowed || document.getElementById("skynet-sso-bar")) {
|
||||
return;
|
||||
}
|
||||
|
||||
const prefs = await browser.storage.local.get({
|
||||
showNotch: true
|
||||
});
|
||||
|
||||
const bar = document.createElement("aside");
|
||||
bar.id = "skynet-sso-bar";
|
||||
bar.dataset.collapsed = "false";
|
||||
bar.dataset.showNotch = String(prefs.showNotch !== false);
|
||||
bar.setAttribute("aria-live", "polite");
|
||||
|
||||
bar.innerHTML = `
|
||||
<button
|
||||
class="skynet-sso-brand"
|
||||
type="button"
|
||||
title="Accueil SKYNET"
|
||||
>
|
||||
<img
|
||||
class="skynet-sso-mark"
|
||||
src="${browser.runtime.getURL("icons/skynet.png")}"
|
||||
alt=""
|
||||
>
|
||||
<span>SKYNET <b>SSO</b></span>
|
||||
</button>
|
||||
|
||||
<div class="skynet-sso-status">
|
||||
<i></i>
|
||||
<span class="skynet-sso-label">Vérification de la session…</span>
|
||||
</div>
|
||||
|
||||
<div class="skynet-sso-user"></div>
|
||||
|
||||
<div class="skynet-sso-actions">
|
||||
<button class="skynet-sso-logout" type="button" hidden>
|
||||
Déconnexion
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="skynet-sso-collapse"
|
||||
type="button"
|
||||
aria-label="Masquer la barre SKYNET"
|
||||
title="Masquer la barre"
|
||||
>
|
||||
<span aria-hidden="true"></span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="skynet-sso-tab"
|
||||
type="button"
|
||||
aria-label="Afficher la barre SKYNET"
|
||||
title="Afficher la barre"
|
||||
><span aria-hidden="true"></span></button>
|
||||
`;
|
||||
|
||||
document.documentElement.appendChild(bar);
|
||||
|
||||
function collapseAfterPageLoad() {
|
||||
bar.dataset.collapsed = "true";
|
||||
}
|
||||
|
||||
if (document.readyState === "complete") {
|
||||
collapseAfterPageLoad();
|
||||
} else {
|
||||
window.addEventListener("load", collapseAfterPageLoad, { once: true });
|
||||
}
|
||||
|
||||
const dialog = document.createElement("div");
|
||||
dialog.id = "skynet-sso-dialog";
|
||||
dialog.innerHTML = `
|
||||
<div class="skynet-sso-dialog-backdrop"></div>
|
||||
<section
|
||||
class="skynet-sso-dialog-panel"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="skynet-sso-dialog-title"
|
||||
aria-describedby="skynet-sso-dialog-description"
|
||||
tabindex="-1"
|
||||
>
|
||||
<div class="skynet-sso-dialog-symbol" aria-hidden="true">
|
||||
<span></span>
|
||||
</div>
|
||||
<p class="skynet-sso-dialog-eyebrow">SKYNET SECURITY</p>
|
||||
<h2 id="skynet-sso-dialog-title">Confirmer la déconnexion</h2>
|
||||
<p id="skynet-sso-dialog-description">
|
||||
Souhaitez-vous vraiment fermer votre session SKYNET sur l’ensemble des services ?
|
||||
</p>
|
||||
<p class="skynet-sso-dialog-error" role="alert" hidden></p>
|
||||
<div class="skynet-sso-dialog-progress" aria-live="polite" hidden>
|
||||
<span class="skynet-sso-spinner" aria-hidden="true"></span>
|
||||
<span class="skynet-sso-dialog-progress-label">Déconnexion en cours…</span>
|
||||
</div>
|
||||
<div class="skynet-sso-dialog-actions">
|
||||
<button class="skynet-sso-dialog-cancel" type="button">Annuler</button>
|
||||
<button class="skynet-sso-dialog-confirm" type="button">
|
||||
<span>Me déconnecter</span>
|
||||
<span class="skynet-sso-dialog-arrow" aria-hidden="true">↗</span>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
`;
|
||||
document.documentElement.appendChild(dialog);
|
||||
|
||||
const dialogPanel = dialog.querySelector(".skynet-sso-dialog-panel");
|
||||
const dialogCancel = dialog.querySelector(".skynet-sso-dialog-cancel");
|
||||
const dialogConfirm = dialog.querySelector(".skynet-sso-dialog-confirm");
|
||||
const dialogError = dialog.querySelector(".skynet-sso-dialog-error");
|
||||
const dialogProgress = dialog.querySelector(".skynet-sso-dialog-progress");
|
||||
const dialogProgressLabel = dialog.querySelector(".skynet-sso-dialog-progress-label");
|
||||
const dialogDescription = dialog.querySelector("#skynet-sso-dialog-description");
|
||||
|
||||
function closeLogoutDialog() {
|
||||
if (dialog.dataset.busy === "true") return;
|
||||
dialog.dataset.open = "false";
|
||||
dialogError.hidden = true;
|
||||
logout.focus();
|
||||
}
|
||||
|
||||
function openLogoutDialog() {
|
||||
dialog.dataset.open = "true";
|
||||
dialog.dataset.busy = "false";
|
||||
dialogError.hidden = true;
|
||||
dialogProgress.hidden = true;
|
||||
dialogDescription.hidden = false;
|
||||
dialogConfirm.disabled = false;
|
||||
dialogCancel.disabled = false;
|
||||
dialogConfirm.querySelector("span").textContent = "Me déconnecter";
|
||||
dialogPanel.focus();
|
||||
}
|
||||
|
||||
function setLogoutBusy(busy) {
|
||||
dialog.dataset.busy = String(busy);
|
||||
dialogProgress.hidden = !busy;
|
||||
dialogDescription.hidden = busy;
|
||||
dialogCancel.disabled = busy;
|
||||
dialogConfirm.disabled = busy;
|
||||
dialogConfirm.querySelector("span").textContent = busy
|
||||
? "Déconnexion…"
|
||||
: "Me déconnecter";
|
||||
dialogProgressLabel.textContent = "Déconnexion en cours…";
|
||||
dialogError.hidden = true;
|
||||
}
|
||||
|
||||
dialogCancel.addEventListener("click", closeLogoutDialog);
|
||||
dialog.querySelector(".skynet-sso-dialog-backdrop")
|
||||
.addEventListener("click", closeLogoutDialog);
|
||||
dialogConfirm.addEventListener("click", async () => {
|
||||
if (dialog.dataset.busy === "true") return;
|
||||
|
||||
setLogoutBusy(true);
|
||||
|
||||
try {
|
||||
const result = await browser.runtime.sendMessage({
|
||||
type: "SSO_LOGOUT"
|
||||
});
|
||||
|
||||
if (!result?.success) {
|
||||
throw new Error("Le serveur n’a pas confirmé la déconnexion.");
|
||||
}
|
||||
|
||||
dialogProgressLabel.textContent = "Session fermée. Actualisation…";
|
||||
render({ status: "anonymous" });
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
dialog.dataset.busy = "false";
|
||||
dialogProgress.hidden = true;
|
||||
dialogDescription.hidden = false;
|
||||
dialogCancel.disabled = false;
|
||||
dialogConfirm.disabled = false;
|
||||
dialogConfirm.querySelector("span").textContent = "Réessayer";
|
||||
dialogError.textContent = error.message || "La déconnexion a échoué. Veuillez réessayer.";
|
||||
dialogError.hidden = false;
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", event => {
|
||||
if (dialog.dataset.open !== "true") return;
|
||||
if (event.key === "Escape") {
|
||||
event.preventDefault();
|
||||
closeLogoutDialog();
|
||||
}
|
||||
if (event.key === "Tab") {
|
||||
const focusable = [dialogCancel, dialogConfirm].filter(
|
||||
element => !element.disabled
|
||||
);
|
||||
if (!focusable.length) {
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
const first = focusable[0];
|
||||
const last = focusable[focusable.length - 1];
|
||||
if (event.shiftKey && document.activeElement === first) {
|
||||
event.preventDefault();
|
||||
last.focus();
|
||||
} else if (!event.shiftKey && document.activeElement === last) {
|
||||
event.preventDefault();
|
||||
first.focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const label = bar.querySelector(".skynet-sso-label");
|
||||
const user = bar.querySelector(".skynet-sso-user");
|
||||
const logout = bar.querySelector(".skynet-sso-logout");
|
||||
const tab = bar.querySelector(".skynet-sso-tab");
|
||||
const collapse = bar.querySelector(".skynet-sso-collapse");
|
||||
const brand = bar.querySelector(".skynet-sso-brand");
|
||||
|
||||
brand.addEventListener("click", async event => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
const cfg = await browser.storage.local.get({
|
||||
homeUrl: "https://celjim.fr"
|
||||
});
|
||||
|
||||
const destination = String(
|
||||
cfg.homeUrl || "https://git.celjim.fr/public/zoraxy-sso-extension-firefox"
|
||||
).trim();
|
||||
|
||||
if (/^https?:\/\//i.test(destination)) {
|
||||
window.location.assign(destination);
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener("click", event => {
|
||||
if (
|
||||
bar.dataset.collapsed !== "true" &&
|
||||
!bar.contains(event.target)
|
||||
) {
|
||||
bar.dataset.collapsed = "true";
|
||||
}
|
||||
}, true);
|
||||
|
||||
collapse.addEventListener("click", event => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
bar.dataset.collapsed = "true";
|
||||
});
|
||||
|
||||
function revealBar(event) {
|
||||
event?.preventDefault();
|
||||
event?.stopPropagation();
|
||||
bar.dataset.collapsed = "false";
|
||||
}
|
||||
|
||||
tab.addEventListener("mouseenter", revealBar);
|
||||
tab.addEventListener("click", revealBar);
|
||||
|
||||
function render(state) {
|
||||
bar.dataset.state = state.status;
|
||||
user.textContent = state.username || "";
|
||||
logout.hidden = state.status !== "authenticated";
|
||||
|
||||
if (state.status === "authenticated") {
|
||||
label.textContent = "Session SSO active";
|
||||
} else if (state.status === "anonymous") {
|
||||
label.textContent = "Aucune session SSO";
|
||||
} else if (state.status === "unavailable") {
|
||||
label.textContent = "Serveur SSO indisponible";
|
||||
} else {
|
||||
label.textContent = "Vérification de la session…";
|
||||
}
|
||||
}
|
||||
|
||||
browser.runtime.sendMessage({
|
||||
type: "SSO_GET_STATE"
|
||||
}).then(render).catch(() => {
|
||||
render({ status: "unavailable" });
|
||||
});
|
||||
|
||||
browser.runtime.onMessage.addListener(message => {
|
||||
if (message?.type === "SSO_STATE") {
|
||||
render(message.state);
|
||||
}
|
||||
});
|
||||
|
||||
browser.storage.onChanged.addListener((changes, area) => {
|
||||
if (area === "local" && changes.showNotch) {
|
||||
bar.dataset.showNotch = String(
|
||||
changes.showNotch.newValue !== false
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
logout.addEventListener("click", event => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
openLogoutDialog();
|
||||
});
|
||||
})();
|
||||
Fichier binaire non affiché.
|
Après Largeur: | Hauteur: | Taille: 70 KiB |
Fichier binaire non affiché.
|
Après Largeur: | Hauteur: | Taille: 58 KiB |
Fichier binaire non affiché.
|
Après Largeur: | Hauteur: | Taille: 76 KiB |
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "SKYNET SSO",
|
||||
"version": "0.0.1",
|
||||
"description": "Affiche l'état de la session SSO Zoraxy et permet une déconnexion.",
|
||||
"browser_specific_settings": {
|
||||
"gecko": {
|
||||
"id": "skynet-sso@celjim.fr",
|
||||
"strict_min_version": "128.0"
|
||||
}
|
||||
},
|
||||
"permissions": ["storage", "tabs"],
|
||||
"host_permissions": ["http://*/*", "https://*/*"],
|
||||
"web_accessible_resources": [
|
||||
{
|
||||
"resources": ["icons/skynet.png"],
|
||||
"matches": ["http://*/*", "https://*/*"]
|
||||
}
|
||||
],
|
||||
"icons": { "128": "icons/logoSkynet.ico" },
|
||||
"background": { "scripts": ["background.js"] },
|
||||
"content_scripts": [{
|
||||
"matches": ["http://*/*", "https://*/*"],
|
||||
"js": ["content.js"],
|
||||
"css": ["skynet.css"],
|
||||
"run_at": "document_idle"
|
||||
}],
|
||||
"options_ui": { "page": "options.html", "open_in_tab": true },
|
||||
"action": {
|
||||
"default_title": "SKYNET SSO",
|
||||
"default_popup": "popup.html",
|
||||
"default_icon": { "128": "icons/logoSkynet.ico" }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
background: #071629;
|
||||
color: #e8f5ff;
|
||||
font: 14px/1.5 Inter, "Segoe UI", sans-serif;
|
||||
}
|
||||
|
||||
main {
|
||||
max-width: 680px;
|
||||
margin: 48px auto;
|
||||
padding: 28px;
|
||||
background: #0c213c;
|
||||
border: 1px solid #1d4565;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
header {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
align-items: center;
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
|
||||
.app-icon {
|
||||
width: 54px;
|
||||
height: 54px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
letter-spacing: 0.1em;
|
||||
font-size: 19px;
|
||||
}
|
||||
|
||||
header p,
|
||||
.hint {
|
||||
margin: 2px 0;
|
||||
color: #91abc2;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin: 18px 0 7px;
|
||||
color: #c8e3f8;
|
||||
}
|
||||
|
||||
input:not([type="checkbox"]),
|
||||
textarea {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 1px solid #294c68;
|
||||
border-radius: 6px;
|
||||
background: #071629;
|
||||
color: #e8f5ff;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.toggle-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 22px;
|
||||
}
|
||||
|
||||
.toggle-row input {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
accent-color: #38c8ff;
|
||||
}
|
||||
|
||||
button {
|
||||
margin-top: 18px;
|
||||
padding: 10px 18px;
|
||||
border: 1px solid #38aee0;
|
||||
border-radius: 6px;
|
||||
background: #10436a;
|
||||
color: white;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#result {
|
||||
margin-left: 12px;
|
||||
color: #57ddb0;
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Paramètres SKYNET SSO</title>
|
||||
<link rel="stylesheet" href="options.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main>
|
||||
<header>
|
||||
<img
|
||||
class="app-icon"
|
||||
src="icons/skynet.png"
|
||||
alt=""
|
||||
>
|
||||
|
||||
<div>
|
||||
<h1>SKYNET SSO</h1>
|
||||
<p>Paramètres de l’extension Firefox</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<label for="homeUrl">
|
||||
URL de navigation lors du clique sur l'icon
|
||||
</label>
|
||||
<input
|
||||
id="homeUrl"
|
||||
type="url"
|
||||
placeholder="https://home.domain.net"
|
||||
>
|
||||
|
||||
<label for="issuer">
|
||||
URL du serveur Zoraxy
|
||||
</label>
|
||||
<input
|
||||
id="issuer"
|
||||
type="url"
|
||||
placeholder="https://auth.domain.net"
|
||||
>
|
||||
|
||||
<label for="hosts">
|
||||
Domaines sur lesquels afficher la barre
|
||||
</label>
|
||||
<textarea
|
||||
id="hosts"
|
||||
rows="6"
|
||||
placeholder="domain.net domain2.net"
|
||||
></textarea>
|
||||
|
||||
<p class="hint">
|
||||
Un domaine par ligne. Les sous-domaines sont inclus automatiquement.
|
||||
Exemple : domain.net couvre sub.domain.net.
|
||||
</p>
|
||||
|
||||
<label class="toggle-row">
|
||||
<input id="showNotch" type="checkbox">
|
||||
<span>
|
||||
Afficher l’encoche pour pouvoir rouvrir la barre après masquage
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<button id="save">
|
||||
Enregistrer
|
||||
</button>
|
||||
|
||||
<span id="result" role="status"></span>
|
||||
</main>
|
||||
|
||||
<script src="options.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,60 @@
|
||||
const homeUrl = document.getElementById("homeUrl");
|
||||
const issuer = document.getElementById("issuer");
|
||||
const hosts = document.getElementById("hosts");
|
||||
const showNotch = document.getElementById("showNotch");
|
||||
const result = document.getElementById("result");
|
||||
|
||||
browser.storage.local.get({
|
||||
homeUrl: "https://home.domain.net",
|
||||
issuer: "https://auth.domain.net",
|
||||
protectedHosts: ["domain.net", "domain2.net"],
|
||||
showNotch: true
|
||||
}).then(cfg => {
|
||||
homeUrl.value = cfg.homeUrl;
|
||||
issuer.value = cfg.issuer;
|
||||
hosts.value = cfg.protectedHosts.join("\n");
|
||||
showNotch.checked = cfg.showNotch !== false;
|
||||
});
|
||||
|
||||
document.getElementById("save").addEventListener("click", async () => {
|
||||
const value = issuer.value.trim().replace(/\/$/, "");
|
||||
|
||||
if (!/^https:\/\//i.test(value)) {
|
||||
result.textContent = "L’URL doit commencer par https://";
|
||||
return;
|
||||
}
|
||||
|
||||
const domains = [
|
||||
...new Set(
|
||||
hosts.value
|
||||
.split(/[\r\n,;]+/)
|
||||
.map(value => value.trim().toLowerCase())
|
||||
.filter(Boolean)
|
||||
)
|
||||
];
|
||||
|
||||
if (
|
||||
!domains.length ||
|
||||
domains.some(domain => /[\s/:?#]/.test(domain))
|
||||
) {
|
||||
result.textContent = "Vérifiez la liste des domaines.";
|
||||
return;
|
||||
}
|
||||
|
||||
const home = homeUrl.value.trim();
|
||||
|
||||
if (!/^https?:\/\//i.test(home)) {
|
||||
result.textContent =
|
||||
"L’URL de la page d’accueil doit commencer par http:// ou https://";
|
||||
return;
|
||||
}
|
||||
|
||||
await browser.storage.local.set({
|
||||
homeUrl: home,
|
||||
issuer: value,
|
||||
protectedHosts: domains,
|
||||
showNotch: showNotch.checked
|
||||
});
|
||||
|
||||
result.textContent = "Paramètres enregistrés.";
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
width: 290px;
|
||||
margin: 0;
|
||||
background: #071629;
|
||||
color: #e8f5ff;
|
||||
font: 13px/1.5 Inter, "Segoe UI", sans-serif;
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding-bottom: 14px;
|
||||
border-bottom: 1px solid #1c3b58;
|
||||
}
|
||||
|
||||
.app-icon {
|
||||
width: 38px;
|
||||
height: 38px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
header strong {
|
||||
display: block;
|
||||
letter-spacing: 0.1em;
|
||||
}
|
||||
|
||||
small {
|
||||
color: #8fa9c0;
|
||||
}
|
||||
|
||||
section {
|
||||
padding: 18px 0;
|
||||
color: #bcd3e7;
|
||||
}
|
||||
|
||||
button {
|
||||
width: 100%;
|
||||
padding: 9px;
|
||||
border: 1px solid #2f9bc9;
|
||||
border-radius: 6px;
|
||||
background: #10436a;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
a {
|
||||
display: block;
|
||||
margin-top: 14px;
|
||||
color: #38c8ff;
|
||||
text-decoration: none;
|
||||
font-size: 12px;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>SKYNET SSO</title>
|
||||
<link rel="stylesheet" href="popup.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main>
|
||||
<header>
|
||||
<img
|
||||
class="app-icon"
|
||||
src="icons/skynet.png"
|
||||
alt=""
|
||||
>
|
||||
|
||||
<div>
|
||||
<strong>SKYNET SSO</strong>
|
||||
<small>Central authentication</small>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section id="state">
|
||||
Vérification…
|
||||
</section>
|
||||
|
||||
<button id="logout" hidden>
|
||||
Déconnexion
|
||||
</button>
|
||||
|
||||
<a href="options.html" target="_blank">
|
||||
Paramètres de l’extension
|
||||
</a>
|
||||
</main>
|
||||
|
||||
<script src="popup.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,34 @@
|
||||
const stateNode = document.getElementById("state");
|
||||
const logout = document.getElementById("logout");
|
||||
|
||||
browser.runtime.sendMessage({
|
||||
type: "SSO_GET_STATE"
|
||||
}).then(state => {
|
||||
stateNode.textContent = state.status === "authenticated"
|
||||
? "Connecté : " + state.username
|
||||
: state.status === "anonymous"
|
||||
? "Aucune session active"
|
||||
: "Service SSO indisponible";
|
||||
|
||||
logout.hidden = state.status !== "authenticated";
|
||||
}).catch(() => {
|
||||
stateNode.textContent = "Impossible de joindre le service SSO";
|
||||
});
|
||||
|
||||
logout.addEventListener("click", async () => {
|
||||
logout.disabled = true;
|
||||
logout.textContent = "Déconnexion…";
|
||||
|
||||
try {
|
||||
await browser.runtime.sendMessage({
|
||||
type: "SSO_LOGOUT"
|
||||
});
|
||||
|
||||
stateNode.textContent = "Session centrale fermée";
|
||||
logout.hidden = true;
|
||||
} catch (error) {
|
||||
stateNode.textContent = error.message || "Échec de la déconnexion";
|
||||
logout.disabled = false;
|
||||
logout.textContent = "Déconnexion";
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,456 @@
|
||||
#skynet-sso-bar {
|
||||
--sky-bg: rgba(7, 18, 35, 0.97);
|
||||
--sky-line: rgba(57, 190, 255, 0.24);
|
||||
--sky-cyan: #38c8ff;
|
||||
--sky-text: #e8f5ff;
|
||||
--sky-muted: #91abc2;
|
||||
|
||||
position: fixed;
|
||||
z-index: 2147483647;
|
||||
inset: 0 0 auto 0;
|
||||
min-height: 44px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18px;
|
||||
padding: 7px 14px;
|
||||
color: var(--sky-text);
|
||||
background: linear-gradient(
|
||||
100deg,
|
||||
var(--sky-bg),
|
||||
#0b2948 65%,
|
||||
#10213b
|
||||
);
|
||||
border-bottom: 1px solid var(--sky-line);
|
||||
box-shadow: 0 5px 22px rgba(0, 0, 0, 0.22);
|
||||
font: 12px/1.4 Inter, "Segoe UI", sans-serif;
|
||||
transition: transform 0.38s cubic-bezier(0.22, 0.8, 0.25, 1);
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
#skynet-sso-bar * {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#skynet-sso-bar[data-collapsed="true"] {
|
||||
transform: translateY(calc(-100% + 1px));
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-brand {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 9px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.12em;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-brand b {
|
||||
color: var(--sky-cyan);
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-mark {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: var(--sky-muted);
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-status i {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
background: #71869a;
|
||||
}
|
||||
|
||||
#skynet-sso-bar[data-state="authenticated"] .skynet-sso-status i {
|
||||
background: #35d69a !important;
|
||||
box-shadow: 0 0 9px #35d69a;
|
||||
}
|
||||
|
||||
#skynet-sso-bar[data-state="unavailable"] .skynet-sso-status i {
|
||||
background: #ffb454;
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-user {
|
||||
color: #c9eaff;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-logout {
|
||||
padding: 6px 11px;
|
||||
border: 1px solid rgba(56, 200, 255, 0.55);
|
||||
border-radius: 6px;
|
||||
background: rgba(14, 75, 112, 0.55);
|
||||
color: #eaf8ff;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-logout:hover {
|
||||
background: #12517a;
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-logout:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-collapse {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
flex: 0 0 28px;
|
||||
padding: 0;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 50%;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s ease, border-color 0.2s ease;
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-collapse span,
|
||||
#skynet-sso-bar .skynet-sso-tab span {
|
||||
display: block;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-right: 1.5px solid var(--sky-cyan);
|
||||
border-bottom: 1.5px solid var(--sky-cyan);
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-collapse span {
|
||||
transform: translateY(2px) rotate(225deg);
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-collapse:hover {
|
||||
background: rgba(56, 200, 255, 0.1);
|
||||
border-color: rgba(56, 200, 255, 0.22);
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-tab {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
bottom: -13px;
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 42px;
|
||||
height: 14px;
|
||||
padding: 0 0 3px;
|
||||
transform: translateX(-50%);
|
||||
border: 1px solid rgba(56, 200, 255, 0.25);
|
||||
border-top: 0;
|
||||
border-radius: 0 0 8px 8px;
|
||||
background: rgba(11, 41, 72, 0.96);
|
||||
box-shadow: 0 3px 10px rgba(0, 0, 0, 0.16);
|
||||
cursor: pointer;
|
||||
transition: background 0.2s ease, height 0.2s ease;
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-tab span {
|
||||
transform: translateY(-2px) rotate(45deg);
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-tab:hover {
|
||||
height: 17px;
|
||||
background: #103656;
|
||||
border-color: rgba(56, 200, 255, 0.5);
|
||||
}
|
||||
|
||||
#skynet-sso-bar[data-collapsed="true"][data-show-notch="true"] .skynet-sso-tab {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#skynet-sso-bar[data-collapsed="true"] .skynet-sso-collapse {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#skynet-sso-bar[data-collapsed="true"][data-show-notch="false"] {
|
||||
transform: translateY(-100%);
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
#skynet-sso-bar {
|
||||
gap: 10px;
|
||||
padding: 6px 9px;
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-brand {
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-status {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-actions {
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
#skynet-sso-bar .skynet-sso-logout {
|
||||
padding: 5px 7px;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Confirmation de déconnexion */
|
||||
#skynet-sso-dialog {
|
||||
--sky-dialog-bg: #08182b;
|
||||
--sky-dialog-line: rgba(76, 190, 245, 0.2);
|
||||
--sky-dialog-cyan: #54d2ff;
|
||||
--sky-dialog-text: #edf8ff;
|
||||
--sky-dialog-muted: #9bb2c8;
|
||||
|
||||
position: fixed;
|
||||
z-index: 2147483647;
|
||||
inset: 0;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 24px;
|
||||
color: var(--sky-dialog-text);
|
||||
font: 14px/1.55 Inter, "Segoe UI", sans-serif;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.24s ease, visibility 0.24s ease;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog[data-open="true"] {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog *,
|
||||
#skynet-sso-dialog *::before,
|
||||
#skynet-sso-dialog *::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-backdrop {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(2, 9, 19, 0.7);
|
||||
-webkit-backdrop-filter: blur(7px);
|
||||
backdrop-filter: blur(7px);
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-panel {
|
||||
position: relative;
|
||||
width: min(100%, 420px);
|
||||
padding: 34px 34px 28px;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
background:
|
||||
radial-gradient(ellipse at 50% -20%, rgba(40, 155, 220, 0.2), transparent 62%),
|
||||
linear-gradient(145deg, #0c2139, var(--sky-dialog-bg) 72%);
|
||||
border: 1px solid var(--sky-dialog-line);
|
||||
border-radius: 18px;
|
||||
box-shadow:
|
||||
0 28px 90px rgba(0, 0, 0, 0.48),
|
||||
inset 0 1px rgba(255, 255, 255, 0.045);
|
||||
transform: translateY(12px) scale(0.985);
|
||||
transition: transform 0.28s cubic-bezier(0.2, 0.75, 0.25, 1);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog[data-open="true"] .skynet-sso-dialog-panel {
|
||||
transform: translateY(0) scale(1);
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-symbol {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 52px;
|
||||
height: 52px;
|
||||
margin: 0 auto 18px;
|
||||
border: 1px solid rgba(84, 210, 255, 0.28);
|
||||
border-radius: 16px;
|
||||
background: rgba(40, 155, 220, 0.1);
|
||||
box-shadow: 0 0 28px rgba(40, 155, 220, 0.1);
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-symbol span {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
border: 1.7px solid var(--sky-dialog-cyan);
|
||||
border-radius: 50%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-symbol span::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
right: -4px;
|
||||
bottom: -2px;
|
||||
border-right: 1.7px solid var(--sky-dialog-cyan);
|
||||
border-bottom: 1.7px solid var(--sky-dialog-cyan);
|
||||
background: #0b1c30;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-eyebrow {
|
||||
margin: 0 0 8px;
|
||||
color: var(--sky-dialog-cyan);
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.2em;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog h2 {
|
||||
margin: 0;
|
||||
color: var(--sky-dialog-text);
|
||||
font-size: 21px;
|
||||
font-weight: 650;
|
||||
letter-spacing: -0.025em;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog #skynet-sso-dialog-description {
|
||||
max-width: 310px;
|
||||
margin: 12px auto 0;
|
||||
color: var(--sky-dialog-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-actions {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
margin-top: 27px;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-actions button {
|
||||
min-height: 40px;
|
||||
padding: 0 16px;
|
||||
border-radius: 9px;
|
||||
font: inherit;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-cancel {
|
||||
color: #c2d2e1;
|
||||
border: 1px solid rgba(158, 188, 215, 0.18);
|
||||
background: rgba(255, 255, 255, 0.035);
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-cancel:hover:not(:disabled) {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-color: rgba(158, 188, 215, 0.32);
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-confirm {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 13px;
|
||||
color: #041523;
|
||||
border: 1px solid #69d7ff;
|
||||
background: linear-gradient(115deg, #72ddff, #35b8ee);
|
||||
box-shadow: 0 5px 18px rgba(45, 174, 230, 0.2);
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-confirm:hover:not(:disabled) {
|
||||
transform: translateY(-1px);
|
||||
background: linear-gradient(115deg, #9ae8ff, #53c8f5);
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-confirm:disabled,
|
||||
#skynet-sso-dialog .skynet-sso-dialog-cancel:disabled {
|
||||
opacity: 0.55;
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-arrow {
|
||||
font-size: 15px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-progress {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 11px;
|
||||
margin-top: 23px;
|
||||
color: #c4eaff;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-progress[hidden],
|
||||
#skynet-sso-dialog [hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-spinner {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
flex: 0 0 17px;
|
||||
border: 2px solid rgba(84, 210, 255, 0.2);
|
||||
border-top-color: var(--sky-dialog-cyan);
|
||||
border-radius: 50%;
|
||||
animation: skynet-sso-spin 0.75s linear infinite;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-error {
|
||||
margin: 16px 0 0;
|
||||
color: #ff9c9c;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@keyframes skynet-sso-spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
#skynet-sso-dialog {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-panel {
|
||||
padding: 29px 22px 23px;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-actions {
|
||||
flex-direction: column-reverse;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-dialog-actions button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
#skynet-sso-dialog,
|
||||
#skynet-sso-dialog .skynet-sso-dialog-panel,
|
||||
#skynet-sso-dialog .skynet-sso-dialog-actions button {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
#skynet-sso-dialog .skynet-sso-spinner {
|
||||
animation-duration: 1.8s;
|
||||
}
|
||||
}
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur