From edeac80ee731ccab9e258bae1418617d8f08def3 Mon Sep 17 00:00:00 2001 From: hunterlong Date: Thu, 17 Sep 2020 12:42:54 -0700 Subject: [PATCH] frontend change, oauth fixes --- CHANGELOG.md | 3 ++ dev/kubernetes.yml | 42 +++++++++++++++ frontend/src/API.js | 4 ++ frontend/src/assets/scss/layout.scss | 4 -- frontend/src/components/Dashboard/Configs.vue | 53 +++++++++++++++++++ .../src/components/Dashboard/Importer.vue | 52 +++++++++++++----- frontend/src/forms/Login.vue | 22 ++++++-- frontend/src/forms/OAuth.vue | 28 +++++++--- frontend/src/languages/data.csv | 1 + frontend/src/pages/Settings.vue | 27 +++++++--- go.mod | 4 +- go.sum | 6 +++ handlers/dashboard.go | 13 +++++ handlers/oauth_custom.go | 2 - handlers/routes.go | 2 + notifiers/discord.go | 2 +- notifiers/slack.go | 2 +- types/configs/methods.go | 9 ++++ types/core/struct.go | 37 ++++++------- 19 files changed, 254 insertions(+), 59 deletions(-) create mode 100644 dev/kubernetes.yml create mode 100644 frontend/src/components/Dashboard/Configs.vue diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ec00745..b61565f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # 0.90.68 (09-15-2020) - Added DB_DSN env for mysql, postgres or sqlite DSN database connection string - Added READ_ONLY env for a read only connection to the database +- Added Custom OAuth OpenID toggle switch in settings (appends 'openid' in scope) +- Fixed Custom OAuth response_type issue +- Added Configs tab in Settings to edit the config.yml from frontend # 0.90.67 (09-14-2020) - Modified core settings to update config.yml on save diff --git a/dev/kubernetes.yml b/dev/kubernetes.yml new file mode 100644 index 00000000..15033baa --- /dev/null +++ b/dev/kubernetes.yml @@ -0,0 +1,42 @@ +apiVersion: v1 +kind: Service +metadata: + name: statping +spec: + ports: + - port: 8080 + selector: + app: statping + clusterIP: None +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: statping +spec: + selector: + matchLabels: + app: statping + strategy: + type: Recreate + template: + metadata: + labels: + app: statping + spec: + containers: + - image: statping/statping + name: statping + env: + - name: ALLOW_REPORTS + value: "true" + ports: + - containerPort: 8080 + name: statping + volumeMounts: + - name: statping-storage + mountPath: /app + volumes: + - name: statping-storage + persistentVolumeClaim: + claimName: statping-claim diff --git a/frontend/src/API.js b/frontend/src/API.js index e027fcb4..0f0aff89 100644 --- a/frontend/src/API.js +++ b/frontend/src/API.js @@ -261,6 +261,10 @@ class Api { }) } + async configs() { + return axios.get('api/settings/configs').then(response => (response.data)) || [] + } + token() { return $cookies.get(tokenKey); } diff --git a/frontend/src/assets/scss/layout.scss b/frontend/src/assets/scss/layout.scss index acb16334..59b82352 100644 --- a/frontend/src/assets/scss/layout.scss +++ b/frontend/src/assets/scss/layout.scss @@ -10,10 +10,6 @@ A { color: $text-color; } -A:HOVER { - color: lighten($text-color, 12%) !important; -} - .modal-backdrop { position: absolute; top: 0; diff --git a/frontend/src/components/Dashboard/Configs.vue b/frontend/src/components/Dashboard/Configs.vue new file mode 100644 index 00000000..9e0dca5a --- /dev/null +++ b/frontend/src/components/Dashboard/Configs.vue @@ -0,0 +1,53 @@ + + + + + diff --git a/frontend/src/components/Dashboard/Importer.vue b/frontend/src/components/Dashboard/Importer.vue index 0f65c056..c131806b 100644 --- a/frontend/src/components/Dashboard/Importer.vue +++ b/frontend/src/components/Dashboard/Importer.vue @@ -6,14 +6,16 @@

-
- +
+
- Export +
+ Export +
-
+

Core Settings @@ -21,13 +23,13 @@

-
Name{{file.core.name}}
-
Description{{file.core.description}}
-
Domain{{file.core.domain}}
+
Name{{file.core.name}}
+
Description{{file.core.description}}
+
Domain{{file.core.domain}}
-
+

Users

@@ -51,7 +53,7 @@
-
+

Checkins

@@ -60,10 +62,10 @@
- {{checkin.id}} + {{checkin.name}}
- {{checkin.service_id}} + Service #{{checkin.service_id}}
@@ -74,7 +76,7 @@
-
+

Services

@@ -97,7 +99,7 @@
-
+

Groups

@@ -117,6 +119,26 @@
+
+

Incidents + +

+ +
+
+ {{incident.name}} +
+
+ + + + +
+
+
+

Notifiers @@ -141,7 +163,9 @@ {{error}}

- +
+ +
diff --git a/frontend/src/forms/Login.vue b/frontend/src/forms/Login.vue index 64ce8cf6..b84c2d68 100644 --- a/frontend/src/forms/Login.vue +++ b/frontend/src/forms/Login.vue @@ -95,17 +95,31 @@ } this.loading = false }, + encode(val) { + return encodeURI(val) + }, + custom_scopes() { + let scopes = [] + if (this.oauth.custom_open_id) { + scopes.push("openid") + } + scopes.push(this.oauth.custom_scopes.split(",")) + if (scopes.length !== 0) { + return "&scopes="+scopes.join(",") + } + return "" + }, GHlogin() { - window.location = `https://github.com/login/oauth/authorize?client_id=${this.oauth.gh_client_id}&redirect_uri=${this.core.domain}/oauth/github&scope=user,repo` + window.location = `https://github.com/login/oauth/authorize?client_id=${this.oauth.gh_client_id}&redirect_uri=${this.encode(this.core.domain+"/oauth/github")}&scope=user,repo` }, Slacklogin() { - window.location = `https://slack.com/oauth/authorize?client_id=${this.oauth.slack_client_id}&redirect_uri=${this.core.domain}/oauth/slack&scope=identity.basic` + window.location = `https://slack.com/oauth/authorize?client_id=${this.oauth.slack_client_id}&redirect_uri=${this.encode(this.core.domain+"/oauth/slack")}&scope=identity.basic` }, Googlelogin() { - window.location = `https://accounts.google.com/signin/oauth?client_id=${this.oauth.google_client_id}&redirect_uri=${this.core.domain}/oauth/google&response_type=code&scope=https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/userinfo.email` + window.location = `https://accounts.google.com/signin/oauth?client_id=${this.oauth.google_client_id}&redirect_uri=${this.encode(this.core.domain+"/oauth/google")}&response_type=code&scope=https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/userinfo.email` }, Customlogin() { - window.location = `${this.oauth.custom_endpoint_auth}?client_id=${this.oauth.custom_client_id}&redirect_uri=${this.core.domain}/oauth/custom${this.oauth.custom_scopes !== "" ? "&scope="+this.oauth.custom_scopes : "" }` + window.location = `${this.oauth.custom_endpoint_auth}?client_id=${this.oauth.custom_client_id}&redirect_uri=${this.encode(this.core.domain+"/oauth/custom")}&response_type=code${this.custom_scopes()}` } } } diff --git a/frontend/src/forms/OAuth.vue b/frontend/src/forms/OAuth.vue index 4bc385a6..646429a8 100644 --- a/frontend/src/forms/OAuth.vue +++ b/frontend/src/forms/OAuth.vue @@ -168,8 +168,8 @@
-
-
+
+
@@ -199,13 +199,24 @@
-
- -
- - Optional comma delimited list of oauth scopes -
+
+ +
+ + Optional comma delimited list of oauth scopes
+
+
+ +
+ + + + + Enable if provider is OpenID +
+
+
@@ -271,6 +282,7 @@ custom_endpoint_auth: "", custom_endpoint_token: "", custom_scopes: "", + custom_open_id: false, } } }, diff --git a/frontend/src/languages/data.csv b/frontend/src/languages/data.csv index 60d8250f..cc8aa51b 100644 --- a/frontend/src/languages/data.csv +++ b/frontend/src/languages/data.csv @@ -9,6 +9,7 @@ login,Login logout,Logout online,Online offline,Offline +configs,Configuration username,Username password,Password email,Email diff --git a/frontend/src/pages/Settings.vue b/frontend/src/pages/Settings.vue index ae8331a3..9235a548 100644 --- a/frontend/src/pages/Settings.vue +++ b/frontend/src/pages/Settings.vue @@ -4,10 +4,16 @@