8000 [pull] main from miniflux:main by pull[bot] · Pull Request #261 · suhaoGe/miniflux · GitHub
[go: up one dir, main page]

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
8000
2 changes: 1 addition & 1 deletion internal/googlereader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ The digest is generated server-side from:
- the Google Reader username
- the stored bcrypt hash of the Google Reader password

Specifically, the code computes an HMAC-SHA1 digest of an empty message using the key:
Specifically, the code computes an HMAC-SHA256 digest of an empty message using the key:

```text
googlereader_username + bcrypt_hash
Expand Down
7 changes: 4 additions & 3 deletions internal/googlereader/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ package googlereader // import "miniflux.app/v2/internal/googlereader"
import (
"context"
"crypto/hmac"
"crypto/sha1"
"crypto/sha256"
"encoding/hex"
"log/slog"
"net/http"
"strings"

"miniflux.app/v2/internal/crypto"
"miniflux.app/v2/internal/http/request"
"miniflux.app/v2/internal/model"
"miniflux.app/v2/internal/storage"
Expand Down Expand Up @@ -130,7 +131,7 @@ func (m *authMiddleware) validateApiKey(next http.Handler) http.Handler {
return
}
expectedToken := getAuthToken(integration.GoogleReaderUsername, integration.GoogleReaderPassword)
if expectedToken != token {
if !crypto.ConstantTimeCmp(expectedToken, token) {
slog.Warn("[GoogleReader] Token does not match",
slog.Bool("authentication_failed", true),
slog.String("client_ip", clientIP),
Expand Down Expand Up @@ -175,7 +176,7 @@ func (m *authMiddleware) validateApiKey(next http.Handler) http.Handler {
}

func getAuthToken(username, password string) string {
token := hex.EncodeToString(hmac.New(sha1.New, []byte(username+password)).Sum(nil))
token := hex.EncodeToString(hmac.New(sha256.New, []byte(username+password)).Sum(nil))
token = username + "/" + token
return token
}
Loading
0