Skip to content

Commit

Permalink
core: escape iframe for logins
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed May 9, 2023
1 parent 1857aca commit 05b9b49
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion plugins/core/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"scrypted.debugHost": "127.0.0.1",
"scrypted.debugHost": "192.168.2.53",
}
4 changes: 2 additions & 2 deletions plugins/core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugins/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scrypted/core",
"version": "0.1.126",
"version": "0.1.127",
"description": "Scrypted Core plugin. Provides the UI, websocket, and engine.io APIs.",
"author": "Scrypted",
"license": "Apache-2.0",
Expand Down
21 changes: 14 additions & 7 deletions plugins/core/ui/src/interfaces/OauthClient.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<script>
import qs from 'query-string';
import RPCInterface from "./RPCInterface.vue";
import { getCurrentBaseUrl } from '../../../../../packages/client/src';
export default {
mixins: [RPCInterface],
Expand All @@ -16,9 +17,18 @@ export default {
return true;
}
},
onClick: function () {
// https://stackoverflow.com/a/39387533
const windowReference = this.isIFrame() ? window.open(undefined, '_blank') : undefined;
onClick: async function () {
// must escape iframe for login.
if (this.isIFrame()) {
const endpointManager = this.$scrypted.endpointManager;
const ep = await endpointManager.getPublicLocalEndpoint();
const u = new URL(ep);
u.hash = window.location.hash;
u.pathname = '/endpoint/@scrypted/core/public/';
window.open(u.toString(), '_blank');
return;
}
this.rpc()
.getOauthUrl()
.then(data => {
Expand Down Expand Up @@ -51,10 +61,7 @@ export default {
r: window.location.toString(),
});
url.search = qs.stringify(querystring);
if (windowReference)
windowReference.location = url.toString();
else
window.location = url.toString();
window.location = url.toString();
});
}
}
Expand Down

0 comments on commit 05b9b49

Please sign in to comment.