Update WOPISrc URL to include access_token for Collabora and remove unnecessary hidden input

This commit is contained in:
Leon Bösche
2026-02-05 16:01:05 +01:00
parent 9eac0fe178
commit c49b2d2805
2 changed files with 6 additions and 11 deletions

Binary file not shown.

View File

@@ -872,21 +872,17 @@ func collaboraProxyHandler(w http.ResponseWriter, r *http.Request, db *database.
return return
} }
// Build WOPISrc URL (without access_token - Collabora will use Authorization header) // Build WOPISrc URL (include access_token for Collabora)
wopiSrc := fmt.Sprintf("https://go.b0esche.cloud/wopi/files/%s", fileID) 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) // Get the correct Collabora editor URL from discovery (includes version hash)
editorURL := getCollaboraEditorURL(collaboraURL) editorURL := getCollaboraEditorURL(collaboraURL)
// URL-encode the WOPISrc for use in the form action URL (Collabora requires this) // WOPISrc is passed unencoded in the query parameter
encodedWopiSrc := url.QueryEscape(wopiSrc) collaboraFullURL := fmt.Sprintf("%s?WOPISrc=%s", editorURL, wopiSrc)
// Build the full Collabora URL with WOPISrc as query parameter
collaboraFullURL := fmt.Sprintf("%s?WOPISrc=%s", editorURL, encodedWopiSrc)
// Return HTML page with auto-submitting form // Return HTML page with auto-submitting form
// The form POSTs to Collabora with access_token in the body // No access_token needed in body since it's in WOPISrc
// WOPISrc must be in the URL as a query parameter
htmlContent := fmt.Sprintf(`<!DOCTYPE html> htmlContent := fmt.Sprintf(`<!DOCTYPE html>
<html> <html>
<head> <head>
@@ -904,7 +900,6 @@ func collaboraProxyHandler(w http.ResponseWriter, r *http.Request, db *database.
<p>Loading Collabora Online...</p> <p>Loading Collabora Online...</p>
</div> </div>
<form method="POST" action="%s" target="_self" id="collaboraForm" style="display: none;"> <form method="POST" action="%s" target="_self" id="collaboraForm" style="display: none;">
<input type="hidden" id="access_token" name="access_token" value="%s">
</form> </form>
<script> <script>
// Auto-submit the form to Collabora // Auto-submit the form to Collabora
@@ -917,7 +912,7 @@ func collaboraProxyHandler(w http.ResponseWriter, r *http.Request, db *database.
} }
</script> </script>
</body> </body>
</html>`, collaboraFullURL, accessToken, collaboraFullURL) </html>`, collaboraFullURL, collaboraFullURL)
w.Header().Set("Content-Type", "text/html; charset=utf-8") w.Header().Set("Content-Type", "text/html; charset=utf-8")
// Don't set X-Frame-Options - this endpoint is meant to be loaded in an iframe // Don't set X-Frame-Options - this endpoint is meant to be loaded in an iframe