Commit Graph

24 Commits

Author SHA1 Message Date
a1346054
844ad9ad79 fix spelling
Signed-off-by: a1346054 <36859588+a1346054@users.noreply.github.com>
2021-08-23 12:19:03 +02:00
Simon McVittie
c704685ecf oci-authenticator: Return G_DBUS_METHOD_INVOCATION_HANDLED where appropriate
Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-12-09 08:34:19 +01:00
Alexander Larsson
180d807d2a oci-authenticator: Fix crash if anon auth fails and no_interaction is set
We were clearing the error from the anon test, and then not doing any
non-anon auth, so error was NULL, causing a crash when returning an
error message.
2020-10-09 16:57:57 +02:00
Alexander Larsson
09d57249f4 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.
2020-08-20 16:44:56 +02:00
Alexander Larsson
bfa3b15435 Transaction: Add "previous-error" option to basic auth error
Also, send this for the oci authenticator.
2020-06-09 14:52:00 +02:00
Alexander Larsson
4c9ff0fb7d oci authenticator: Only loop password prompt on 401 error 2020-06-09 14:52:00 +02:00
Alexander Larsson
743619141f oci authenticator: Translate some missing strings 2020-06-09 14:52:00 +02:00
Alexander Larsson
ac9e86eb8f OCI Authenticator: Report error code in errors 2020-06-09 14:52:00 +02:00
Alexander Larsson
0290c154bf oci authenticator: Make the authentication debug logs a bit more verbose 2020-05-04 16:32:22 +02:00
Alexander Larsson
6395d04e40 Merge pull request #3471 from owtaylor/oci-error-overwrite
oci-authenticator: fix failures to clear GError
2020-03-17 11:12:51 +01:00
Owen W. Taylor
08636d4729 oci-authenticator: reuse token results when we already have them
When we already have a token for the first repository after probing
for no-auth authenticator or testing user-entered credentials, just
use that, don't request it again in the loop over repositories.

This gives a significant optimization of the prompted-credentials
case for registry.redhat.io, which takes 4-5 seconds to generate a
token, hopefully avoiding the user thinking something has gone wrong.

Signed-off-by: Owen W. Taylor <otaylor@fishsoup.net>
2020-03-16 16:26:04 -04:00
Owen W. Taylor
425f628263 oci-authenticator: fix failures to clear GError
Fix problems overwriting a GError when we retry multiple times.
One of these was introduced with the recent change
e3f17a89a flatpak-oci-authenticator: try getting a token without credentials
but the other was existing.

Signed-off-by: Owen W. Taylor <otaylor@fishsoup.net>
2020-03-16 15:59:21 -04:00
Matthew Leeds
84c68ad501 oci-authenticator: Don't shadow a global variable 2020-03-16 09:29:31 +01:00
Owen W. Taylor
fe3f17a89a flatpak-oci-authenticator: try getting a token without credentials
Some registries require getting a token even to download an image
anonymously. So, if no auth has been configured, before prompting
the user for username/password, try without a BasicAuth header.

Signed-off-by: Owen W. Taylor <otaylor@fishsoup.net>
2020-03-16 09:13:41 +01:00
Alexander Larsson
aabadfdc8e authenticator: Fix sandboxed authenticators
We rely on broadcast signals for authenticator replies rather than unicast
as these are not filtered by the sandbox (due to them being opt-in by the
receiver).

Actually this already worked fine in the flatpak side as the generated
code already subscribes to the signals, this just switches the internal
authenticators (test and oci) to using the new way to emit signals.
2019-12-19 10:33:21 +01:00
Alexander Larsson
65f2bdf840 oci-authenticator: Remove leftover TODO comment
We *do* handle dying peers now, so remove TODO about this.
2019-12-17 15:00:23 +01:00
Alexander Larsson
24145b0845 oci-authenticator: Reply to the close message
The client will be waiting for the response, so make sure we send it!
2019-12-17 15:00:23 +01:00
Alexander Larsson
7ecc9fa12c oci-authenticator: Skip interaction of no-interaction is set 2019-12-17 14:59:43 +01:00
Alexander Larsson
38c86bdf0f Authenticator: Add extra a{sv} args for future use
These are not used atm, but make the APIs future proof.
2019-12-12 14:27:59 +01:00
Alexander Larsson
328b793c5a oci authenticator: Lookup up auth tokens in predefined files
We look in these, in this order:
 ~/.config/flatpak/oci-auth.json
 /etc/flatpak/oci-auth.json
 /run/user/$uid/containers/auth.json
 /run/containers/$uid/auth.json
 ~/.docker/config.json

The first two are flatpak specific, and the others are what
skopeo and docker use.
2019-12-12 12:16:53 +01:00
Alexander Larsson
39ee9bc594 oci authenticator: Pass registry url as realm 2019-12-12 12:16:53 +01:00
Alexander Larsson
c56e1c4646 oci-authenticator: Use basic authentication to log in if no other auth 2019-12-12 12:16:53 +01:00
Alexander Larsson
8818f08fd1 oci-authenticator: Add helpers for sending responses 2019-12-12 12:16:53 +01:00
Alexander Larsson
d25f65e968 OCI: Add an authenticator for OCI remotes
Given a configuration like:

[remote "oci-remote"]
url=oci+http://some.server.com/api/v1/organization/foo?index=labels
xa.authenticator-name=org.flatpak.Authenticator.Oci
xa.default-token-type=1
xa.authenticator-options={"auth": <"a-token-here">}

I was able to install an app from an OCI remote that required a login
2019-12-12 12:16:53 +01:00