diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b229014 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +certs diff --git a/Dockerfile b/Dockerfile index d2e36e8..04c7c5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,13 @@ FROM golang:1.11.5 as build WORKDIR /go/src/github.com/mitchell/selfpass COPY . . -ENV GO111MODULE=on -RUN make gen-certs-go +ENV GO111MODULE on RUN make build FROM debian:stable-20190506-slim -WORKDIR /usr/bin -COPY --from=build /go/src/github.com/mitchell/selfpass/bin/server . +COPY --from=build /go/src/github.com/mitchell/selfpass/bin/server /usr/bin/server +RUN groupadd -r selfpass && useradd --no-log-init -r -g selfpass selfpass +USER selfpass +WORKDIR /home/selfpass ENTRYPOINT ["server"] EXPOSE 8080 diff --git a/Makefile b/Makefile index d81ddee..a63cdcc 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,15 @@ -.PHONY: all build clean format test +.PHONY: all build clean format test gen-certs-go build: clean format env CGO_ENABLED=0 go build -o ./bin/server ./cmd/server - rm ./cmd/server/certs.go clean: rm -rf ./bin go mod tidy -docker: +docker: gen-certs-go docker-compose build + rm ./cmd/server/certs.go local: docker-compose up -d diff --git a/credentials/commands/create.go b/credentials/commands/create.go index 13813ba..bf8f839 100644 --- a/credentials/commands/create.go +++ b/credentials/commands/create.go @@ -91,7 +91,7 @@ password.`, check(survey.AskOne(prompt, &cpass, nil)) if ci.Password != cpass { - fmt.Println("passwords didn't match'") + fmt.Println("passwords didn't match") os.Exit(1) } } @@ -127,7 +127,7 @@ password.`, } } - ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) defer cancel() c, err := initClient(ctx).Create(ctx, ci) diff --git a/credentials/commands/delete.go b/credentials/commands/delete.go index 18410a7..7883c41 100644 --- a/credentials/commands/delete.go +++ b/credentials/commands/delete.go @@ -21,7 +21,7 @@ func MakeDelete(initConfig CredentialClientInit) *cobra.Command { check(survey.AskOne(prompt, &confirmed, nil)) if confirmed { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) defer cancel() check(initConfig(ctx).Delete(ctx, args[0])) diff --git a/credentials/commands/get.go b/credentials/commands/get.go index 3eb5e5b..51a0acb 100644 --- a/credentials/commands/get.go +++ b/credentials/commands/get.go @@ -25,7 +25,7 @@ decrypting password.`, Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) defer cancel() cred, err := initClient(ctx).Get(ctx, args[0]) diff --git a/credentials/commands/list.go b/credentials/commands/list.go index 1b5f17b..3f97331 100644 --- a/credentials/commands/list.go +++ b/credentials/commands/list.go @@ -3,9 +3,11 @@ package commands import ( "context" "fmt" - "time" + "os" + "os/exec" "github.com/spf13/cobra" + "gopkg.in/AlecAivazis/survey.v1" ) func MakeList(initClient CredentialClientInit) *cobra.Command { @@ -18,13 +20,14 @@ func MakeList(initClient CredentialClientInit) *cobra.Command { includes almost all the information but the most sensitive.`, Run: func(cmd *cobra.Command, args []string) { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) - defer cancel() + ctx := context.Background() mdch, errch := initClient(ctx).GetAllMetadata(ctx, sourceHost) + fmt.Println() + receive: - for { + for count := 0; ; count++ { select { case <-ctx.Done(): check(fmt.Errorf("context timeout")) @@ -37,6 +40,20 @@ includes almost all the information but the most sensitive.`, break receive } + if count != 0 && count%3 == 0 { + var proceed bool + prompt := &survey.Confirm{Message: "Next page?", Default: true} + check(survey.AskOne(prompt, &proceed, nil)) + + if !proceed { + break receive + } + + clearCmd := exec.Command("clear") + clearCmd.Stdout = os.Stdout + check(clearCmd.Run()) + } + fmt.Println(md) } }