From 59c209b71328da74f627e7ba19477d41352e856f Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Sat, 26 Jun 2021 23:00:27 -0500 Subject: [PATCH 1/6] update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92eae3e..8b85fc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 1.0.3 + +- OAuth merged +- Fix Grafana Cloud login +- Updated modules + ## 1.0.2 - Also compatible with Grafana v7 From f500dc65b62f5abf04c3643fc01ece1046780a9e Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Sat, 26 Jun 2021 23:39:03 -0500 Subject: [PATCH 2/6] implement window position, fix typos --- CHANGELOG.md | 1 + README.md | 118 ++++++++++++------------ pkg/cmd/grafana-kiosk/main.go | 6 +- pkg/kiosk/anonymous_login.go | 1 + pkg/kiosk/config.go | 9 +- pkg/kiosk/grafana_com_login.go | 1 + pkg/kiosk/grafana_genericoauth_login.go | 3 +- pkg/kiosk/local_login.go | 1 + 8 files changed, 77 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b85fc1..2d77477 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - OAuth merged - Fix Grafana Cloud login - Updated modules +- Add "window-position" option ## 1.0.2 diff --git a/README.md b/README.md index 858539d..6f1beec 100644 --- a/README.md +++ b/README.md @@ -9,15 +9,16 @@ This provides a utility to quickly standup a kiosk on devices like a Raspberry P The utitilty provides these options: -- login +- Login - to a Grafana server (local account) - to a Grafana server with anonymous-mode enabled (same method used on [play.grafana.org](https://play.grafana.org)) - to a Grafana Cloud instance - to a Grafana server with OAuth enabled -- switch to kiosk or kiosk-tv mode -- display the default home page set for the user -- display a specified dashboard -- start a playlist immediately (inactive mode enable) +- Switch to kiosk or kiosk-tv mode +- Display the default home page set for the user +- Display a specified dashboard +- Start a playlist immediately (inactive mode enable) +- Can specify where to start kiosk for multiple displays Additionally, an initialize option is provided to configure LXDE for Raspberry Pi Desktop. @@ -47,41 +48,42 @@ Extract the zip or tar file, and copy the appropriate binary to /usr/bin/grafana ## Usage -`--URL` - -- URL to a Grafana server - -`--playlist` - -- designates the URL as a playlist, allowing instant "inactive" user vs waiting for the timeout - -`--login-method` (default anon) - -- anon (anonymous) -- local (local user) -- gcom (Hosted Grafana) -- goauth (Open Auth) - -`--username` used with local and gcom login methods - -`--password` used with local and gcom login methods - -`--ignore-certificate-errors` used with local and anonymous login methods - -`--kiosk-mode` - -- full (no sidebar, top navigation disabled) -- tv (no sidebar, top navigation enabled) -- disabled (sidebar and top navigation enabled) - -`--autofit` scales panels to fit the display (default is true) - -- true -- false - -`--lxde` enables initialization of LXDE - -`--lxde-home` specifies home directory of LXDE user (default $HOME) +```TEXT + -URL string + URL to Grafana server (default "https://play.grafana.org") + -auto-login + oauth_auto_login is enabled in grafana config + -autofit + Fit panels to screen (default true) + -c string + Path to configuration file (config.yaml) + -field-password string + Fieldname for the password (default "password") + -field-username string + Fieldname for the username (default "username") + -ignore-certificate-errors + Ignore SSL/TLS certificate error + -kiosk-mode string + Kiosk Display Mode [full|tv|disabled] + full = No TOPNAV and No SIDEBAR + tv = No SIDEBAR + disabled = omit option + (default "full") + -login-method string + [anon|local|gcom|goauth] (default "anon") + -lxde + Initialize LXDE for kiosk mode + -lxde-home string + Path to home directory of LXDE user running X Server (default "/home/pi") + -password string + password (default "guest") + -playlists + URL is a playlist + -username string + username (default "guest") + -window-position string + Top Left Position of Kiosk (default "0,0") +``` ### Using a configuration file @@ -99,7 +101,7 @@ target: login-method: anon username: user password: changeme - playlist: false + playlists: false URL: https://play.grafana.org ignore-certificate-errors: false ``` @@ -113,31 +115,33 @@ They can also be used instead of a configuration file. ```TEXT KIOSK_AUTOFIT bool - fit panels to screen (default "true") + fit panels to screen (default "true") KIOSK_LXDE_ENABLED bool - initialize LXDE for kiosk mode (default "false") - KIOSK_MODE string - path to home directory of LXDE user running X Server (default "/home/pi") + initialize LXDE for kiosk mode (default "false") + KIOSK_LXDE_HOME string + path to home directory of LXDE user running X Server (default "/home/pi") KIOSK_MODE string - [full|tv|disabled] (default "full") + [full|tv|disabled] (default "full") + KIOSK_WINDOW_POSITION string + Top Left Position of Kiosk (default "0,0") KIOSK_IGNORE_CERTIFICATE_ERRORS bool - ignore SSL/TLS certificate errors (default "false") + ignore SSL/TLS certificate errors (default "false") KIOSK_IS_PLAYLIST bool - URL is a playlist (default "false") + URL is a playlist (default "false") KIOSK_LOGIN_METHOD string - [anon|local|gcom] (default "anon") + [anon|local|gcom|goauth] (default "anon") KIOSK_LOGIN_PASSWORD string - password (default "guest") + password (default "guest") KIOSK_URL string - URL to Grafana server (default "https://play.grafana.org") + URL to Grafana server (default "https://play.grafana.org") KIOSK_LOGIN_USER string - username (default "guest") + username (default "guest") KIOSK_GOAUTH_AUTO_LOGIN bool - IF oauth_auto_login setting is set to true or false in grafana config (default "false") + [false|true] KIOSK_GOAUTH_FIELD_USER string - HTML input fieldname value for username of your generic oauth provider (default "test") + Username html input name value KIOSK_GOAUTH_FIELD_PASSWORD string - HTML input fieldname value for the password of your generic oauth provider (default "test") + Password html input name value ``` ### Hosted Grafana using grafana.com authentication @@ -157,7 +161,7 @@ This will login to a Hosted Grafana instance and take the browser to a specific This will login to a Hosted Grafana instance and take the browser to a playlist in fullscreen kiosk mode, and autofit the panels to fill the display. ```bash -./bin/grafana-kiosk --URL https://bkgann3.grafana.net/playlists/play/1 --login-method gcom --username bkgann --password abc123 --kiosk-mode full --playlist --autofit +./bin/grafana-kiosk --URL https://bkgann3.grafana.net/playlists/play/1 --login-method gcom --username bkgann --password abc123 --kiosk-mode full --playlists --autofit ``` ### Grafana Server with Local Accounts @@ -281,7 +285,7 @@ After=network.target User=pi Environment="DISPLAY=:0" Environment="XAUTHORITY=/home/pi/.Xauthority" -ExecStart=/usr/bin/grafana-kiosk --URL -login-method local -username -password -playlist true +ExecStart=/usr/bin/grafana-kiosk --URL -login-method local -username -password -playlists true [Install] WantedBy=graphical.target diff --git a/pkg/cmd/grafana-kiosk/main.go b/pkg/cmd/grafana-kiosk/main.go index ab9156a..c6f62ba 100644 --- a/pkg/cmd/grafana-kiosk/main.go +++ b/pkg/cmd/grafana-kiosk/main.go @@ -29,6 +29,7 @@ type Args struct { Password string UsernameField string PasswordField string + WindowPosition string } // ProcessArgs processes and handles CLI arguments @@ -42,12 +43,13 @@ func ProcessArgs(cfg interface{}) Args { f.StringVar(&a.Password, "password", "guest", "password") f.StringVar(&a.Mode, "kiosk-mode", "full", "Kiosk Display Mode [full|tv|disabled]\nfull = No TOPNAV and No SIDEBAR\ntv = No SIDEBAR\ndisabled = omit option\n") f.StringVar(&a.URL, "URL", "https://play.grafana.org", "URL to Grafana server") + f.StringVar(&a.WindowPosition, "window-position", "0,0", "Top Left Position of Kiosk") f.BoolVar(&a.IsPlayList, "playlists", false, "URL is a playlist") f.BoolVar(&a.AutoFit, "autofit", true, "Fit panels to screen") f.BoolVar(&a.LXDEEnabled, "lxde", false, "Initialize LXDE for kiosk mode") f.StringVar(&a.LXDEHome, "lxde-home", "/home/pi", "Path to home directory of LXDE user running X Server") f.BoolVar(&a.IgnoreCertificateErrors, "ignore-certificate-errors", false, "Ignore SSL/TLS certificate error") - f.BoolVar(&a.OauthAutoLogin, "auto-login", false, "oauth_auto_login is enabeld in grafana config") + f.BoolVar(&a.OauthAutoLogin, "auto-login", false, "oauth_auto_login is enabled in grafana config") f.StringVar(&a.UsernameField, "field-username", "username", "Fieldname for the username") f.StringVar(&a.PasswordField, "field-password", "password", "Fieldname for the password") @@ -93,6 +95,7 @@ func summary(cfg *kiosk.Config) { log.Println("LXDEEnabled:", cfg.General.LXDEEnabled) log.Println("LXDEHome:", cfg.General.LXDEHome) log.Println("Mode:", cfg.General.Mode) + log.Println("WindowPosition:", cfg.General.WindowPosition) // target log.Println("URL:", cfg.Target.URL) log.Println("LoginMethod:", cfg.Target.LoginMethod) @@ -136,6 +139,7 @@ func main() { cfg.General.LXDEEnabled = args.LXDEEnabled cfg.General.LXDEHome = args.LXDEHome cfg.General.Mode = args.Mode + cfg.General.WindowPosition = args.WindowPosition // cfg.GOAUTH.AutoLogin = args.OauthAutoLogin cfg.GOAUTH.UsernameField = args.UsernameField diff --git a/pkg/kiosk/anonymous_login.go b/pkg/kiosk/anonymous_login.go index 2fe5c54..d504c70 100644 --- a/pkg/kiosk/anonymous_login.go +++ b/pkg/kiosk/anonymous_login.go @@ -31,6 +31,7 @@ func GrafanaKioskAnonymous(cfg *Config) { chromedp.Flag("disable-overlay-scrollbar", true), chromedp.Flag("ignore-certificate-errors", cfg.Target.IgnoreCertificateErrors), chromedp.Flag("test-type", cfg.Target.IgnoreCertificateErrors), + chromedp.Flag("window-position", cfg.General.WindowPosition), chromedp.UserDataDir(dir), } diff --git a/pkg/kiosk/config.go b/pkg/kiosk/config.go index 2c1134e..fa461a7 100644 --- a/pkg/kiosk/config.go +++ b/pkg/kiosk/config.go @@ -3,10 +3,11 @@ package kiosk // Config configuration for backend type Config struct { General struct { - AutoFit bool `yaml:"autofit" env:"KIOSK_AUTOFIT" env-default:"true" env-description:"fit panels to screen"` - LXDEEnabled bool `yaml:"lxde" env:"KIOSK_LXDE_ENABLED" env-default:"false" env-description:"initialize LXDE for kiosk mode"` - LXDEHome string `yaml:"lxde-home" env:"KIOSK_MODE" env-default:"/home/pi" env-description:"path to home directory of LXDE user running X Server"` - Mode string `yaml:"kiosk-mode" env:"KIOSK_MODE" env-default:"full" env-description:"[full|tv|disabled]"` + AutoFit bool `yaml:"autofit" env:"KIOSK_AUTOFIT" env-default:"true" env-description:"fit panels to screen"` + LXDEEnabled bool `yaml:"lxde" env:"KIOSK_LXDE_ENABLED" env-default:"false" env-description:"initialize LXDE for kiosk mode"` + LXDEHome string `yaml:"lxde-home" env:"KIOSK_LXDE_HOME" env-default:"/home/pi" env-description:"path to home directory of LXDE user running X Server"` + Mode string `yaml:"kiosk-mode" env:"KIOSK_MODE" env-default:"full" env-description:"[full|tv|disabled]"` + WindowPosition string `yaml:"window-position" env:"KIOSK_WINDOW_POSITION" env-default:"0,0" env-description:"Top Left Position of Kiosk"` } `yaml:"general"` Target struct { IgnoreCertificateErrors bool `yaml:"ignore-certificate-errors" env:"KIOSK_IGNORE_CERTIFICATE_ERRORS" env-description:"ignore SSL/TLS certificate errors" env-default:"false"` diff --git a/pkg/kiosk/grafana_com_login.go b/pkg/kiosk/grafana_com_login.go index 61e3478..f924c85 100644 --- a/pkg/kiosk/grafana_com_login.go +++ b/pkg/kiosk/grafana_com_login.go @@ -30,6 +30,7 @@ func GrafanaKioskGCOM(cfg *Config) { chromedp.Flag("disable-sync", true), chromedp.Flag("disable-notifications", true), chromedp.Flag("disable-overlay-scrollbar", true), + chromedp.Flag("window-position", cfg.General.WindowPosition), chromedp.UserDataDir(dir), } diff --git a/pkg/kiosk/grafana_genericoauth_login.go b/pkg/kiosk/grafana_genericoauth_login.go index 46e846e..8312b79 100644 --- a/pkg/kiosk/grafana_genericoauth_login.go +++ b/pkg/kiosk/grafana_genericoauth_login.go @@ -30,6 +30,7 @@ func GrafanaKioskGenericOauth(cfg *Config) { chromedp.Flag("disable-sync", true), chromedp.Flag("disable-notifications", true), chromedp.Flag("disable-overlay-scrollbar", true), + chromedp.Flag("window-position", cfg.General.WindowPosition), chromedp.UserDataDir(dir), } @@ -56,7 +57,7 @@ func GrafanaKioskGenericOauth(cfg *Config) { // XPATH of grafana.com for Generic OAUTH login button = //*[@href="login/grafana_com"]/i // Click the OAUTH login button - log.Println("Oauth_Auto_Login enabeld: ", cfg.GOAUTH.AutoLogin) + log.Println("Oauth_Auto_Login enabled: ", cfg.GOAUTH.AutoLogin) if cfg.GOAUTH.AutoLogin { if err := chromedp.Run(taskCtx, chromedp.Navigate(generatedURL), diff --git a/pkg/kiosk/local_login.go b/pkg/kiosk/local_login.go index 7706a61..a6a0652 100644 --- a/pkg/kiosk/local_login.go +++ b/pkg/kiosk/local_login.go @@ -32,6 +32,7 @@ func GrafanaKioskLocal(cfg *Config) { chromedp.Flag("disable-overlay-scrollbar", true), chromedp.Flag("ignore-certificate-errors", cfg.Target.IgnoreCertificateErrors), chromedp.Flag("test-type", cfg.Target.IgnoreCertificateErrors), + chromedp.Flag("window-position", cfg.General.WindowPosition), chromedp.UserDataDir(dir), } From aa345c9f93862eb733c4e08a4c8f5cb0f5fb3e4a Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Sun, 27 Jun 2021 00:06:51 -0500 Subject: [PATCH 3/6] Update docs --- README.md | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 6f1beec..b657bdd 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ Extract the zip or tar file, and copy the appropriate binary to /usr/bin/grafana ## Usage +NOTE: Flags with parameters should use an "equals" (-autofit=true, -URL=https://play.grafana.org) when also used with any boolean flags. + ```TEXT -URL string URL to Grafana server (default "https://play.grafana.org") @@ -149,19 +151,19 @@ They can also be used instead of a configuration file. This will login to a Hosted Grafana instance and take the browser to the default dashboard in fullscreen kiosk mode: ```bash -./bin/grafana-kiosk --URL https://bkgann3.grafana.net --login-method gcom --username bkgann --password abc123 --kiosk-mode full +./bin/grafana-kiosk -URL=https://bkgann3.grafana.net -login-method=gcom -username=bkgann -password=abc123 -kiosk-mode=full ``` This will login to a Hosted Grafana instance and take the browser to a specific dashboard in tv kiosk mode: ```bash -./bin/grafana-kiosk --URL https://bkgann3.grafana.net/dashboard/db/sensu-summary --login-method gcom --username bkgann --password abc123 --kiosk-mode tv +./bin/grafana-kiosk -URL=https://bkgann3.grafana.net/dashboard/db/sensu-summary -login-method=gcom -username=bkgann -password=abc123 -kiosk-mode tv ``` This will login to a Hosted Grafana instance and take the browser to a playlist in fullscreen kiosk mode, and autofit the panels to fill the display. ```bash -./bin/grafana-kiosk --URL https://bkgann3.grafana.net/playlists/play/1 --login-method gcom --username bkgann --password abc123 --kiosk-mode full --playlists --autofit +./bin/grafana-kiosk -URL=https://bkgann3.grafana.net/playlists/play/1 -login-method=gcom -username=bkgann -password=abc123 -kiosk-mode=full -playlists -autofit=true ``` ### Grafana Server with Local Accounts @@ -169,13 +171,13 @@ This will login to a Hosted Grafana instance and take the browser to a playlist This will login to a grafana server that uses local accounts: ```bash -./bin/grafana-kiosk --URL https://localhost:3000 --login-method local --username admin --password admin --kiosk-mode tv +./bin/grafana-kiosk -URL=https://localhost:3000 -login-method=local -username=admin -password=admin -kiosk-mode=tv ``` -If you are using a self-signed certificate, you can remove the certificate error with `--ignore-certificate-errors` +If you are using a self-signed certificate, you can remove the certificate error with `-ignore-certificate-errors` ```bash -./bin/grafana-kiosk --URL https://localhost:3000 --login-method local --username admin --password admin --kiosk-mode tv --ignore-certificate-errors +./bin/grafana-kiosk -URL=https://localhost:3000 -login-method=local -username=admin -password=admin -kiosk-mode=tv -ignore-certificate-errors ``` ### Grafana Server with Anonymous access enabled @@ -183,13 +185,13 @@ If you are using a self-signed certificate, you can remove the certificate error This will take the browser to the default dashboard on play.grafana.org in fullscreen kiosk mode (no login needed): ```bash -./bin/grafana-kiosk --URL https://play.grafana.org --login-method anon --kiosk-mode tv +./bin/grafana-kiosk -URL=https://play.grafana.org -login-method=anon -kiosk-mode=tv ``` This will take the browser to a playlist on play.grafana.org in fullscreen kiosk mode (no login needed): ```bash -./bin/grafana-kiosk --URL https://play.grafana.org/playlists/play/1 --login-method anon --kiosk-mode tv +./bin/grafana-kiosk -URL=https://play.grafana.org/playlists/play/1 -login-method=anon -kiosk-mode=tv ``` ### Grafana Server with Generic Oauth @@ -197,24 +199,24 @@ This will take the browser to a playlist on play.grafana.org in fullscreen kiosk This will login to a Generic Oauth service, configured on Grafana. Oauth_auto_login is disabeld. As Oauth provider is Keycloak used. ```bash -go run pkg/cmd/grafana-kiosk/main.go --URL https://my.grafana.oauth/playlists/play/1 --login-method goauth --username test --password test +go run pkg/cmd/grafana-kiosk/main.go -URL=https://my.grafana.oauth/playlists/play/1 -login-method=goauth -username=test -password=test ``` This will login to a Generic Oauth service, configured on Grafana. Oauth_auto_login is disabeld. As Oauth provider is Keycloak used and also the login and password html input name is set. ```bash -go run pkg/cmd/grafana-kiosk/main.go --URL https://my.grafana.oauth/playlists/play/1 --login-method goauth --username test --password test --field-username username --field-password password +go run pkg/cmd/grafana-kiosk/main.go -URL=https://my.grafana.oauth/playlists/play/1 -login-method=goauth -username=test -password=test -field-username=username -field-password=password ``` This will login to a Generic Oauth service, configured on Grafana. Oauth_auto_login is enabled. As Oauth provider is Keycloak used and also the login and password html input name is set. ```bash -go run pkg/cmd/grafana-kiosk/main.go --URL https://my.grafana.oauth/playlists/play/1 --login-method goauth --username test --password test --field-username username --field-password password --auto-login true +go run pkg/cmd/grafana-kiosk/main.go -URL=https://my.grafana.oauth/playlists/play/1 -login-method=goauth -username=test -password=test -field-username=username -field-password=password -auto-login=true ``` ## LXDE Options -The `--lxde` option initializes settings for the desktop. +The `-lxde` option initializes settings for the desktop. Actions Performed: @@ -225,7 +227,7 @@ Actions Performed: - runs `xset s noblank` disables blank mode for screensaver (maybe not needed) - runs `unclutter` to hide the mouse -The `--lxde-home` option allows you to specify a different $HOME directory where the lxde configuration files can be found. +The `-lxde-home` option allows you to specify a different $HOME directory where the lxde configuration files can be found. ## Automatic Startup @@ -236,7 +238,7 @@ LXDE can start the kiosk automatically by creating this file: Create/edit the file: `/home/pi/.config/lxsession/LXDE-pi/autostart` ```BASH -/usr/bin/grafana-kiosk --URL https://bkgann3.grafana.net/dashboard/db/sensu-summary --login-method gcom --username bkgann --password abc123 --kiosk-mode full --lxde +/usr/bin/grafana-kiosk -URL=https://bkgann3.grafana.net/dashboard/db/sensu-summary -login-method=gcom -username=bkgann -password=abc123 -kiosk-mode=full -lxde ``` #### Session with disconnected "screen" @@ -246,7 +248,7 @@ Alternatively you can run grafana-kiosk under screen, which can very useful for Create/edit the file: `/home/pi/.config/lxsession/LXDE-pi/autostart` ```BASH -screen -d -m bash -c "/usr/bin/grafana-kiosk --URL https://bkgann3.grafana.net/dashboard/db/sensu-summary --login-method gcom --username bkgann --password abc123 --kiosk-mode full --lxde" +screen -d -m bash -c "/usr/bin/grafana-kiosk -URL=https://bkgann3.grafana.net/dashboard/db/sensu-summary -login-method=gcom -username=bkgann -password=abc123 -kiosk-mode=full -lxde" ``` ### Desktop Link @@ -256,7 +258,7 @@ Create/edit the file: `/home/pi/.config/autostart/grafana-kiosk.desktop` ```INI [Desktop Entry] Type=Application -Exec=/usr/bin/grafana-kiosk --URL https://bkgann3.grafana.net/dashboard/db/sensu-summary --login-method gcom --username bkgann --password abc123 --kiosk-mode full --lxde +Exec=/usr/bin/grafana-kiosk -URL=https://bkgann3.grafana.net/dashboard/db/sensu-summary -login-method=gcom -username=bkgann -password=abc123 -kiosk-mode=full -lxde ``` #### Desktop Link with disconnected "screen" @@ -264,7 +266,7 @@ Exec=/usr/bin/grafana-kiosk --URL https://bkgann3.grafana.net/dashboard/db/sensu ```INI [Desktop Entry] Type=Application -Exec=screen -d -m bash -c /usr/bin/grafana-kiosk --URL https://bkgann3.grafana.net/dashboard/db/sensu-summary --login-method gcom --username bkgann --password abc123 --kiosk-mode full --lxde +Exec=screen -d -m bash -c /usr/bin/grafana-kiosk -URL=https://bkgann3.grafana.net/dashboard/db/sensu-summary -login-method=gcom -username=bkgann -password=abc123 -kiosk-mode=full -lxde ``` ## Systemd startup @@ -285,7 +287,7 @@ After=network.target User=pi Environment="DISPLAY=:0" Environment="XAUTHORITY=/home/pi/.Xauthority" -ExecStart=/usr/bin/grafana-kiosk --URL -login-method local -username -password -playlists true +ExecStart=/usr/bin/grafana-kiosk -URL= -login-method=local -username= -password= -playlists=true [Install] WantedBy=graphical.target From a006f938a360b5e2a0f38b634bd6f3a4aa7c0da2 Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Sun, 27 Jun 2021 13:28:18 -0500 Subject: [PATCH 4/6] cleanup modules --- go.mod | 2 -- go.sum | 28 +--------------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/go.mod b/go.mod index 1373543..7478f44 100644 --- a/go.mod +++ b/go.mod @@ -6,8 +6,6 @@ require ( github.com/chromedp/cdproto v0.0.0-20210625233425-810000e4a4fc github.com/chromedp/chromedp v0.7.3 github.com/ilyakaznacheev/cleanenv v1.2.5 - github.com/knq/sysutil v0.0.0-20191005231841-15668db23d08 // indirect - github.com/mailru/easyjson v0.7.7 // indirect github.com/smartystreets/goconvey v1.6.4 golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 // indirect ) diff --git a/go.sum b/go.sum index 4a9782b..f7d7a93 100644 --- a/go.sum +++ b/go.sum @@ -1,38 +1,20 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/chromedp/cdproto v0.0.0-20200116234248-4da64dd111ac/go.mod h1:PfAWWKJqjlGFYJEidUM6aVIWPr0EpobeyVWEEmplX7g= -github.com/chromedp/cdproto v0.0.0-20200424080200-0de008e41fa0 h1:Mf2aT0YmWsdNULwaHeCktDLWHb1s+VoDi9xEcFboLQ4= -github.com/chromedp/cdproto v0.0.0-20200424080200-0de008e41fa0/go.mod h1:PfAWWKJqjlGFYJEidUM6aVIWPr0EpobeyVWEEmplX7g= -github.com/chromedp/cdproto v0.0.0-20210526005521-9e51b9051fd0 h1:aIcgRshD5I1MfJfB92KBDKpaXrYqj3fkqI8bHdtP3zA= github.com/chromedp/cdproto v0.0.0-20210526005521-9e51b9051fd0/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U= github.com/chromedp/cdproto v0.0.0-20210625233425-810000e4a4fc h1:Gr9CJ/+rF6ZUXoP83j05KIh/HHBl3i3nXwXPqpLQaw0= github.com/chromedp/cdproto v0.0.0-20210625233425-810000e4a4fc/go.mod h1:At5TxYYdxkbQL0TSefRjhLE3Q0lgvqKKMSFUglJ7i1U= -github.com/chromedp/chromedp v0.5.3 h1:F9LafxmYpsQhWQBdCs+6Sret1zzeeFyHS5LkRF//Ffg= -github.com/chromedp/chromedp v0.5.3/go.mod h1:YLdPtndaHQ4rCpSpBG+IPpy9JvX0VD+7aaLxYgYj28w= github.com/chromedp/chromedp v0.7.3 h1:FvgJICfjvXtDX+miuMUY0NHuY8zQvjS/TcEQEG6Ldzs= github.com/chromedp/chromedp v0.7.3/go.mod h1:9gC521Yzgrk078Ulv6KIgG7hJ2x9aWrxMBBobTFk30A= github.com/chromedp/sysutil v1.0.0 h1:+ZxhTpfpZlmchB58ih/LBHX52ky7w2VhQVKQMucy3Ic= github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= -github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= -github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= -github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= -github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= -github.com/gobwas/ws v1.0.3 h1:ZOigqf7iBxkA4jdQ3am7ATzdlOFp9YzA6NmuvEEZc9g= -github.com/gobwas/ws v1.0.3/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= -github.com/gobwas/ws v1.0.4 h1:5eXU1CZhpQdq5kXbKb+sECH5Ia5KiO6CYzIzdlVx6Bs= -github.com/gobwas/ws v1.0.4/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/gobwas/ws v1.1.0-rc.5 h1:QOAag7FoBaBYYHRqzqkhhd8fq5RTubvI4v3Ft/gDVVQ= github.com/gobwas/ws v1.1.0-rc.5/go.mod h1:nzvNcVha5eUziGrbxFCo6qFIojQHjJV5cLYIbezhfL0= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/ilyakaznacheev/cleanenv v1.2.3 h1:EjZD1ATWWHNSGjc+W0LcGuoRBdsJHN3VVQQMB2EIDDQ= -github.com/ilyakaznacheev/cleanenv v1.2.3/go.mod h1:/i3yhzwZ3s7hacNERGFwvlhwXMDcaqwIzmayEhbRplk= github.com/ilyakaznacheev/cleanenv v1.2.5 h1:/SlcF9GaIvefWqFJzsccGG/NJdoaAwb7Mm7ImzhO3DM= github.com/ilyakaznacheev/cleanenv v1.2.5/go.mod h1:/i3yhzwZ3s7hacNERGFwvlhwXMDcaqwIzmayEhbRplk= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= @@ -41,12 +23,6 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/knq/sysutil v0.0.0-20191005231841-15668db23d08 h1:V0an7KRw92wmJysvFvtqtKMAPmvS5O0jtB0nYo6t+gs= -github.com/knq/sysutil v0.0.0-20191005231841-15668db23d08/go.mod h1:dFWs1zEqDjFtnBXsd1vPOZaLsESovai349994nHx3e0= -github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM= -github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= -github.com/mailru/easyjson v0.7.1 h1:mdxE1MF9o53iCb2Ghj1VfWvh7ZOwHpnVG/xwXrV90U8= -github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= @@ -56,15 +32,13 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 h1:YTzHMGlqJu67/uEo1lBv0n3wBXhXNeUbB1XfN2vmTm0= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210525143221-35b2ab0089ea/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From fb39468290271d88b52bd3f1dd7efb68848e4754 Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Mon, 28 Jun 2021 00:21:24 -0500 Subject: [PATCH 5/6] fixes gcom basic login --- CHANGELOG.md | 3 ++- pkg/kiosk/grafana_com_login.go | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d77477..cb68ead 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ - OAuth merged - Fix Grafana Cloud login - Updated modules -- Add "window-position" option +- Added "window-position" option, allows running kiosk on different displays +- Added `--check-for-update-interval=31536000` to default flags sent to chromium to workaround update popup ## 1.0.2 diff --git a/pkg/kiosk/grafana_com_login.go b/pkg/kiosk/grafana_com_login.go index f924c85..8c10971 100644 --- a/pkg/kiosk/grafana_com_login.go +++ b/pkg/kiosk/grafana_com_login.go @@ -55,12 +55,27 @@ func GrafanaKioskGCOM(cfg *Config) { Launch chrome, click the grafana.com button, fill out login form and submit */ // XPATH of grafana.com login button = //*[@href="login/grafana_com"]/i + // XPATH for grafana.com login (new) = //a[contains(@href,'login/grafana_com')] + + //chromedp.WaitVisible(`//*[@href="login/grafana_com"]/i`, chromedp.BySearch), // Click the grafana_com login button if err := chromedp.Run(taskCtx, chromedp.Navigate(generatedURL), - chromedp.WaitVisible(`//*[@href="login/grafana_com"]/i`, chromedp.BySearch), - chromedp.Click(`//*[@href="login/grafana_com"]/..`, chromedp.BySearch), + chromedp.ActionFunc(func(context.Context) error { + log.Println("waiting for login dialog") + return nil + }), + chromedp.WaitVisible(`//a[contains(@href,'login/grafana_com')]`, chromedp.BySearch), + chromedp.ActionFunc(func(context.Context) error { + log.Println("gcom login dialog detected") + return nil + }), + chromedp.Click(`//a[contains(@href,'login/grafana_com')]/..`, chromedp.BySearch), + chromedp.ActionFunc(func(context.Context) error { + log.Println("gcom button clicked") + return nil + }), ); err != nil { panic(err) } From 138acb6df782db084563078eb1173fb0a4120371 Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Mon, 28 Jun 2021 22:31:18 -0500 Subject: [PATCH 6/6] add update interval flag --- pkg/kiosk/anonymous_login.go | 2 +- pkg/kiosk/grafana_com_login.go | 2 +- pkg/kiosk/grafana_genericoauth_login.go | 2 +- pkg/kiosk/local_login.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/kiosk/anonymous_login.go b/pkg/kiosk/anonymous_login.go index d504c70..4b519b0 100644 --- a/pkg/kiosk/anonymous_login.go +++ b/pkg/kiosk/anonymous_login.go @@ -21,7 +21,6 @@ func GrafanaKioskAnonymous(cfg *Config) { opts := []chromedp.ExecAllocatorOption{ chromedp.NoFirstRun, chromedp.NoDefaultBrowserCheck, - // chromedp.DisableGPU, // needed? chromedp.Flag("noerrdialogs", true), chromedp.Flag("kiosk", true), chromedp.Flag("bwsi", true), @@ -32,6 +31,7 @@ func GrafanaKioskAnonymous(cfg *Config) { chromedp.Flag("ignore-certificate-errors", cfg.Target.IgnoreCertificateErrors), chromedp.Flag("test-type", cfg.Target.IgnoreCertificateErrors), chromedp.Flag("window-position", cfg.General.WindowPosition), + chromedp.Flag("check-for-update-interval", 31536000), chromedp.UserDataDir(dir), } diff --git a/pkg/kiosk/grafana_com_login.go b/pkg/kiosk/grafana_com_login.go index 8c10971..b4822e7 100644 --- a/pkg/kiosk/grafana_com_login.go +++ b/pkg/kiosk/grafana_com_login.go @@ -22,7 +22,6 @@ func GrafanaKioskGCOM(cfg *Config) { opts := []chromedp.ExecAllocatorOption{ chromedp.NoFirstRun, chromedp.NoDefaultBrowserCheck, - // chromedp.DisableGPU, // needed? chromedp.Flag("noerrdialogs", true), chromedp.Flag("kiosk", true), chromedp.Flag("bwsi", true), @@ -31,6 +30,7 @@ func GrafanaKioskGCOM(cfg *Config) { chromedp.Flag("disable-notifications", true), chromedp.Flag("disable-overlay-scrollbar", true), chromedp.Flag("window-position", cfg.General.WindowPosition), + chromedp.Flag("check-for-update-interval", 31536000), chromedp.UserDataDir(dir), } diff --git a/pkg/kiosk/grafana_genericoauth_login.go b/pkg/kiosk/grafana_genericoauth_login.go index 8312b79..77cef2a 100644 --- a/pkg/kiosk/grafana_genericoauth_login.go +++ b/pkg/kiosk/grafana_genericoauth_login.go @@ -22,7 +22,6 @@ func GrafanaKioskGenericOauth(cfg *Config) { opts := []chromedp.ExecAllocatorOption{ chromedp.NoFirstRun, chromedp.NoDefaultBrowserCheck, - // chromedp.DisableGPU, // needed? chromedp.Flag("noerrdialogs", true), chromedp.Flag("kiosk", true), chromedp.Flag("bwsi", true), @@ -31,6 +30,7 @@ func GrafanaKioskGenericOauth(cfg *Config) { chromedp.Flag("disable-notifications", true), chromedp.Flag("disable-overlay-scrollbar", true), chromedp.Flag("window-position", cfg.General.WindowPosition), + chromedp.Flag("check-for-update-interval", 31536000), chromedp.UserDataDir(dir), } diff --git a/pkg/kiosk/local_login.go b/pkg/kiosk/local_login.go index a6a0652..44068e6 100644 --- a/pkg/kiosk/local_login.go +++ b/pkg/kiosk/local_login.go @@ -22,7 +22,6 @@ func GrafanaKioskLocal(cfg *Config) { opts := []chromedp.ExecAllocatorOption{ chromedp.NoFirstRun, chromedp.NoDefaultBrowserCheck, - // chromedp.DisableGPU, // needed? chromedp.Flag("noerrdialogs", true), chromedp.Flag("kiosk", true), chromedp.Flag("bwsi", true), @@ -33,6 +32,7 @@ func GrafanaKioskLocal(cfg *Config) { chromedp.Flag("ignore-certificate-errors", cfg.Target.IgnoreCertificateErrors), chromedp.Flag("test-type", cfg.Target.IgnoreCertificateErrors), chromedp.Flag("window-position", cfg.General.WindowPosition), + chromedp.Flag("check-for-update-interval", 31536000), chromedp.UserDataDir(dir), }