URL-decode access token in WOPI handlers and add debug logging for received tokens

This commit is contained in:
Leon Bösche
2026-02-04 23:56:42 +01:00
parent 5139334d4d
commit 67e6d89eb2
2 changed files with 15 additions and 0 deletions

Binary file not shown.

View File

@@ -223,6 +223,13 @@ func wopiCheckFileInfoHandler(w http.ResponseWriter, r *http.Request, db *databa
return
}
// URL-decode the token in case it was encoded
if decodedToken, err := url.QueryUnescape(accessToken); err == nil {
accessToken = decodedToken
}
fmt.Printf("[WOPI-DEBUG] CheckFileInfo received token: %s\n", accessToken)
// Validate token
claims, err := validateWOPIAccessToken(accessToken, jwtManager)
if err != nil {
@@ -452,6 +459,13 @@ func wopiPutFileHandler(w http.ResponseWriter, r *http.Request, db *database.DB,
}
accessToken := strings.TrimPrefix(authHeader, "Bearer ")
// URL-decode the token in case it was encoded
if decodedToken, err := url.QueryUnescape(accessToken); err == nil {
accessToken = decodedToken
}
fmt.Printf("[WOPI-DEBUG] PutFile received token: %s\n", accessToken)
// Validate token
claims, err := validateWOPIAccessToken(accessToken, jwtManager)
if err != nil {
@@ -846,6 +860,7 @@ func collaboraProxyHandler(w http.ResponseWriter, r *http.Request, db *database.
}
// Build WOPISrc URL (with access_token as query parameter)
// JWT tokens are URL-safe, so no additional encoding needed
wopiSrc := fmt.Sprintf("https://go.b0esche.cloud/wopi/files/%s?access_token=%s", fileID, accessToken)
// Get the correct Collabora editor URL from discovery (includes version hash)