Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Server

on:
push:
branches: ["main"]
branches: ["main", "develop"]
pull_request:
branches: ["main"]
branches: ["main", "develop"]
workflow_dispatch: {}

jobs:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
workflow_dispatch:
inputs:
node-version:
Expand Down
14 changes: 7 additions & 7 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions server/auth/passwords.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import (
"crypto/hmac"
"crypto/sha256"
"fmt"
"github.com/FachschaftMathPhysInfo/kummerkasten/utils"
"golang.org/x/crypto/bcrypt"
"log"
"os"
)

var envConf = utils.EnvConfig

func HashPassword(password string) (string, error) {
toHash := []byte(password + os.Getenv("PEPPER"))
toHash := []byte(password + envConf.Pepper)
secretHmac := hmac.New(sha256.New, toHash)
secretHmac.Write(toHash)
hash, err := bcrypt.GenerateFromPassword(toHash, bcrypt.DefaultCost)
Expand All @@ -23,7 +25,7 @@ func HashPassword(password string) (string, error) {
}

func VerifyPassword(storedHash, providedPassword string) error {
toHash := []byte(providedPassword + os.Getenv("PEPPER"))
toHash := []byte(providedPassword + envConf.Pepper)
secretHmac := hmac.New(sha256.New, toHash)
secretHmac.Write(toHash)

Expand Down
21 changes: 11 additions & 10 deletions server/db/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"database/sql"
"fmt"
"github.com/FachschaftMathPhysInfo/kummerkasten/utils"
"log"
"os"
"time"

"github.com/FachschaftMathPhysInfo/kummerkasten/models"
Expand All @@ -16,10 +16,11 @@ import (
)

var (
db *bun.DB
sqldb *sql.DB
err error
tables = []interface{}{
envConf = utils.EnvConfig
db *bun.DB
sqldb *sql.DB
err error
tables = []interface{}{
(*models.User)(nil),
(*models.Label)(nil),
(*models.Setting)(nil),
Expand All @@ -39,11 +40,11 @@ const PingIntervalDBConnection = 5 * time.Second
func Init(ctx context.Context) (*sql.DB, *bun.DB) {

dsn := fmt.Sprintf("postgres://%s:%s@%s:%s/%s?sslmode=disable",
os.Getenv("POSTGRES_USER"),
os.Getenv("POSTGRES_PASSWORD"),
os.Getenv("POSTGRES_HOST"),
os.Getenv("POSTGRES_PORT"),
os.Getenv("POSTGRES_DB"))
envConf.PostgresUser,
envConf.PostgresPassword,
envConf.PostgresHost,
envConf.PostgresPort,
envConf.PostgresDB)

sqldb = sql.OpenDB(pgdriver.NewConnector(pgdriver.WithDSN(dsn)))

Expand Down
Loading
Loading