Skip to content

Commit

Permalink
Merge branch 'jk/credentials'
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Junio C Hamano committed Dec 20, 2011
2 parents d165204 + 861444f commit 367d20e
Show file tree
Hide file tree
Showing 28 changed files with 2,427 additions and 100 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
/git-commit-tree
/git-config
/git-count-objects
/git-credential-cache
/git-credential-cache--daemon
/git-credential-store
/git-cvsexportcommit
/git-cvsimport
/git-cvsserver
Expand Down Expand Up @@ -167,6 +170,7 @@
/gitweb/static/gitweb.js
/gitweb/static/gitweb.min.*
/test-chmtime
/test-credential
/test-ctype
/test-date
/test-delta
Expand Down
1 change: 1 addition & 0 deletions Documentation/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt \
MAN7_TXT=gitcli.txt gittutorial.txt gittutorial-2.txt \
gitcvs-migration.txt gitcore-tutorial.txt gitglossary.txt \
gitdiffcore.txt gitnamespaces.txt gitrevisions.txt gitworkflows.txt
MAN7_TXT += gitcredentials.txt

MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))
Expand Down
23 changes: 23 additions & 0 deletions Documentation/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,29 @@ commit.template::
"{tilde}/" is expanded to the value of `$HOME` and "{tilde}user/" to the
specified user's home directory.

credential.helper::
Specify an external helper to be called when a username or
password credential is needed; the helper may consult external
storage to avoid prompting the user for the credentials. See
linkgit:gitcredentials[7] for details.

credential.useHttpPath::
When acquiring credentials, consider the "path" component of an http
or https URL to be important. Defaults to false. See
linkgit:gitcredentials[7] for more information.

credential.username::
If no username is set for a network authentication, use this username
by default. See credential.<context>.* below, and
linkgit:gitcredentials[7].

credential.<url>.*::
Any of the credential.* options above can be applied selectively to
some credentials. For example "credential.https://example.com.username"
would set the default username only for https connections to
example.com. See linkgit:gitcredentials[7] for details on how URLs are
matched.

include::diff-config.txt[]

difftool.<tool>.path::
Expand Down
26 changes: 26 additions & 0 deletions Documentation/git-credential-cache--daemon.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
git-credential-cache--daemon(1)
===============================

NAME
----
git-credential-cache--daemon - temporarily store user credentials in memory

SYNOPSIS
--------
[verse]
git credential-cache--daemon <socket>

DESCRIPTION
-----------

NOTE: You probably don't want to invoke this command yourself; it is
started automatically when you use linkgit:git-credential-cache[1].

This command listens on the Unix domain socket specified by `<socket>`
for `git-credential-cache` clients. Clients may store and retrieve
credentials. Each credential is held for a timeout specified by the
client; once no credentials are held, the daemon exits.

GIT
---
Part of the linkgit:git[1] suite
77 changes: 77 additions & 0 deletions Documentation/git-credential-cache.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
git-credential-cache(1)
=======================

NAME
----
git-credential-cache - helper to temporarily store passwords in memory

SYNOPSIS
--------
-----------------------------
git config credential.helper 'cache [options]'
-----------------------------

DESCRIPTION
-----------

This command caches credentials in memory for use by future git
programs. The stored credentials never touch the disk, and are forgotten
after a configurable timeout. The cache is accessible over a Unix
domain socket, restricted to the current user by filesystem permissions.

You probably don't want to invoke this command directly; it is meant to
be used as a credential helper by other parts of git. See
linkgit:gitcredentials[7] or `EXAMPLES` below.

OPTIONS
-------

--timeout <seconds>::

Number of seconds to cache credentials (default: 900).

--socket <path>::

Use `<path>` to contact a running cache daemon (or start a new
cache daemon if one is not started). Defaults to
`~/.git-credential-cache/socket`. If your home directory is on a
network-mounted filesystem, you may need to change this to a
local filesystem.

CONTROLLING THE DAEMON
----------------------

If you would like the daemon to exit early, forgetting all cached
credentials before their timeout, you can issue an `exit` action:

--------------------------------------
git credential-cache exit
--------------------------------------

EXAMPLES
--------

The point of this helper is to reduce the number of times you must type
your username or password. For example:

------------------------------------
$ git config credential.helper cache
$ git push http://example.com/repo.git
Username: <type your username>
Password: <type your password>

[work for 5 more minutes]
$ git push http://example.com/repo.git
[your credentials are used automatically]
------------------------------------

You can provide options via the credential.helper configuration
variable (this example drops the cache time to 5 minutes):

-------------------------------------------------------
$ git config credential.helper 'cache --timeout=300'
-------------------------------------------------------

GIT
---
Part of the linkgit:git[1] suite
75 changes: 75 additions & 0 deletions Documentation/git-credential-store.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
git-credential-store(1)
=======================

NAME
----
git-credential-store - helper to store credentials on disk

SYNOPSIS
--------
-------------------
git config credential.helper 'store [options]'
-------------------

DESCRIPTION
-----------

NOTE: Using this helper will store your passwords unencrypted on disk,
protected only by filesystem permissions. If this is not an acceptable
security tradeoff, try linkgit:git-credential-cache[1], or find a helper
that integrates with secure storage provided by your operating system.

This command stores credentials indefinitely on disk for use by future
git programs.

You probably don't want to invoke this command directly; it is meant to
be used as a credential helper by other parts of git. See
linkgit:gitcredentials[7] or `EXAMPLES` below.

OPTIONS
-------

--store=<path>::

Use `<path>` to store credentials. The file will have its
filesystem permissions set to prevent other users on the system
from reading it, but will not be encrypted or otherwise
protected. Defaults to `~/.git-credentials`.

EXAMPLES
--------

The point of this helper is to reduce the number of times you must type
your username or password. For example:

------------------------------------------
$ git config credential.helper store
$ git push http://example.com/repo.git
Username: <type your username>
Password: <type your password>

[several days later]
$ git push http://example.com/repo.git
[your credentials are used automatically]
------------------------------------------

STORAGE FORMAT
--------------

The `.git-credentials` file is stored in plaintext. Each credential is
stored on its own line as a URL like:

------------------------------
https://user:pass@example.com
------------------------------

When git needs authentication for a particular URL context,
credential-store will consider that context a pattern to match against
each entry in the credentials file. If the protocol, hostname, and
username (if we already have one) match, then the password is returned
to git. See the discussion of configuration in linkgit:gitcredentials[7]
for more information.

GIT
---
Part of the linkgit:git[1] suite
Loading

0 comments on commit 367d20e

Please sign in to comment.