aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorMax Resnick <max@ofmax.li>2024-04-02 21:42:47 -0700
committerMax Resnick <max@ofmax.li>2024-04-02 21:42:47 -0700
commit36cf7c3c00688f623d62216e71aa2c73f8e8d78a (patch)
tree96693c604b81637a598c52f5f1dd320fce18fa40 /internal
parent544fd53047b240170ea51abd418f132b69eadf42 (diff)
downloadgo-git-server-36cf7c3c00688f623d62216e71aa2c73f8e8d78a.tar.gz
feat: switch to hex encoding
Diffstat (limited to 'internal')
-rw-r--r--internal/authz/middleware.go4
-rw-r--r--internal/authz/model.go4
2 files changed, 4 insertions, 4 deletions
diff --git a/internal/authz/middleware.go b/internal/authz/middleware.go
index 441240f..3c029b0 100644
--- a/internal/authz/middleware.go
+++ b/internal/authz/middleware.go
@@ -3,7 +3,7 @@ package authz
import (
"context"
- "encoding/base64"
+ "encoding/hex"
"fmt"
"log"
"net/http"
@@ -33,7 +33,7 @@ func Authentication(authMap TokenMap, next http.Handler) http.Handler {
http.Error(rw, "Bad Request", http.StatusForbidden)
return
}
- token, err := base64.URLEncoding.DecodeString(p)
+ token, err := hex.DecodeString(p)
if err != nil {
http.Error(rw, "Bad Request", http.StatusBadRequest)
return
diff --git a/internal/authz/model.go b/internal/authz/model.go
index efa78f7..1ed61cf 100644
--- a/internal/authz/model.go
+++ b/internal/authz/model.go
@@ -2,8 +2,8 @@ package authz
import (
"crypto/rand"
- "encoding/base64"
"encoding/csv"
+ "encoding/hex"
"fmt"
"math/big"
"os"
@@ -56,7 +56,7 @@ func GenerateNewToken() (string, string, error) {
if err != nil {
return "", "", err
}
- token := base64.URLEncoding.EncodeToString(tokenBytes)
+ token := hex.EncodeToString(tokenBytes)
hash := string(hashBytes)
return token, hash, nil
}