Skip to content

Commit 367d20e

Browse files
committed
Merge branch 'jk/credentials'
* jk/credentials: t: add test harness for external credential helpers credentials: add "store" helper strbuf: add strbuf_add*_urlencode Makefile: unix sockets may not available on some platforms credentials: add "cache" helper docs: end-user documentation for the credential subsystem credential: make relevance of http path configurable credential: add credential.*.username credential: apply helper config http: use credential API to get passwords credential: add function for parsing url components introduce credentials API t5550: fix typo test-lib: add test_config_global variant Conflicts: strbuf.c
2 parents d165204 + 861444f commit 367d20e

28 files changed

+2427
-100
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
/git-commit-tree
3131
/git-config
3232
/git-count-objects
33+
/git-credential-cache
34+
/git-credential-cache--daemon
35+
/git-credential-store
3336
/git-cvsexportcommit
3437
/git-cvsimport
3538
/git-cvsserver
@@ -167,6 +170,7 @@
167170
/gitweb/static/gitweb.js
168171
/gitweb/static/gitweb.min.*
169172
/test-chmtime
173+
/test-credential
170174
/test-ctype
171175
/test-date
172176
/test-delta

Documentation/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt \
77
MAN7_TXT=gitcli.txt gittutorial.txt gittutorial-2.txt \
88
gitcvs-migration.txt gitcore-tutorial.txt gitglossary.txt \
99
gitdiffcore.txt gitnamespaces.txt gitrevisions.txt gitworkflows.txt
10+
MAN7_TXT += gitcredentials.txt
1011

1112
MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
1213
MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))

Documentation/config.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,29 @@ commit.template::
834834
"{tilde}/" is expanded to the value of `$HOME` and "{tilde}user/" to the
835835
specified user's home directory.
836836

837+
credential.helper::
838+
Specify an external helper to be called when a username or
839+
password credential is needed; the helper may consult external
840+
storage to avoid prompting the user for the credentials. See
841+
linkgit:gitcredentials[7] for details.
842+
843+
credential.useHttpPath::
844+
When acquiring credentials, consider the "path" component of an http
845+
or https URL to be important. Defaults to false. See
846+
linkgit:gitcredentials[7] for more information.
847+
848+
credential.username::
849+
If no username is set for a network authentication, use this username
850+
by default. See credential.<context>.* below, and
851+
linkgit:gitcredentials[7].
852+
853+
credential.<url>.*::
854+
Any of the credential.* options above can be applied selectively to
855+
some credentials. For example "credential.https://example.com.username"
856+
would set the default username only for https connections to
857+
example.com. See linkgit:gitcredentials[7] for details on how URLs are
858+
matched.
859+
837860
include::diff-config.txt[]
838861

839862
difftool.<tool>.path::
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
git-credential-cache--daemon(1)
2+
===============================
3+
4+
NAME
5+
----
6+
git-credential-cache--daemon - temporarily store user credentials in memory
7+
8+
SYNOPSIS
9+
--------
10+
[verse]
11+
git credential-cache--daemon <socket>
12+
13+
DESCRIPTION
14+
-----------
15+
16+
NOTE: You probably don't want to invoke this command yourself; it is
17+
started automatically when you use linkgit:git-credential-cache[1].
18+
19+
This command listens on the Unix domain socket specified by `<socket>`
20+
for `git-credential-cache` clients. Clients may store and retrieve
21+
credentials. Each credential is held for a timeout specified by the
22+
client; once no credentials are held, the daemon exits.
23+
24+
GIT
25+
---
26+
Part of the linkgit:git[1] suite
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
git-credential-cache(1)
2+
=======================
3+
4+
NAME
5+
----
6+
git-credential-cache - helper to temporarily store passwords in memory
7+
8+
SYNOPSIS
9+
--------
10+
-----------------------------
11+
git config credential.helper 'cache [options]'
12+
-----------------------------
13+
14+
DESCRIPTION
15+
-----------
16+
17+
This command caches credentials in memory for use by future git
18+
programs. The stored credentials never touch the disk, and are forgotten
19+
after a configurable timeout. The cache is accessible over a Unix
20+
domain socket, restricted to the current user by filesystem permissions.
21+
22+
You probably don't want to invoke this command directly; it is meant to
23+
be used as a credential helper by other parts of git. See
24+
linkgit:gitcredentials[7] or `EXAMPLES` below.
25+
26+
OPTIONS
27+
-------
28+
29+
--timeout <seconds>::
30+
31+
Number of seconds to cache credentials (default: 900).
32+
33+
--socket <path>::
34+
35+
Use `<path>` to contact a running cache daemon (or start a new
36+
cache daemon if one is not started). Defaults to
37+
`~/.git-credential-cache/socket`. If your home directory is on a
38+
network-mounted filesystem, you may need to change this to a
39+
local filesystem.
40+
41+
CONTROLLING THE DAEMON
42+
----------------------
43+
44+
If you would like the daemon to exit early, forgetting all cached
45+
credentials before their timeout, you can issue an `exit` action:
46+
47+
--------------------------------------
48+
git credential-cache exit
49+
--------------------------------------
50+
51+
EXAMPLES
52+
--------
53+
54+
The point of this helper is to reduce the number of times you must type
55+
your username or password. For example:
56+
57+
------------------------------------
58+
$ git config credential.helper cache
59+
$ git push http://example.com/repo.git
60+
Username: <type your username>
61+
Password: <type your password>
62+
63+
[work for 5 more minutes]
64+
$ git push http://example.com/repo.git
65+
[your credentials are used automatically]
66+
------------------------------------
67+
68+
You can provide options via the credential.helper configuration
69+
variable (this example drops the cache time to 5 minutes):
70+
71+
-------------------------------------------------------
72+
$ git config credential.helper 'cache --timeout=300'
73+
-------------------------------------------------------
74+
75+
GIT
76+
---
77+
Part of the linkgit:git[1] suite
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
git-credential-store(1)
2+
=======================
3+
4+
NAME
5+
----
6+
git-credential-store - helper to store credentials on disk
7+
8+
SYNOPSIS
9+
--------
10+
-------------------
11+
git config credential.helper 'store [options]'
12+
-------------------
13+
14+
DESCRIPTION
15+
-----------
16+
17+
NOTE: Using this helper will store your passwords unencrypted on disk,
18+
protected only by filesystem permissions. If this is not an acceptable
19+
security tradeoff, try linkgit:git-credential-cache[1], or find a helper
20+
that integrates with secure storage provided by your operating system.
21+
22+
This command stores credentials indefinitely on disk for use by future
23+
git programs.
24+
25+
You probably don't want to invoke this command directly; it is meant to
26+
be used as a credential helper by other parts of git. See
27+
linkgit:gitcredentials[7] or `EXAMPLES` below.
28+
29+
OPTIONS
30+
-------
31+
32+
--store=<path>::
33+
34+
Use `<path>` to store credentials. The file will have its
35+
filesystem permissions set to prevent other users on the system
36+
from reading it, but will not be encrypted or otherwise
37+
protected. Defaults to `~/.git-credentials`.
38+
39+
EXAMPLES
40+
--------
41+
42+
The point of this helper is to reduce the number of times you must type
43+
your username or password. For example:
44+
45+
------------------------------------------
46+
$ git config credential.helper store
47+
$ git push http://example.com/repo.git
48+
Username: <type your username>
49+
Password: <type your password>
50+
51+
[several days later]
52+
$ git push http://example.com/repo.git
53+
[your credentials are used automatically]
54+
------------------------------------------
55+
56+
STORAGE FORMAT
57+
--------------
58+
59+
The `.git-credentials` file is stored in plaintext. Each credential is
60+
stored on its own line as a URL like:
61+
62+
------------------------------
63+
https://user:[email protected]
64+
------------------------------
65+
66+
When git needs authentication for a particular URL context,
67+
credential-store will consider that context a pattern to match against
68+
each entry in the credentials file. If the protocol, hostname, and
69+
username (if we already have one) match, then the password is returned
70+
to git. See the discussion of configuration in linkgit:gitcredentials[7]
71+
for more information.
72+
73+
GIT
74+
---
75+
Part of the linkgit:git[1] suite

0 commit comments

Comments
 (0)