Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20240517 prep release #130

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ jobs:
run: go get .

- name: Install golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --exclude-use-default
skip-cache: true
skip-pkg-cache: true

- name: Run Gosec Security Scanner
uses: securego/gosec@master
Expand All @@ -51,7 +50,7 @@ jobs:
args: -v build:ci

- name: Upload Code Climate Report
uses: paambaati/codeclimate-action@v5.0.0
uses: paambaati/codeclimate-action@v9.0.0
env:
CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
with:
Expand Down Expand Up @@ -99,5 +98,4 @@ jobs:
generate_release_notes: true
files: |
./grafana-kiosk-v*/**
body: |
** Draft release **
body_path: CHANGELOG.md
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
bin/
coverage/
coverage.html
coverage.out
35 changes: 35 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"cSpell.words": [
"apikey",
"armv",
"autofit",
"bkgann",
"changeme",
"chromedp",
"dpms",
"Fieldname",
"fullscreen",
"gcom",
"goauth",
"googleusercontent",
"Heylin",
"idtoken",
"journalctl",
"Keycloak",
"KEYFILE",
"LXDE",
"lxpanel",
"lxsession",
"Magefile",
"myoauthid",
"noblank",
"Pasqualone",
"pcmanfs",
"Ramberg",
"Ronan",
"Stäheli",
"TOPNAV",
"XAUTHORITY",
"xset"
]
}
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
# Change Log

## 1.1.0

NOTICE: BREAKING CHANGES!

The configuration parameters and YAML configurations have significantly changed.

- NEW configuration options:
- toggle for GPU (default: true)

```YAML
---
general:
gpu-enabled: false
```

- debug output to assist with setting up kiosk for first time (default: false)

```YAML
---
general:
debug: true
```

- start-maximized (default: true)
- start-fullscreen (default: true)

chromedp.Flag("start-fullscreen", true),
chromedp.Flag("start-maximized", true),

- PageLoadDelayMS, delay can be set to extend timeout to websocket (default: 2000)(verified working)
- Fixes:
- `--kiosk` toggle to fix for latest chrome/bookworm (default: true)

chromedp.Flag("kiosk", true),

incognito toggle

geolocation toggle

autofit now working from config

- Update workflow
- Fix for GCOM login Issue [#132](https://github.com/grafana/grafana-kiosk/issues/132)

## 1.0.8

- Fix for issue [#137](https://github.com/grafana/grafana-kiosk/issues/137) How to get rid of "Choose your search engine" window
Expand Down
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The utility provides these options:
- to a Grafana server (local account or bypass OAuth)
- 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 Cloud instance with Legacy API Token
- to a Grafana Cloud instance with Service Account Token
- to a Grafana server with OAuth enabled
- to an AWS Managed Grafana instance (both with and without MFA)
- Switch to kiosk or kiosk-tv mode
Expand All @@ -25,6 +27,10 @@ The utility provides these options:

Additionally, an initialize option is provided to configure LXDE for Raspberry Pi Desktop.

## BREAKING CHANGES from 1.0 to 1.1

NOTICE: Release 1.1.0 contains breaking changes. Parameters and YAML configurations have significantly changed.

## Installing on Linux

Download the zip or tar file from [releases](https://github.com/grafana/grafana-kiosk/releases)
Expand All @@ -40,6 +46,7 @@ The release file includes pre-built binaries. See table below for the types avai
| linux | arm | ARM v6 | grafana-kiosk.linux.armv6 |
| linux | arm | ARM v7 | grafana-kiosk.linux.armv7 |
| darwin | amd64 | 64bit | grafana-kiosk.darwin.amd64 |
| darwin | arm64 | 64bit | grafana-kiosk.darwin.arm64 |
| windows | amd64 | 64bit | grafana-kiosk.windows.amd64.exe |

Extract the zip or tar file, and copy the appropriate binary to /usr/bin/grafana-kiosk:
Expand All @@ -54,7 +61,7 @@ Extract the zip or tar file, and copy the appropriate binary to /usr/bin/grafana
This application can run on most operating systems, but for linux some additional
binaries are suggested for full support.

Suggesting Packages:
Suggested Packages:

`unclutter` (for hiding mouse/cursor)
`rng-tools` (for entropy issues)
Expand All @@ -74,7 +81,7 @@ NOTE: Flags with parameters should use an "equals"
idtoken audience
-auto-login
oauth_auto_login is enabled in grafana config
(set this flag along with the "local" login-method to bypass OAuth via the /login/local url and use a local grafana user/pass before continuing to the target URL)
(set this flag along with the "local" login-method to bypass OAuth via the /login/local url and use a local grafana user/pass before continuing to the target URL)
-autofit
Fit panels to screen (default true)
-c string
Expand Down Expand Up @@ -180,7 +187,7 @@ They can also be used instead of a configuration file.
KIOSK_IDTOKEN_KEYFILE string
JSON Credentials for idtoken (default "key.json")
KIOSK_IDTOKEN_AUDIENCE string
Audience for idtoken, tpyically your oauth client id
Audience for idtoken, typically your oauth client id
KIOSK_APIKEY_APIKEY string
APIKEY Generated in Grafana Server
```
Expand Down Expand Up @@ -219,7 +226,7 @@ If you are using a self-signed certificate, you can remove the certificate error
./bin/grafana-kiosk -URL=https://localhost:3000 -login-method=local -username=admin -password=admin -kiosk-mode=tv -ignore-certificate-errors
```

This will login to a grafana server, configured for AzureAD OAuth and has Oauth_auto_login is enabled, bypassing OAuth and using a manually setup local username and password.
This will login to a grafana server, configured for AzureAD OAuth and has OAuth_auto_login is enabled, bypassing OAuth and using a manually setup local username and password.

```bash
./bin/grafana-kiosk -URL=https://localhost:3000 -login-method=local -username=admin -password=admin -auto-login=true -kiosk-mode=tv
Expand Down Expand Up @@ -247,21 +254,27 @@ This will take the browser to the default dashboard on play.grafana.org in fulls
./bin/grafana-kiosk -URL=https://play.grafana.org -login-method apikey --apikey "xxxxxxxxxxxxxxx" -kiosk-mode=tv
```

### Grafana Server with Generic Oauth
Note: You can use a legacy API key, or the new Service Account method that has a token issued to it:

See: [Create A Service Account]<https://grafana.com/docs/grafana/latest/administration/service-accounts/#create-a-service-account-in-grafana> and [Service Account Tokens]<https://grafana.com/docs/grafana/latest/administration/service-accounts/#service-account-tokens>

For Legacy Keys see: [API Keys]<https://grafana.com/docs/grafana/latest/administration/api-keys/#api-keys>

### Grafana Server with Generic OAuth

This will login to a Generic Oauth service, configured on Grafana. Oauth_auto_login is disabeld. As Oauth provider is Keycloak used.
This will login to a Generic OAuth service, configured on Grafana. `oauth_auto_login` is disabled. An OAuth provider called `Keycloak` is 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
```

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.
This will login to a Generic OAuth service, configured on Grafana. `oauth_auto_login` is disabled. An OAuth provider called `Keycloak` is used and 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
```

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.
This will login to a Generic OAuth service, configured on Grafana. `oauth_auto_login` is enabled. An OAuth provider called `Keycloak` is used and 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
Expand Down
5 changes: 3 additions & 2 deletions config-example.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
general:
kiosk-mode: full
autofit: true
lxde: true
lxde: false
lxde-home: /home/pi
window-position: 1920,1000

target:
login-method: anon
Expand All @@ -16,4 +17,4 @@ target:
goauth:
auto-login: false
fieldname-username: username
fieldname-password: password
fieldname-password: password
40 changes: 28 additions & 12 deletions pkg/cmd/grafana-kiosk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Args struct {
Password string
UsernameField string
PasswordField string
PageLoadDelayMS int64
WindowPosition string
WindowSize string
ScaleFactor string
Expand All @@ -62,6 +63,7 @@ func ProcessArgs(cfg interface{}) Args {
flagSettings.BoolVar(&processedArgs.AutoFit, "autofit", true, "Fit panels to screen")
flagSettings.BoolVar(&processedArgs.LXDEEnabled, "lxde", false, "Initialize LXDE for kiosk mode")
flagSettings.StringVar(&processedArgs.LXDEHome, "lxde-home", "/home/pi", "Path to home directory of LXDE user running X Server")
flagSettings.Int64Var(&processedArgs.PageLoadDelayMS, "pageload-delay-ms", 2000, "Milliseconds to wait for page to load")
flagSettings.BoolVar(&processedArgs.IgnoreCertificateErrors, "ignore-certificate-errors", false, "Ignore SSL/TLS certificate error")
flagSettings.BoolVar(&processedArgs.OauthAutoLogin, "auto-login", false, "oauth_auto_login is enabled in grafana config")
flagSettings.StringVar(&processedArgs.UsernameField, "field-username", "username", "Fieldname for the username")
Expand Down Expand Up @@ -118,13 +120,14 @@ func setEnvironment() {

func summary(cfg *kiosk.Config) {
// general
log.Println("AutoFit:", cfg.General.AutoFit)
log.Println("AutoFit:", cfg.GrafanaOptions.AutoFit)
log.Println("LXDEEnabled:", cfg.General.LXDEEnabled)
log.Println("LXDEHome:", cfg.General.LXDEHome)
log.Println("Mode:", cfg.General.Mode)
log.Println("WindowPosition:", cfg.General.WindowPosition)
log.Println("WindowSize:", cfg.General.WindowSize)
log.Println("ScaleFactor:", cfg.General.ScaleFactor)
log.Println("PageLoadDelayMS:", cfg.General.PageLoadDelayMS)
log.Println("GrafanaOptions - Kiosk Mode:", cfg.GrafanaOptions.KioskMode)
log.Println("WindowPosition:", cfg.ChromeDPFlags.WindowPosition)
log.Println("WindowSize:", cfg.ChromeDPFlags.WindowSize)
log.Println("ScaleFactor:", cfg.ChromeDPFlags.ScaleFactor)
// target
log.Println("URL:", cfg.Target.URL)
log.Println("LoginMethod:", cfg.Target.LoginMethod)
Expand Down Expand Up @@ -171,6 +174,9 @@ func main() {
if err := cleanenv.ReadEnv(&cfg); err != nil {
log.Println("Error reading config from environment", err)
}
//
cfg.Bearer.APIKey = args.APIKey
//
cfg.Target.URL = args.URL
cfg.Target.LoginMethod = args.LoginMethod
cfg.Target.Username = args.Username
Expand All @@ -179,22 +185,32 @@ func main() {
cfg.Target.IsPlayList = args.IsPlayList
cfg.Target.UseMFA = args.UseMFA
//
cfg.General.AutoFit = args.AutoFit
cfg.ChromeDPFlags.WindowPosition = args.WindowPosition
cfg.ChromeDPFlags.WindowSize = args.WindowSize
cfg.ChromeDPFlags.ScaleFactor = args.ScaleFactor
//
cfg.General.LXDEEnabled = args.LXDEEnabled
cfg.General.LXDEHome = args.LXDEHome
cfg.General.Mode = args.Mode
cfg.General.WindowPosition = args.WindowPosition
cfg.General.WindowSize = args.WindowSize
cfg.General.ScaleFactor = args.ScaleFactor
cfg.General.PageLoadDelayMS = args.PageLoadDelayMS
//
cfg.GoAuth.AutoLogin = args.OauthAutoLogin
cfg.GoAuth.UsernameField = args.UsernameField
cfg.GoAuth.PasswordField = args.PasswordField

//
cfg.GrafanaOptions.AutoFit = args.AutoFit
cfg.GrafanaOptions.KioskMode = args.Mode
//
cfg.IDToken.Audience = args.Audience
cfg.IDToken.KeyFile = args.KeyFile
//
cfg.Target.URL = args.URL
cfg.Target.LoginMethod = args.LoginMethod
cfg.Target.Username = args.Username
cfg.Target.Password = args.Password
cfg.Target.IgnoreCertificateErrors = args.IgnoreCertificateErrors
cfg.Target.IsPlayList = args.IsPlayList
cfg.Target.UseMFA = args.UseMFA

cfg.APIKey.APIKey = args.APIKey
}

// make sure the url has content
Expand Down
18 changes: 11 additions & 7 deletions pkg/cmd/grafana-kiosk/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ func TestMain(t *testing.T) {
Version: "1.0.0",
},
General: kiosk.General{
AutoFit: true,
LXDEEnabled: true,
LXDEHome: "/home/pi",
Mode: "full",
LXDEEnabled: true,
LXDEHome: "/home/pi",
},
GrafanaOptions: kiosk.GrafanaOptions{
AutoFit: true,
KioskMode: "full",
},
ChromeDPFlags: kiosk.ChromeDPFlags{
WindowPosition: "0,0",
WindowSize: "1920,1080",
ScaleFactor: "1.0",
Expand All @@ -44,7 +48,7 @@ func TestMain(t *testing.T) {
KeyFile: "/tmp/key.json",
Audience: "clientid",
},
APIKey: kiosk.APIKey{
Bearer: kiosk.Bearer{
APIKey: "abc",
},
}
Expand All @@ -69,12 +73,12 @@ func TestMain(t *testing.T) {
oldArgs := os.Args
defer func() { os.Args = oldArgs }()
os.Args = []string{"grafana-kiosk", ""}
os.Setenv("KIOSK_AUTOFIT", "false")
os.Setenv("KIOSK_GRAFANA_AUTOFIT", "false")
cfg := kiosk.Config{}
if err := cleanenv.ReadEnv(&cfg); err != nil {
log.Println("Error reading config from environment", err)
}
So(cfg.General.AutoFit, ShouldBeFalse)
So(cfg.GrafanaOptions.AutoFit, ShouldBeFalse)
})
})
// end of general options
Expand Down
Loading