mirror of
https://github.com/koush/scrypted.git
synced 2026-02-17 12:12:16 +00:00
core: support custom and relative path redirect uri for oauth clients
This commit is contained in:
4
plugins/core/package-lock.json
generated
4
plugins/core/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/core",
|
||||
"version": "0.1.27",
|
||||
"version": "0.1.28",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/core",
|
||||
"version": "0.1.27",
|
||||
"version": "0.1.28",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@scrypted/common": "file:../../common",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@scrypted/core",
|
||||
"version": "0.1.27",
|
||||
"version": "0.1.28",
|
||||
"description": "Scrypted Core plugin. Provides the UI, websocket, and engine.io APIs.",
|
||||
"author": "Scrypted",
|
||||
"license": "Apache-2.0",
|
||||
|
||||
@@ -8,14 +8,32 @@ import qs from 'query-string';
|
||||
export default {
|
||||
mixins: [RPCInterface],
|
||||
methods: {
|
||||
onChange() {},
|
||||
onClick: function() {
|
||||
onChange() { },
|
||||
onClick: function () {
|
||||
this.rpc()
|
||||
.getOauthUrl()
|
||||
.then(data => {
|
||||
var url = new URL(data);
|
||||
var querystring = qs.parse(url.search.replace("?", ""));
|
||||
querystring.redirect_uri = `https://home.scrypted.app/web/oauth/callback`;
|
||||
let { redirect_uri } = querystring;
|
||||
if (redirect_uri) {
|
||||
let u;
|
||||
try {
|
||||
u = new URL(redirect_uri);
|
||||
}
|
||||
catch (e) {
|
||||
u = new URL(redirect_uri, window.location.href);
|
||||
u.hostname = 'localhost';
|
||||
}
|
||||
if (u.hostname === 'localhost') {
|
||||
u.hostname = new URL(window.location.href).hostname;
|
||||
redirect_uri = u.toString();
|
||||
}
|
||||
}
|
||||
else {
|
||||
redirect_uri = `https://home.scrypted.app/web/oauth/callback`;
|
||||
}
|
||||
querystring.redirect_uri = redirect_uri;
|
||||
querystring.state = JSON.stringify({
|
||||
d: this.device.id,
|
||||
s: querystring.state,
|
||||
|
||||
Reference in New Issue
Block a user