<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/credential.c, branch v2.40.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.40.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.40.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2023-02-22T23:18:58Z</updated>
<entry>
<title>credential: new attribute password_expiry_utc</title>
<updated>2023-02-22T23:18:58Z</updated>
<author>
<name>M Hickford</name>
<email>mirth.hickford@gmail.com</email>
</author>
<published>2023-02-18T06:32:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d208bfdfef97a1e8fb746763b5057e0ad91e283b'/>
<id>urn:sha1:d208bfdfef97a1e8fb746763b5057e0ad91e283b</id>
<content type='text'>
Some passwords have an expiry date known at generation. This may be
years away for a personal access token or hours for an OAuth access
token.

When multiple credential helpers are configured, `credential fill` tries
each helper in turn until it has a username and password, returning
early. If Git authentication succeeds, `credential approve`
stores the successful credential in all helpers. If authentication
fails, `credential reject` erases matching credentials in all helpers.
Helpers implement corresponding operations: get, store, erase.

The credential protocol has no expiry attribute, so helpers cannot
store expiry information. Even if a helper returned an improvised
expiry attribute, git credential discards unrecognised attributes
between operations and between helpers.

This is a particular issue when a storage helper and a
credential-generating helper are configured together:

	[credential]
		helper = storage  # eg. cache or osxkeychain
		helper = generate  # eg. oauth

`credential approve` stores the generated credential in both helpers
without expiry information. Later `credential fill` may return an
expired credential from storage. There is no workaround, no matter how
clever the second helper. The user sees authentication fail (a retry
will succeed).

Introduce a password expiry attribute. In `credential fill`, ignore
expired passwords and continue to query subsequent helpers.

In the example above, `credential fill` ignores the expired password
and a fresh credential is generated. If authentication succeeds,
`credential approve` replaces the expired password in storage.
If authentication fails, the expired credential is erased by
`credential reject`. It is unnecessary but harmless for storage
helpers to self prune expired credentials.

Add support for the new attribute to credential-cache.
Eventually, I hope to see support in other popular storage helpers.

Example usage in a credential-generating helper
https://github.com/hickford/git-credential-oauth/pull/16

Signed-off-by: M Hickford &lt;mirth.hickford@gmail.com&gt;
Reviewed-by: Calvin Wan &lt;calvinwan@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>urlmatch.c: add and use a *_release() function</title>
<updated>2022-03-04T21:24:18Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2022-03-04T18:32:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a41e8e74674d53a46616b01f2c18e43c7f2f30a8'/>
<id>urn:sha1:a41e8e74674d53a46616b01f2c18e43c7f2f30a8</id>
<content type='text'>
Plug a memory leak in credential_apply_config() by adding and using a
new urlmatch_config_release() function. This just does a
string_list_clear() on the "vars" member.

This finished up work on normalizing the init/free pattern in this
API, started in 73ee449bbf2 (urlmatch.[ch]: add and use
URLMATCH_CONFIG_INIT, 2021-10-01).

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>urlmatch.[ch]: add and use URLMATCH_CONFIG_INIT</title>
<updated>2021-10-01T21:22:51Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-10-01T10:27:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=73ee449bbf2918e29d26361e57f35a24f224e3be'/>
<id>urn:sha1:73ee449bbf2918e29d26361e57f35a24f224e3be</id>
<content type='text'>
Change the initialization pattern of "struct urlmatch_config" to use
an *_INIT macro and designated initializers. Right now there's no
other "struct" member of "struct urlmatch_config" which would require
its own *_INIT, but it's good practice not to assume that. Let's also
change this to a designated initializer while we're at it.

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>credential: fix leak in credential_apply_config()</title>
<updated>2021-08-25T18:41:30Z</updated>
<author>
<name>Mike Hommey</name>
<email>mh@glandium.org</email>
</author>
<published>2021-08-20T08:44:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5146c2f148e903db2d906dae372803d9c8c3bbcf'/>
<id>urn:sha1:5146c2f148e903db2d906dae372803d9c8c3bbcf</id>
<content type='text'>
Signed-off-by: Mike Hommey &lt;mh@glandium.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>*.c *_init(): define in terms of corresponding *_INIT macro</title>
<updated>2021-07-01T19:32:22Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-07-01T10:51:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5726a6b4012cd41701927a6637b9f2070e7760ee'/>
<id>urn:sha1:5726a6b4012cd41701927a6637b9f2070e7760ee</id>
<content type='text'>
Change the common patter in the codebase of duplicating the
initialization logic between an *_INIT macro and a
corresponding *_init() function to use the macro as the canonical
source of truth.

Now we no longer need to keep the function up-to-date with the macro
version. This implements a suggestion by Jeff King who found that
under -O2 [1] modern compilers will init new version in place without
the extra copy[1]. The performance of a single *_init() won't matter
in most cases, but even if it does we're going to be producing
efficient machine code to perform these operations.

1. https://lore.kernel.org/git/YNyrDxUO1PlGJvCn@coredump.intra.peff.net/

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>credential: treat CR/LF as line endings in the credential protocol</title>
<updated>2020-10-03T17:41:03Z</updated>
<author>
<name>Nikita Leonov</name>
<email>nykyta.leonov@gmail.com</email>
</author>
<published>2020-10-03T13:29:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=356c473295097f4aeaacc1a2dcd70271b7080788'/>
<id>urn:sha1:356c473295097f4aeaacc1a2dcd70271b7080788</id>
<content type='text'>
This fix makes using Git credentials more friendly to Windows users: it
allows a credential helper to communicate using CR/LF line endings ("DOS
line endings" commonly found on Windows) instead of LF-only line endings
("Unix line endings").

Note that this changes the behavior a bit: if a credential helper
produces, say, a password with a trailing Carriage Return character,
that will now be culled even when the rest of the lines end only in Line
Feed characters, indicating that the Carriage Return was not meant to be
part of the line ending.

In practice, it seems _very_ unlikely that something like this happens.
Passwords usually need to consist of non-control characters, URLs need
to have special characters URL-encoded, and user names, well, are names.

However, it _does_ help on Windows, where CR/LF line endings are common:
as unrecognized commands are simply ignored by the credential machinery,
even a command like `quit\r` (which is clearly intended to abort) would
simply be ignored (silently) by Git.

So let's change the credential machinery to accept both CR/LF and LF
line endings.

While we do this for the credential helper protocol, we do _not_ adjust
`git credential-cache--daemon` (which won't work on Windows, anyway,
because it requires Unix sockets) nor `git credential-store` (which
writes the file `~/.git-credentials` which we consider an implementation
detail that should be opaque to the user, read: we do expect users _not_
to edit this file manually).

Signed-off-by: Nikita Leonov &lt;nykyta.leonov@gmail.com&gt;
Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>run_command: teach API users to use embedded 'args' more</title>
<updated>2020-08-26T22:32:37Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-08-26T22:25:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=afbdba391eaf3c473eff8f12437ff510935b520f'/>
<id>urn:sha1:afbdba391eaf3c473eff8f12437ff510935b520f</id>
<content type='text'>
The child_process structure has an embedded strvec for formulating
the command line argument list these days, but code that predates
the wide use of it prepared a separate char *argv[] array and
manually set the child_process.argv pointer point at it.

Teach these old-style code to lose the separate argv[] array.

Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'js/partial-urlmatch'</title>
<updated>2020-05-05T21:54:30Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-05-05T21:54:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=568324f31ba6cec13532e420117d312db65ddd80'/>
<id>urn:sha1:568324f31ba6cec13532e420117d312db65ddd80</id>
<content type='text'>
The same as js/partial-urlmatch-2.17, built on more recent codebase
to avoid unnecessary merge conflicts.

* js/partial-urlmatch:
  credential: handle `credential.&lt;partial-URL&gt;.&lt;key&gt;` again
  credential: optionally allow partial URLs in credential_from_url_gently()
</content>
</entry>
<entry>
<title>Merge branch 'js/partial-urlmatch-2.17'</title>
<updated>2020-05-05T21:54:29Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-05-05T21:54:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=da05cacd8a4e7c3d6d8c84aa2c1d45684717ac95'/>
<id>urn:sha1:da05cacd8a4e7c3d6d8c84aa2c1d45684717ac95</id>
<content type='text'>
Recent updates broke parsing of "credential.&lt;url&gt;.&lt;key&gt;" where
&lt;url&gt; is not a full URL (e.g. [credential "https://"] helper = ...)
stopped working, which has been corrected.

* js/partial-urlmatch-2.17:
  credential: handle `credential.&lt;partial-URL&gt;.&lt;key&gt;` again
  credential: optionally allow partial URLs in credential_from_url_gently()
  credential: fix grammar
</content>
</entry>
<entry>
<title>Merge branch 'bc/wildcard-credential'</title>
<updated>2020-05-05T21:54:26Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2020-05-05T21:54:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=fd65fc3960a972ab2f03b94d08f0e421d9ee22bb'/>
<id>urn:sha1:fd65fc3960a972ab2f03b94d08f0e421d9ee22bb</id>
<content type='text'>
Update the parser used for credential.&lt;URL&gt;.&lt;variable&gt;
configuration, to handle &lt;URL&gt;s with '/' in them correctly.

* bc/wildcard-credential:
  credential: fix matching URLs with multiple levels in path
</content>
</entry>
</feed>
