diff --git a/android-client/PMA.SyncClient.pas b/android-client/PMA.SyncClient.pas index 44d0d90..14b3838 100644 --- a/android-client/PMA.SyncClient.pas +++ b/android-client/PMA.SyncClient.pas @@ -140,7 +140,8 @@ begin LHttp.ResponseTimeout := FTimeoutMs; LHttp.HandleRedirects := False; LHttp.UserAgent := 'PMServer'; - LHttp.CustomHeaders['Authorization'] := 'token ' + FToken; + // SANS JETON, expres : "public" = visible par n'importe qui. Un jeton faux + // faisait repondre 401 avant tout verdict ; prive et anonyme = 404. try LResp := LHttp.Get(RepoApiUrl(FBaseUrl)); except diff --git a/delphi-backend/UMainForm.pas b/delphi-backend/UMainForm.pas index 581e389..2da4864 100644 --- a/delphi-backend/UMainForm.pas +++ b/delphi-backend/UMainForm.pas @@ -1659,7 +1659,12 @@ begin // "token " et non "Bearer" : c'est la forme que Gitea attend // d'un jeton d'acces personnel, et l'autre donne un 401 muet. if LGitea then - LHttp.CustomHeaders['Authorization'] := 'token ' + LPwd + begin + // Pas d'en-tete du tout sans jeton : la verification "depot + // public" se fait volontairement en anonyme. + if LPwd <> '' then + LHttp.CustomHeaders['Authorization'] := 'token ' + LPwd; + end else if (LUser <> '') then begin LHttp.CredentialsStorage.AddCredential( diff --git a/js/app.sync.js b/js/app.sync.js index ddfe412..2800532 100644 --- a/js/app.sync.js +++ b/js/app.sync.js @@ -115,7 +115,11 @@ function syncNormalizeRepoUrl(u) { async function syncRepoPublicWarning(cfg) { if (!syncIsGitea(cfg.url)) return ''; const repoUrl = cfg.url.split('/contents/')[0]; - const r = await _webdavCall('get', repoUrl, cfg.user, cfg.pwd); + // SANS JETON, expres : "public" veut dire "visible par n'importe qui", et + // c'est exactement la question posee. Avec un jeton faux, GitHub repondait + // 401 avant de dire quoi que ce soit du depot ; un depot prive repond 404 + // sans jeton, ce qui veut dire "pas public". + const r = await _webdavCall('get', repoUrl, '', ''); if (r.status < 200 || r.status >= 300 || !r.payload) return ''; try { const o = JSON.parse(new TextDecoder().decode(base64ToBytes(r.payload))); @@ -309,6 +313,9 @@ async function syncTestConnection() { const cfg = await loadSyncConfig(true); // needs the WebDAV credentials if (!cfg || !cfg.url) return toast('Set the WebDAV URL first', 'warning'); toast('Testing connection…'); + // LE DEPOT PUBLIC D'ABORD : il est refuse quel que soit le jeton. + const pubFirst = await syncRepoPublicWarning(cfg); + if (pubFirst) return toast(pubFirst, 'error'); const r = await _webdavCall('test', cfg.url, cfg.user, cfg.pwd); // A reachable Gitea with a valid token is not enough: a URL pointing one // path segment off answers 200 with JSON that is not a file. Checking the @@ -318,8 +325,6 @@ async function syncTestConnection() { try { un = giteaUnwrap(new TextDecoder().decode(base64ToBytes(r.payload || ''))); } catch (e) { /* traite comme une forme inattendue */ } - const pub = await syncRepoPublicWarning(cfg); - if (pub) return toast(pub, 'error'); return un ? toast('Connection OK · file found in the repository') : toast('Reached Gitea, but this URL does not return a file — ' +