Optimized the process for obtaining user sessions for SPA and comcipapic
This commit is contained in:
6
dist/chromium/background.js
vendored
6
dist/chromium/background.js
vendored
@@ -757,8 +757,8 @@ function createAuthConsumerSession({
|
|||||||
if (restarted) restartedDocument = documentId;
|
if (restarted) restartedDocument = documentId;
|
||||||
}
|
}
|
||||||
} else if (page?.status === "ready" && documentId) {
|
} else if (page?.status === "ready" && documentId) {
|
||||||
// Confirm a stable, fully loaded document, not a transient SAML page.
|
// Confirm the parsed application document without waiting for visual assets.
|
||||||
await wait(500);
|
await wait(100);
|
||||||
let confirmed;
|
let confirmed;
|
||||||
try { confirmed = await inspectPage(tab); } catch { /* A redirect started during validation. */ }
|
try { confirmed = await inspectPage(tab); } catch { /* A redirect started during validation. */ }
|
||||||
if (confirmed?.status === "ready" && confirmed.documentId === documentId && !state?.failedStatus) {
|
if (confirmed?.status === "ready" && confirmed.documentId === documentId && !state?.failedStatus) {
|
||||||
@@ -1553,7 +1553,7 @@ function createFusionSrDetails({ fetchJson, tabsCreate, tabsRemove, supportsFire
|
|||||||
let session = sessions.get(key);
|
let session = sessions.get(key);
|
||||||
if (!session) {
|
if (!session) {
|
||||||
const details = {
|
const details = {
|
||||||
url: "https://comcipapic-oalprod.integration.ocp.oraclecloud.com/ic/builder/rt/oalset_semc/live/webApps/Dashboard/?page=shell&shell=main&main=manageresourcerequests",
|
url: "https://comcipapic-oalprod.integration.ocp.oraclecloud.com/ic/builder/rt/SeaaS_initiation/live/webApps/external/",
|
||||||
active: false
|
active: false
|
||||||
};
|
};
|
||||||
if (Number.isInteger(sender?.tab?.windowId)) details.windowId = sender.tab.windowId;
|
if (Number.isInteger(sender?.tab?.windowId)) details.windowId = sender.tab.windowId;
|
||||||
|
|||||||
2
dist/chromium/manifest.json
vendored
2
dist/chromium/manifest.json
vendored
@@ -34,7 +34,7 @@
|
|||||||
"spa-page.js"
|
"spa-page.js"
|
||||||
],
|
],
|
||||||
"all_frames": false,
|
"all_frames": false,
|
||||||
"run_at": "document_idle"
|
"run_at": "document_end"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"background": {
|
"background": {
|
||||||
|
|||||||
2
dist/chromium/spa-page.js
vendored
2
dist/chromium/spa-page.js
vendored
@@ -16,7 +16,7 @@ function createSpaPage() {
|
|||||||
else if (/^\/(?:cloudgate|login|signin|sso|oauth)(?:\/|$)/i.test(location.pathname)
|
else if (/^\/(?:cloudgate|login|signin|sso|oauth)(?:\/|$)/i.test(location.pathname)
|
||||||
|| /\b(?:sign(?:ing)? in|log in|single sign.on|oracle access manager)\b/i.test(document.title)
|
|| /\b(?:sign(?:ing)? in|log in|single sign.on|oracle access manager)\b/i.test(document.title)
|
||||||
|| document.querySelector('input[name="SAMLResponse"], input[name="SAMLRequest"], input[type="password"], form[action*="/sso"], form[action*="/login"], meta[http-equiv="refresh" i]')) status = "login";
|
|| document.querySelector('input[name="SAMLResponse"], input[name="SAMLRequest"], input[type="password"], form[action*="/sso"], form[action*="/login"], meta[http-equiv="refresh" i]')) status = "login";
|
||||||
else if (document.readyState === "complete" && text
|
else if ((document.readyState === "interactive" || document.readyState === "complete") && text
|
||||||
&& document.querySelector('a[href], button, input, [role="main"], main, nav')) status = "ready";
|
&& document.querySelector('a[href], button, input, [role="main"], main, nav')) status = "ready";
|
||||||
return { status, documentId };
|
return { status, documentId };
|
||||||
}
|
}
|
||||||
|
|||||||
6
dist/firefox/background.js
vendored
6
dist/firefox/background.js
vendored
@@ -757,8 +757,8 @@ function createAuthConsumerSession({
|
|||||||
if (restarted) restartedDocument = documentId;
|
if (restarted) restartedDocument = documentId;
|
||||||
}
|
}
|
||||||
} else if (page?.status === "ready" && documentId) {
|
} else if (page?.status === "ready" && documentId) {
|
||||||
// Confirm a stable, fully loaded document, not a transient SAML page.
|
// Confirm the parsed application document without waiting for visual assets.
|
||||||
await wait(500);
|
await wait(100);
|
||||||
let confirmed;
|
let confirmed;
|
||||||
try { confirmed = await inspectPage(tab); } catch { /* A redirect started during validation. */ }
|
try { confirmed = await inspectPage(tab); } catch { /* A redirect started during validation. */ }
|
||||||
if (confirmed?.status === "ready" && confirmed.documentId === documentId && !state?.failedStatus) {
|
if (confirmed?.status === "ready" && confirmed.documentId === documentId && !state?.failedStatus) {
|
||||||
@@ -1553,7 +1553,7 @@ function createFusionSrDetails({ fetchJson, tabsCreate, tabsRemove, supportsFire
|
|||||||
let session = sessions.get(key);
|
let session = sessions.get(key);
|
||||||
if (!session) {
|
if (!session) {
|
||||||
const details = {
|
const details = {
|
||||||
url: "https://comcipapic-oalprod.integration.ocp.oraclecloud.com/ic/builder/rt/oalset_semc/live/webApps/Dashboard/?page=shell&shell=main&main=manageresourcerequests",
|
url: "https://comcipapic-oalprod.integration.ocp.oraclecloud.com/ic/builder/rt/SeaaS_initiation/live/webApps/external/",
|
||||||
active: false
|
active: false
|
||||||
};
|
};
|
||||||
if (Number.isInteger(sender?.tab?.windowId)) details.windowId = sender.tab.windowId;
|
if (Number.isInteger(sender?.tab?.windowId)) details.windowId = sender.tab.windowId;
|
||||||
|
|||||||
2
dist/firefox/manifest.json
vendored
2
dist/firefox/manifest.json
vendored
@@ -34,7 +34,7 @@
|
|||||||
"spa-page.js"
|
"spa-page.js"
|
||||||
],
|
],
|
||||||
"all_frames": false,
|
"all_frames": false,
|
||||||
"run_at": "document_idle"
|
"run_at": "document_end"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"background": {
|
"background": {
|
||||||
|
|||||||
2
dist/firefox/spa-page.js
vendored
2
dist/firefox/spa-page.js
vendored
@@ -16,7 +16,7 @@ function createSpaPage() {
|
|||||||
else if (/^\/(?:cloudgate|login|signin|sso|oauth)(?:\/|$)/i.test(location.pathname)
|
else if (/^\/(?:cloudgate|login|signin|sso|oauth)(?:\/|$)/i.test(location.pathname)
|
||||||
|| /\b(?:sign(?:ing)? in|log in|single sign.on|oracle access manager)\b/i.test(document.title)
|
|| /\b(?:sign(?:ing)? in|log in|single sign.on|oracle access manager)\b/i.test(document.title)
|
||||||
|| document.querySelector('input[name="SAMLResponse"], input[name="SAMLRequest"], input[type="password"], form[action*="/sso"], form[action*="/login"], meta[http-equiv="refresh" i]')) status = "login";
|
|| document.querySelector('input[name="SAMLResponse"], input[name="SAMLRequest"], input[type="password"], form[action*="/sso"], form[action*="/login"], meta[http-equiv="refresh" i]')) status = "login";
|
||||||
else if (document.readyState === "complete" && text
|
else if ((document.readyState === "interactive" || document.readyState === "complete") && text
|
||||||
&& document.querySelector('a[href], button, input, [role="main"], main, nav')) status = "ready";
|
&& document.querySelector('a[href], button, input, [role="main"], main, nav')) status = "ready";
|
||||||
return { status, documentId };
|
return { status, documentId };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const baseManifest = {
|
|||||||
matches: ["https://spa.oracle.com/*"],
|
matches: ["https://spa.oracle.com/*"],
|
||||||
js: ["spa-page.js"],
|
js: ["spa-page.js"],
|
||||||
all_frames: false,
|
all_frames: false,
|
||||||
run_at: "document_idle"
|
run_at: "document_end"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -334,8 +334,8 @@ function createAuthConsumerSession({
|
|||||||
if (restarted) restartedDocument = documentId;
|
if (restarted) restartedDocument = documentId;
|
||||||
}
|
}
|
||||||
} else if (page?.status === "ready" && documentId) {
|
} else if (page?.status === "ready" && documentId) {
|
||||||
// Confirm a stable, fully loaded document, not a transient SAML page.
|
// Confirm the parsed application document without waiting for visual assets.
|
||||||
await wait(500);
|
await wait(100);
|
||||||
let confirmed;
|
let confirmed;
|
||||||
try { confirmed = await inspectPage(tab); } catch { /* A redirect started during validation. */ }
|
try { confirmed = await inspectPage(tab); } catch { /* A redirect started during validation. */ }
|
||||||
if (confirmed?.status === "ready" && confirmed.documentId === documentId && !state?.failedStatus) {
|
if (confirmed?.status === "ready" && confirmed.documentId === documentId && !state?.failedStatus) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ function createSpaPage() {
|
|||||||
else if (/^\/(?:cloudgate|login|signin|sso|oauth)(?:\/|$)/i.test(location.pathname)
|
else if (/^\/(?:cloudgate|login|signin|sso|oauth)(?:\/|$)/i.test(location.pathname)
|
||||||
|| /\b(?:sign(?:ing)? in|log in|single sign.on|oracle access manager)\b/i.test(document.title)
|
|| /\b(?:sign(?:ing)? in|log in|single sign.on|oracle access manager)\b/i.test(document.title)
|
||||||
|| document.querySelector('input[name="SAMLResponse"], input[name="SAMLRequest"], input[type="password"], form[action*="/sso"], form[action*="/login"], meta[http-equiv="refresh" i]')) status = "login";
|
|| document.querySelector('input[name="SAMLResponse"], input[name="SAMLRequest"], input[type="password"], form[action*="/sso"], form[action*="/login"], meta[http-equiv="refresh" i]')) status = "login";
|
||||||
else if (document.readyState === "complete" && text
|
else if ((document.readyState === "interactive" || document.readyState === "complete") && text
|
||||||
&& document.querySelector('a[href], button, input, [role="main"], main, nav')) status = "ready";
|
&& document.querySelector('a[href], button, input, [role="main"], main, nav')) status = "ready";
|
||||||
return { status, documentId };
|
return { status, documentId };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ function createFusionSrDetails({ fetchJson, tabsCreate, tabsRemove, supportsFire
|
|||||||
let session = sessions.get(key);
|
let session = sessions.get(key);
|
||||||
if (!session) {
|
if (!session) {
|
||||||
const details = {
|
const details = {
|
||||||
url: "https://comcipapic-oalprod.integration.ocp.oraclecloud.com/ic/builder/rt/oalset_semc/live/webApps/Dashboard/?page=shell&shell=main&main=manageresourcerequests",
|
url: "https://comcipapic-oalprod.integration.ocp.oraclecloud.com/ic/builder/rt/SeaaS_initiation/live/webApps/external/",
|
||||||
active: false
|
active: false
|
||||||
};
|
};
|
||||||
if (Number.isInteger(sender?.tab?.windowId)) details.windowId = sender.tab.windowId;
|
if (Number.isInteger(sender?.tab?.windowId)) details.windowId = sender.tab.windowId;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ test("distribution contracts: manifests, execution boundaries and deterministic
|
|||||||
matches: ["https://eeho.fa.us2.oraclecloud.com/hcmUI/faces/FuseWelcome*", "https://eeho.fa.us2.oraclecloud.com/fscmUI/faces/FuseWelcome*"],
|
matches: ["https://eeho.fa.us2.oraclecloud.com/hcmUI/faces/FuseWelcome*", "https://eeho.fa.us2.oraclecloud.com/fscmUI/faces/FuseWelcome*"],
|
||||||
js: ["content.js"], all_frames: true, run_at: "document_idle"
|
js: ["content.js"], all_frames: true, run_at: "document_idle"
|
||||||
}, {
|
}, {
|
||||||
matches: ["https://spa.oracle.com/*"], js: ["spa-page.js"], all_frames: false, run_at: "document_idle"
|
matches: ["https://spa.oracle.com/*"], js: ["spa-page.js"], all_frames: false, run_at: "document_end"
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
for (const target of ["chromium", "firefox"]) {
|
for (const target of ["chromium", "firefox"]) {
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ test("preparation closes immediately on the second cookie event even while getAl
|
|||||||
assert.equal(listeners.size, 0);
|
assert.equal(listeners.size, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("explicit preparation opens resource requests Dashboard and observes cookies without any API requests", async () => {
|
test("explicit preparation opens SeaaS initiation and observes cookies without any API requests", async () => {
|
||||||
let calls = 0;
|
let calls = 0;
|
||||||
let reads = 0;
|
let reads = 0;
|
||||||
const domain = "comcipapic-oalprod.integration.ocp.oraclecloud.com";
|
const domain = "comcipapic-oalprod.integration.ocp.oraclecloud.com";
|
||||||
@@ -97,7 +97,7 @@ test("explicit preparation opens resource requests Dashboard and observes cookie
|
|||||||
assert.deepEqual(result.debugRequests, []);
|
assert.deepEqual(result.debugRequests, []);
|
||||||
assert.ok(!JSON.stringify(result).includes("secret"));
|
assert.ok(!JSON.stringify(result).includes("secret"));
|
||||||
assert.equal(h.tabs[0].active, false);
|
assert.equal(h.tabs[0].active, false);
|
||||||
assert.equal(h.tabs[0].url, "https://comcipapic-oalprod.integration.ocp.oraclecloud.com/ic/builder/rt/oalset_semc/live/webApps/Dashboard/?page=shell&shell=main&main=manageresourcerequests");
|
assert.equal(h.tabs[0].url, "https://comcipapic-oalprod.integration.ocp.oraclecloud.com/ic/builder/rt/SeaaS_initiation/live/webApps/external/");
|
||||||
assert.deepEqual(h.removedTabs, [91]);
|
assert.deepEqual(h.removedTabs, [91]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ for (const family of ["chrome", "firefox"]) {
|
|||||||
assert.equal(h.tabs.length, 1);
|
assert.equal(h.tabs.length, 1);
|
||||||
assert.equal(h.tabs[0].active, false);
|
assert.equal(h.tabs[0].active, false);
|
||||||
assert.equal(h.tabs[0].windowId, 3);
|
assert.equal(h.tabs[0].windowId, 3);
|
||||||
assert.equal(h.tabs[0].url, "https://comcipapic-oalprod.integration.ocp.oraclecloud.com/ic/builder/rt/oalset_semc/live/webApps/Dashboard/?page=shell&shell=main&main=manageresourcerequests");
|
assert.equal(h.tabs[0].url, "https://comcipapic-oalprod.integration.ocp.oraclecloud.com/ic/builder/rt/SeaaS_initiation/live/webApps/external/");
|
||||||
assert.equal(h.tabs[0].cookieStoreId, family === "firefox" ? "test-store" : undefined);
|
assert.equal(h.tabs[0].cookieStoreId, family === "firefox" ? "test-store" : undefined);
|
||||||
assert.deepEqual(h.removedTabs, [91]);
|
assert.deepEqual(h.removedTabs, [91]);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ test("error, SAML/login, blank and incomplete pages never authorize a fetch", as
|
|||||||
[{ loginSelector: 'input[name="SAMLRequest"]' }, "login"],
|
[{ loginSelector: 'input[name="SAMLRequest"]' }, "login"],
|
||||||
[{ loginSelector: 'input[type="password"]' }, "login"],
|
[{ loginSelector: 'input[type="password"]' }, "login"],
|
||||||
[{ loginSelector: 'meta[http-equiv="refresh" i]' }, "login"],
|
[{ loginSelector: 'meta[http-equiv="refresh" i]' }, "login"],
|
||||||
[{ readyState: "interactive" }, "loading"],
|
|
||||||
[{ readyState: "loading" }, "loading"],
|
[{ readyState: "loading" }, "loading"],
|
||||||
[{ title: "", body: "" }, "loading"],
|
[{ title: "", body: "" }, "loading"],
|
||||||
[{ controls: false }, "loading"]
|
[{ controls: false }, "loading"]
|
||||||
@@ -72,6 +71,7 @@ test("error, SAML/login, blank and incomplete pages never authorize a fetch", as
|
|||||||
for (const family of ["chrome", "browser"]) {
|
for (const family of ["chrome", "browser"]) {
|
||||||
test(`${family}: a loaded application reads identity once per document in its own authenticated context`, async () => {
|
test(`${family}: a loaded application reads identity once per document in its own authenticated context`, async () => {
|
||||||
const h = harness({ family });
|
const h = harness({ family });
|
||||||
|
h.dom.readyState = "interactive";
|
||||||
const page = await h.send(inspect);
|
const page = await h.send(inspect);
|
||||||
assert.equal(page.status, "ready");
|
assert.equal(page.status, "ready");
|
||||||
const [first, second] = await Promise.all([h.send(read, page.documentId), h.send(read, page.documentId)]);
|
const [first, second] = await Promise.all([h.send(read, page.documentId), h.send(read, page.documentId)]);
|
||||||
|
|||||||
Reference in New Issue
Block a user