Skip to content

Commit 494243d

Browse files
yakuteremredipirecepfatihsezginmrtrkmn
authored
Version v1.2.1 (#196)
* removed api check on signup * added recaptcha to signup * fixed unrelated email issue (#151) * go-fmt for auth.go * change goroutine email * fix subscription status * update recaptcha * fix signin email conflict * little changes * disabled Recaptcha * updated Readme * update go mod * youtube link (#158) * added type conv. check * added RespondWithEncJSON * changed Decrypt payload * added helper test * refactor logins * update test data * added test suite * add env dev to emails * Refactoring Some Functions (#160) * refactor bankaccount functions * refactor creditcard functions * refactor server functions * refactor note functions * deleted recaptcha func (#159) * TODO about CreateUser fixed (#161) * create user actions moved to the service layer * some user tests introduced (#164) * some user tests introduced Signed-off-by: Ahmet Turkmen <[email protected]> * UUID enhancement (#168) * update mw * fixed token invalidation * added validator to app/user (#169) * fix: add email template * fix: auth confirmation code * fix: update subcription process * fix: add redirect after email confirm * fix: updare subscription * change login logic * update docker compose * Update error message (#171) * delete a user without logging in (#173) * fix refresh token with userUUID * feat: add change master password feature * update * ADD db ssl mode issue #177 (#178) * add cli and fix db usessl docker * update docker file with passwall-cli * add create subscription to cli * add config.yml to gitignore * Update jwt package (#179) * implemented new logger package * update db gorm package and seperate update and create * change JWT storage to cookie * add cookie bugs * add signout and refactor * minor fixes * add both bearer and cookie support * fix minor bug * add wait for postgres to docker-compose * Readme (#182) * Add comment lines to repository interface (#183) * Refactored Any function (#185) * Refactored Any function * Renamed function name * Add argument to function (#186) * Refactored Any function * Renamed function name * Add return argument to function * minor fixes * Add auto ssl with lets encrypt (#189) Signed-off-by: Kaan Karakaya <[email protected]> * update docker compose files * remove query parameter args * update readme for docker compose * Export Feature (#190) * Add export endpoint for data exporting * Add export handlers * Update export handler * fix export errors * Add return error if decryption fails (#191) * Fix typo and broken link (#194) Closes #193 * fix upstream git remote address * fix broken link of a document * upgrade go version to 1.17 (#195) Signed-off-by: mrtrkmn <[email protected]> Co-authored-by: mrtrkmn <[email protected]> * add Makefile * update go.mod * improve startup logging * refactor: refactor export function and minor improvements Signed-off-by: Kaan Karakaya <[email protected]> Co-authored-by: Emre Dipi <[email protected]> Co-authored-by: Recep Alaca <[email protected]> Co-authored-by: Fatih Sezgin <[email protected]> Co-authored-by: Ahmet Türkmen <[email protected]> Co-authored-by: Mehmet Güngören <[email protected]> Co-authored-by: Yakut Özcan <[email protected]> Co-authored-by: Ahmet Can Çiçek <[email protected]> Co-authored-by: Ahmet Can Çiçek <[email protected]> Co-authored-by: Kaan Karakaya <[email protected]> Co-authored-by: SADIK KUZU <[email protected]> Co-authored-by: mrtrkmn <[email protected]>
1 parent 6a23ff6 commit 494243d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1221
-430
lines changed

.github/workflows/buildtest.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
- 5432:5432
2424

2525
steps:
26-
- name: Set up Go 1.14
27-
uses: actions/setup-go@v1
26+
- name: Set up Go 1.17
27+
uses: actions/setup-go@v2
2828
with:
29-
go-version: 1.14
29+
go-version: 1.17
3030
id: go
3131

3232

.goreleaser.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.yml

Whitespace-only changes.

CONTRIBUTING-TR.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Eğer daha önce hiç pull request yapmadıysanız aramıza hoşgeldiniz :tada:
8989
# Klonlanan dizine gidin
9090
cd <repo-name>
9191
# Orjinal repoyu "upstream" adlı bir remote called'a atayın
92-
git remote add upstream https://github.com/hoodiehq/<repo-name>
92+
git remote add upstream https://github.com/passwall/<repo-name>
9393
```
9494

9595
2. Eğer daha önce fork yaptıysanız, upstream üzerinden en son değişiklikleri alın:
@@ -117,7 +117,7 @@ Eğer daha önce hiç pull request yapmadıysanız aramıza hoşgeldiniz :tada:
117117

118118
7. Net, anlaşılır bir başlık ve açıklama ile pull request açın. [Konu hakkında yardımcı döküman](https://help.github.com/articles/using-pull-requests/)
119119

120-
Açık kaynak projeye nasıl katkıda bulunulabileceğini anlatan daha detaylı bir dokümana [şuradan](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github) ulaşabilirsiniz.
120+
Açık kaynak projeye nasıl katkıda bulunulabileceğini anlatan daha detaylı bir dokümana [şuradan](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github) ulaşabilirsiniz.
121121

122122
Hata bildirimi (Bug report)
123123
------------

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,3 @@ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certifi
3131
COPY --from=builder /app/passwall-server /app/passwall-server
3232

3333
COPY --from=builder /app/passwall-cli /app/passwall-cli
34-
35-
COPY --from=builder /app/store /app/store

Makefile

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
SHELL := bash
2+
.SHELLFLAGS := -e -o pipefail -c
3+
MAKEFLAGS += --warn-undefined-variables
4+
5+
ifeq ($(GOPATH),)
6+
GOPATH = $(HOME)/go
7+
endif
8+
9+
GOBIN ?= $(GOPATH)/bin
10+
GOOS ?= $(shell go env GOOS)
11+
GOARCH ?= $(shell go env GOARCH)
12+
container_test_args := -test.v $(TEST_ARGS)
13+
14+
ifdef SUDO_USER
15+
SKIP_ADMIN_TEST = 0
16+
endif
17+
18+
export SKIP_ADMIN_TEST
19+
export GOPATH
20+
export GOBIN
21+
22+
# build time variables embedded in final executable
23+
VERSION ?= "1.2.0"
24+
BUILD_TIME := $(shell date -u +%Y-%m-%dT%H:%M:%S)
25+
COMMIT_ID := $(strip $(shell git rev-parse HEAD))
26+
# strip debug info from binaries
27+
GO_BUILD_LDFLAGS := -s -w
28+
# set build time variables
29+
GO_BUILD_LDFLAGS += -X github.com/passwall/passwall-server/pkg/buildvars.Version=$(VERSION)
30+
GO_BUILD_LDFLAGS += -X github.com/passwall/passwall-server/pkg/buildvars.BuildTime=$(BUILD_TIME)
31+
GO_BUILD_LDFLAGS += -X github.com/passwall/passwall-server/pkg/buildvars.CommitID=$(COMMIT_ID)
32+
33+
GO_BUILD_TAGS = netgo osusergo
34+
ifeq ($(GOOS),darwin)
35+
CGO_CFLAGS = -mmacosx-version-min=10.15
36+
CGO_LDFLAGS = -mmacosx-version-min=10.15
37+
# export SDKROOT=$(shell xcrun --sdk macosx --show-sdk-path)
38+
export CGO_CFLAGS
39+
export CGO_LDFLAGS
40+
endif
41+
42+
ifdef disable_test
43+
disable_test_race = 1
44+
endif
45+
46+
go_test := CGO_ENABLED=0 go test -v -count=1 -failfast \
47+
-ldflags "$(GO_BUILD_LDFLAGS)" -tags "$(GO_BUILD_TAGS)"
48+
49+
version_output_file ?= ./passwall-server_version.json
50+
51+
.PHONY: all
52+
all: test build
53+
54+
.PHONY: test
55+
test: get generate lint
56+
ifndef disable_test
57+
# internal tests
58+
$(go_test) -coverpkg=./... -coverprofile=$(GOOS)-cover.out ./...
59+
$(GOBIN)/gocov convert $(GOOS)-cover.out | $(GOBIN)/gocov report
60+
endif
61+
# -race is not supported on 386 architecture
62+
# -race tests fail under docker arm64 container due to emulation.
63+
ifndef disable_test_race
64+
ifneq ($(GOARCH),386)
65+
$(go_test) -race -failfast ./...
66+
endif
67+
endif
68+
69+
70+
.PHONY: lint
71+
lint:
72+
ifndef disable_lint
73+
$(GOBIN)/golangci-lint run --timeout 15m ./...
74+
endif
75+
76+
.PHONY: get
77+
get:
78+
go version
79+
go env
80+
@echo -------------
81+
@echo GOBIN=$(GOBIN)
82+
@echo GOPATH=$(GOPATH)
83+
mkdir -p $(GOBIN)
84+
mkdir -p $(GOPATH)
85+
ifndef disable_lint
86+
# install golangci-lint, Note: always check version and update below.
87+
[ ! -f $(GOBIN)/golangci-lint ] && \
88+
CGO_ENABLED=0 curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
89+
sh -s -- -b $(GOBIN) v1.44.2 || true
90+
[ -x $(GOBIN)/golangci-lint ]
91+
endif
92+
ifndef disable_test
93+
# install coverage reporter
94+
[ ! -f $(GOBIN)/gocov ] && \
95+
go install github.com/axw/gocov/gocov@latest || true
96+
[ -x $(GOBIN)/gocov ]
97+
endif
98+
99+
.PHONY: build
100+
build: generate
101+
go version
102+
go env
103+
rm -f ./passwall-server
104+
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -trimpath -tags "$(GO_BUILD_TAGS)" \
105+
-ldflags "$(GO_BUILD_LDFLAGS)" -o ./passwall-server ./cmd/passwall-server
106+
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -trimpath -tags "$(GO_BUILD_TAGS)" \
107+
-ldflags "$(GO_BUILD_LDFLAGS)" -o ./passwall-cli ./cmd/passwall-cli
108+
109+
110+
# We embed files in pkg/embedded package with go generate command.
111+
.PHONY: generate
112+
generate:
113+
go generate ./...
114+
115+
.PHONY: clean
116+
clean:
117+
rm -f *-cover.out
118+
rm -f gotest_*.test
119+
rm -f *.log
120+
rm -f ./passwall-server
121+
find . -iname "*.log" -type f -delete || true

README.md

Lines changed: 25 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,37 @@ I promise all the coffee you have ordered will be spent on this project
2020
<img src="https://www.yakuter.com/wp-content/yuklemeler/passwall-screenshot.png" alt="" width="600" height="425" />
2121
</p>
2222

23-
## API Documentation
24-
API documentation available at [Postman Public Directory](https://documenter.getpostman.com/view/3658426/SzYbyHXj)
23+
## On Premise Installation
24+
1. Pull passwall-server image from Docker Hub.
2525

26-
PassWall has both server and client side encryption. So when creating user to work with Postman you should use already SHA256 encrypted password in JSON or use a Postman Pre-request Script to encrypt json in form.
27-
28-
**Postman Pre-request Script Usage**
29-
While creating a user via Postman, you should send a post request to **/auth/signup** endpoint. In the request use the JSON schema below as **raw body**. Do not change **{{password}}**, it is an environment variable in Postman.
30-
```json
31-
{
32-
"name": "Erhan Yakut",
33-
"email": "[email protected]",
34-
"master_password": "{{password}}"
35-
}
26+
```
27+
docker pull passwall/passwall-server
3628
```
3729

38-
Then in Pre-request Script, copy and paste the javascript code below. You should change the password in the code.
39-
```javascript
40-
var newPassword = '123456' // Change this
41-
42-
pm.environment.set('password', newPassword);
43-
44-
var encryptedPassword = CryptoJS.SHA256(pm.environment.get('password')).toString();
45-
46-
pm.environment.set('password',encryptedPassword);
47-
48-
console.log(encryptedPassword);
49-
```
50-
Click on [this link](https://www.youtube.com/watch?v=bFgstpIA3iE&list=PL645jNNONo8TBOBDFRq7SolX_aWCT2Ia9) to visit our Youtube playlist.
51-
52-
53-
## Database support
54-
PassWall works with **PostgreSQL** databases.
30+
2. Download the docker-compose.yml file and start the server with the following commands.
5531

56-
## Configuration
57-
When PassWall Server starts, it automatically generates **config.yml** in the folders below:
58-
**MacOS:** $HOME/Library/Application Support/passwall-server
59-
**Windows:** $APPDATA/passwall-server
60-
**Linux:** $HOME/.config/passwall-server
32+
```
33+
mkdir $HOME/passwall-server
34+
```
35+
```
36+
cd $HOME/passwall-server
37+
```
38+
```
39+
wget https://raw.githubusercontent.com/passwall/passwall-server/main/docker-compose.yml
40+
```
41+
```
42+
docker-compose up -d
43+
```
6144

45+
3. Create a new user with passwall-cli.
46+
```
47+
docker exec -it passwall-server /app/passwall-cli
48+
```
6249

50+
4. Download and install any passwall client you want from [paswall.io](https://signup.passwall.io).
51+
5. Open your client and write http://localhost:3625 into the server url field. Login with your newly created user information.
52+
## API Documentation
53+
API documentation available at [Postman Public Directory](https://documenter.getpostman.com/view/3658426/SzYbyHXj)
6354
## Security
6455
1. PassWall uses The Advanced Encryption Standard (AES) encryption algorithm with Galois/Counter Mode (GCM) symmetric-key cryptographic mode. Passwords encrypted with AES can only be decrypted with the passphrase defined in the **config.yml** file.
6556

@@ -91,24 +82,6 @@ These environment variables are accepted:
9182
- PW_DB_PORT
9283
- PW_DB_LOG_MODE
9384

94-
**Backup Variables**
95-
- PW_BACKUP_FOLDER
96-
- PW_BACKUP_ROTATION
97-
- PW_BACKUP_PERIOD
98-
99-
## Development usage
100-
Install Go to your computer. Pull the server repo. Execute the command in server folder.
101-
102-
```
103-
go run ./cmd/passwall-server
104-
```
105-
106-
## Docker
107-
108-
```
109-
docker-compose up --build
110-
```
111-
11285
## Hello Contributors
11386

11487
1. Don't send too much commit at once. It will be easier for us to do a code review.

cmd/passwall-cli/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ func main() {
3131
c := color.New(color.FgCyan)
3232

3333
reader := bufio.NewReader(os.Stdin)
34-
c.Print("Enter Name: ")
34+
35+
c.Print("Enter Name Surname: ")
3536
name, _ := reader.ReadString('\n')
3637

3738
c.Print("Enter E-mail Address: ")

cmd/passwall-server/main.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
11
package main
22

33
import (
4+
"fmt"
45
"net/http"
6+
"os"
7+
"path/filepath"
58
"time"
69

710
"github.com/passwall/passwall-server/internal/app"
811
"github.com/passwall/passwall-server/internal/config"
912
"github.com/passwall/passwall-server/internal/router"
1013
"github.com/passwall/passwall-server/internal/storage"
14+
"github.com/passwall/passwall-server/pkg/buildvars"
1115
"github.com/passwall/passwall-server/pkg/constants"
1216
"github.com/passwall/passwall-server/pkg/logger"
1317
)
1418

1519
func main() {
20+
// Set current working directory to make logger and config use the application dir
21+
err := os.Chdir(filepath.Dir(appFilePath()))
22+
if err != nil {
23+
logger.Fatalf("os.Chdir failed error: %v", err)
24+
}
25+
26+
logStartupInfo()
27+
1628
cfg, err := config.Init(constants.ConfigPath, constants.ConfigName)
1729
if err != nil {
1830
logger.Fatalf("config.Init: %s", err)
@@ -36,8 +48,32 @@ func main() {
3648
Handler: router.New(s),
3749
}
3850

39-
logger.Infof("listening on %s", cfg.Server.Port)
51+
msg := fmt.Sprintf("Passwall Server is up and running on '%s' in '%s' mode", cfg.Server.Port, cfg.Server.Env)
52+
fmt.Println(msg)
53+
logger.Infof("Passwall Server is up and running on %s", cfg.Server.Port)
4054
if err := srv.ListenAndServe(); err != nil {
4155
logger.Fatalf("failed to start server: %v", err)
4256
}
4357
}
58+
59+
func logStartupInfo() {
60+
args := os.Args
61+
if args == nil {
62+
args = []string{}
63+
}
64+
65+
logger.Infof("Version: %s Commit ID: %s Build Time: %s", buildvars.Version, buildvars.CommitID, buildvars.BuildTime)
66+
67+
// Important: %q quotes the each slice item and provides better logging but it panicks! if slice is nil.
68+
logger.Infof("Application arguments: %q", args)
69+
}
70+
71+
// appFilePath returns the file path of the executable that is currently running
72+
func appFilePath() string {
73+
path, err := os.Executable()
74+
if err != nil {
75+
// Fallback to args array which may not always be the full path
76+
return os.Args[0]
77+
}
78+
return path
79+
}

0 commit comments

Comments
 (0)