oci-auth: Don't ask for authentication if anon auth fails with weird error

If the initial anonymous fails for any other reason than "not authorized"
we immediately fail the operation instead of asking for user/password.
The later is creating a very bad UX in case of e.g. networking or
infrastructure issues, as described in #3753.

(cherry picked from commit 09d57249f4)
This commit is contained in:
Alexander Larsson
2020-08-13 13:55:29 +02:00
committed by Alexander Larsson
parent 5c63fba452
commit aa739a18f0

View File

@@ -525,8 +525,21 @@ handle_request_ref_tokens (FlatpakAuthenticator *f_authenticator,
have_auth = TRUE;
else
{
g_debug ("Anonymous authentication failed: %s", error->message);
g_clear_error (&error);
if (g_error_matches (error, FLATPAK_ERROR, FLATPAK_ERROR_NOT_AUTHORIZED))
{
g_debug ("Anonymous authentication failed: %s", error->message);
g_clear_error (&error);
/* Continue trying with authentication below */
}
else
{
/* We failed with some weird reason (network issue maybe?) and it is unlikely
* that adding some authentication will fix it. It will just cause a bad UX like
* described in #3753, so just return the error early.
*/
return error_request (request, sender, error);
}
}
}