Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
supercaracal committed Jun 26, 2021
1 parent 3a24c2d commit 9b5a676
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ SCRAM-SHA-256$4096:yTo5lMI+1XyqZOcvYz99Kw==$VJcML25bB3h0xiMUFw9D4spAJwp8IxD1Cxnk

### Testing
```
$ docker run --rm --name=test -p 5432:5432 -e POSTGRES_PASSWORD=postgres -e POSTGRES_INITDB_ARGS=--auth-host=scram-sha-256 postgres
$ docker run --rm --name=test -e POSTGRES_PASSWORD=postgres -e POSTGRES_INITDB_ARGS=--auth-host=scram-sha-256 postgres
```

```
$ docker exec -it test psql -h 127.0.0.1 -U postgres -c "CREATE ROLE test WITH LOGIN PASSWORD 'SCRAM-SHA-256$4096:yTo5lMI+1XyqZOcvYz99Kw==$VJcML25bB3h0xiMUFw9D4spAJwp8IxD1CxnkR7XPty8=:NE05auswTZk1ntaXa8DrO9tYekyhfv1qRMXmugXpGPc='"
Password for user postgres:
$ docker exec -it test psql -U postgres -c "CREATE ROLE test WITH LOGIN PASSWORD 'SCRAM-SHA-256$4096:yTo5lMI+1XyqZOcvYz99Kw==$VJcML25bB3h0xiMUFw9D4spAJwp8IxD1CxnkR7XPty8=:NE05auswTZk1ntaXa8DrO9tYekyhfv1qRMXmugXpGPc='"
CREATE ROLE
```

```
$ docker exec -it test psql -h 127.0.0.1 -U postgres -c 'SELECT usename, passwd FROM pg_catalog.pg_shadow'
Password for user postgres:
$ docker exec -it test psql -U postgres -c 'SELECT usename, passwd FROM pg_catalog.pg_shadow'
usename | passwd
----------+---------------------------------------------------------------------------------------------------------------------------------------
postgres | SCRAM-SHA-256$4096:N+t+PZUQAu25roNaMJiQIw==$MNmcJjqjLwfWBTvKq2zRCWSWPFQX6KnDqqyrqA1XU5g=:jL3qX7jzS4wSP1rOmEbbmLReYL98WeKukK8SfLcdpvU=
Expand All @@ -35,10 +33,14 @@ Password for user postgres:
```

```
$ psql -h 127.0.0.1 -p 5432 -U test -W -d postgres -c 'SELECT 1'
$ docker exec -it test psql -h 127.0.0.1 -U test -W -d postgres -c 'SELECT 1'
Password:
?column?
----------
1
(1 row)
```

```
$ docker stop test
```
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func getStoredKey(clientKey []byte) (storedKey []byte) {
return
}

// FIXME: some bugs
func encryptPassword(rawPassword, salt []byte, iter, keyLen int) string {
digestKey := pbkdf2.Key(rawPassword, salt, iter, keyLen, sha256.New)
clientKey := getHashSum(digestKey, []byte("Client Key"))
Expand Down

0 comments on commit 9b5a676

Please sign in to comment.