Skip to content

Commit 8e7306c

Browse files
committed
Fixes #3: use symmetric key for JWT
1 parent 5488727 commit 8e7306c

File tree

4 files changed

+6
-13
lines changed

4 files changed

+6
-13
lines changed

Makefile

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,18 @@ test-cover: test ## run unit tests and show test coverage information
3131

3232
.PHONY: run
3333
run: ## run the API server
34-
go run ${LDFLAGS} cmd/server/main.go & echo $$! > $(PID_FILE)
35-
36-
.PHONY: run-stop
37-
run-stop: ## stop the API server
38-
@pkill -P `cat $(PID_FILE)` || true
34+
go run ${LDFLAGS} cmd/server/main.go
3935

4036
.PHONY: run-restart
4137
run-restart: ## restart the API server
42-
@make run-stop
38+
@pkill -P `cat $(PID_FILE)` || true
4339
@printf '%*s\n' "80" '' | tr ' ' -
4440
@echo "Source file changed. Restarting server..."
45-
@make run
41+
@go run ${LDFLAGS} cmd/server/main.go & echo $$! > $(PID_FILE)
4642
@printf '%*s\n' "80" '' | tr ' ' -
4743

48-
run-live: run ## run the API server with live reload support (requires fswatch)
44+
run-live: ## run the API server with live reload support (requires fswatch)
45+
@go run ${LDFLAGS} cmd/server/main.go & echo $$! > $(PID_FILE)
4946
@fswatch -x -o --event Created --event Updated --event Renamed -r internal pkg cmd config | xargs -n1 -I {} make run-restart
5047

5148
.PHONY: build

cmd/server/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func buildHandler(logger log.Logger, db *dbcontext.DB, cfg *config.Config) http.
8585

8686
rg := router.Group("/v1")
8787

88-
authHandler := auth.Handler(cfg.JWTVerificationKey)
88+
authHandler := auth.Handler(cfg.JWTSigningKey)
8989

9090
album.RegisterHandlers(rg.Group(""),
9191
album.NewService(album.NewRepository(db, logger), logger),

config/local.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
dsn: "postgres://127.0.0.1/go_restful?sslmode=disable&user=postgres&password=postgres"
22
jwt_signing_key: "LxsKJywDL5O5PvgODZhBH12KE6k2yL8E"
3-
jwt_verification_key: "IuDQoh1QAIFwnKAydSntyJrTmOkct3wN"

internal/config/config.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ type Config struct {
2121
DSN string `yaml:"dsn" env:"DSN,secret"`
2222
// JWT signing key. required.
2323
JWTSigningKey string `yaml:"jwt_signing_key" env:"JWT_SIGNING_KEY,secret"`
24-
// JWT verification key. required.
25-
JWTVerificationKey string `yaml:"jwt_verification_key" env:"JWT_VERIFICATION_KEY,secret"`
2624
// JWT expiration in hours. Defaults to 72 hours (3 days)
2725
JWTExpiration int `yaml:"jwt_expiration" env:"JWT_EXPIRATION"`
2826
}
@@ -32,7 +30,6 @@ func (c Config) Validate() error {
3230
return validation.ValidateStruct(&c,
3331
validation.Field(&c.DSN, validation.Required),
3432
validation.Field(&c.JWTSigningKey, validation.Required),
35-
validation.Field(&c.JWTVerificationKey, validation.Required),
3633
)
3734
}
3835

0 commit comments

Comments
 (0)