diff --git a/README.md b/README.md index 2d4cb4c..3fc407a 100644 --- a/README.md +++ b/README.md @@ -42,18 +42,6 @@ $ chaturbate-dvr -u CHANNEL_USERNAME   -**🔒 Restrict access page** - -If you want to restrict access to the page using a username and password, add this to the accounts.json file - -```json -{ - "john.doe": "password" -} -``` - -  - ## Preview ![image_1](https://github.com/teacat/chaturbate-dvr/assets/7308718/c6d17ffe-eba7-4296-9315-f501489d85f3) @@ -107,6 +95,8 @@ COMMANDS: GLOBAL OPTIONS: --username value, -u value channel username to record. + --gui-username value, --gui-u value username for auth web. + --gui-password value, --gui-p value password for auth web. --framerate value, -f value preferred framerate. (default: 30) --resolution value, -r value preferred resolution (default: 1080) --resolution-fallback value, --rf value fallback to 'up' (larger) or 'down' (smaller) resolution if preferred resolution is not available (default: "down") diff --git a/accounts.json b/accounts.json deleted file mode 100644 index 9e26dfe..0000000 --- a/accounts.json +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/bin/arm64/darwin/chatubrate-dvr b/bin/arm64/darwin/chatubrate-dvr index 6bfa599..e944fc9 100755 Binary files a/bin/arm64/darwin/chatubrate-dvr and b/bin/arm64/darwin/chatubrate-dvr differ diff --git a/bin/arm64/linux/chatubrate-dvr b/bin/arm64/linux/chatubrate-dvr index c2099c8..63cbb22 100755 Binary files a/bin/arm64/linux/chatubrate-dvr and b/bin/arm64/linux/chatubrate-dvr differ diff --git a/bin/arm64/windows/chatubrate-dvr.exe b/bin/arm64/windows/chatubrate-dvr.exe index 757e1ee..189999d 100755 Binary files a/bin/arm64/windows/chatubrate-dvr.exe and b/bin/arm64/windows/chatubrate-dvr.exe differ diff --git a/bin/darwin/chatubrate-dvr b/bin/darwin/chatubrate-dvr index 07d05b0..ed951ca 100755 Binary files a/bin/darwin/chatubrate-dvr and b/bin/darwin/chatubrate-dvr differ diff --git a/bin/linux/chatubrate-dvr b/bin/linux/chatubrate-dvr index fc0d55f..78204d3 100755 Binary files a/bin/linux/chatubrate-dvr and b/bin/linux/chatubrate-dvr differ diff --git a/bin/windows/chatubrate-dvr.exe b/bin/windows/chatubrate-dvr.exe index 468f978..e7e8800 100755 Binary files a/bin/windows/chatubrate-dvr.exe and b/bin/windows/chatubrate-dvr.exe differ diff --git a/docker-compose-web.yml b/docker-compose-web.yml index 7fa9b7c..63f334b 100644 --- a/docker-compose-web.yml +++ b/docker-compose-web.yml @@ -6,7 +6,8 @@ services: build: context: . dockerfile: web.Dockerfile + environment: + - GUI_USERNAME=johndoe + - GUI_PASSWORD=password ports: - - "8080:8080" - volumes: - - ./accounts.json:/usr/src/app/accounts.json \ No newline at end of file + - "8080:8080" \ No newline at end of file diff --git a/main.go b/main.go index 5122ffc..66014f2 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,6 @@ package main import ( "embed" - "encoding/json" "fmt" "io/fs" "log" @@ -41,6 +40,18 @@ func main() { Usage: "channel username to record.", Value: "", }, + &cli.StringFlag{ + Name: "gui-username", + Aliases: []string{"gui-u"}, + Usage: "username for auth web.", + Value: "", + }, + &cli.StringFlag{ + Name: "gui-password", + Aliases: []string{"gui-p"}, + Usage: "password for auth web.", + Value: "", + }, &cli.IntFlag{ Name: "framerate", Aliases: []string{"f"}, @@ -127,21 +138,6 @@ func start(c *cli.Context) error { //go:embed handler/view var FS embed.FS -func listAccounts() gin.Accounts { - b, err := os.ReadFile("accounts.json") - if err != nil { - if os.IsNotExist(err) { - return nil - } - return nil - } - var configs gin.Accounts - if err := json.Unmarshal(b, &configs); err != nil { - return nil - } - return configs -} - func startWeb(c *cli.Context) error { gin.SetMode(gin.ReleaseMode) r := gin.Default() @@ -157,13 +153,16 @@ func startWeb(c *cli.Context) error { log.Fatalln(err) } - accounts := listAccounts() + guiUsername := c.String("gui-username") + guiPassword := c.String("gui-password") var authorized = r.Group("/") var authorizedApi = r.Group("/api") - if len(accounts) > 0 { - ginBasicAuth := gin.BasicAuth(accounts) + if guiUsername != "" && guiPassword != "" { + ginBasicAuth := gin.BasicAuth(gin.Accounts{ + guiUsername: guiPassword, + }) authorized.Use(ginBasicAuth) authorizedApi.Use(ginBasicAuth) } diff --git a/web.Dockerfile b/web.Dockerfile index c256c0b..575ba9b 100644 --- a/web.Dockerfile +++ b/web.Dockerfile @@ -8,4 +8,4 @@ RUN go mod download && go mod verify COPY . . RUN go build -CMD [ "sh", "-c", "./chaturbate-dvr" ] \ No newline at end of file +CMD [ "sh", "-c", "./chaturbate-dvr -gui-username ${GUI_USERNAME} -gui-password ${GUI_PASSWORD}" ] \ No newline at end of file