back to home

languitar / pass-git-helper

A git credential helper interfacing with pass, the standard unix password manager.

368 stars
24 forks
1 issues
Python

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing languitar/pass-git-helper in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/languitar/pass-git-helper)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

pass-git-helper A [git] credential helper implementation that allows using [pass] as the credential backend for your https-based git repositories. When [git] tries to interact with an https-based upstream and needs credentials, this helper will be called to look up the credentials from the user's password store. Instead of enforcing a specific layout of the password store, a configuration file with explicitly defining mappings between hosts and entries in the password store is used, giving full flexibility to the user on how to structure or reuse existing password databases for [git] authentication. pass-git-helper will use the mappings to find the correct entry in the user's password store based on the request URL and then provides [git] with the credentials from this entry. Preconditions It is recommended to configure GPG to use a graphical pinentry program. That way, you can also use this helper when [git] is invoked via GUI programs such as your IDE. For a configuration example, refer to the ArchWiki. In case you really want to use the terminal for pinentry (via ), be sure to appropriately configure the environment variable , most likely by adding the following lines to your shell initialization: If you use this setup for remote work via SSH, also consider the alternative of GPG agent forwarding. Installation Official Packages If possible, use an available package for your Linux distribution or operating system such as the ones linked below. From Source This might potentially install Python packages without the knowledge of your system's package manager. If all package preconditions are already met, you can also copy the script file to to your system to avoid this problem: Another option is to install the script in an isolated virtualenv: Usage Configure git to use pass-git-helper To instruct git to use the helper, set the configuration option of git to . In case you do not want to include a full path, a workaround using a shell fragment needs to be used, i.e. must be the option value. The option can be set using the CLI with: This will result in the following contents in : In case you share the across multiple machines and is not available on all of them, the following version does not bail out if pass git helper is missing: can be combined with other helpers. For instance, the following configuration first tries the git built-in helper for in-memory password access before falling back to if a cache miss occurs: Define Mappings Create the file . This file uses ini syntax to specify the mapping of hosts to entries in the password store database. The first matching mapping from the configuration file is used to select the entry from the password store database. This search process is based on the order of definition in the configuration file. Section headers define patterns which are matched against the host part of a URL with a git repository. Matching supports wildcards (using the python fnmatch module). Each section needs to contain a entry pointing to the entry in the password store with the password (and optionally username) to use. Example: If you want to match entries not only based on the host, but also based on the path on a host, set to in your git config, e.g. via: Afterwards, entries can be matched against in the mapping. This means that in order to use a specific account for a certain Github project, you can then use the following mapping pattern: Please note that when including the path in the mapping, the mapping expressions need to match against the whole path. As a consequence, in case you want to use the same account for all Github projects, you need to make sure that a wildcard covers the path of the URL, as shown here: The host can be used as a variable to address a pass entry. This is especially helpful for wildcard matches: The above configuration directive will lead to any host that did not match any previous section in the ini file to being looked up under the directory in your password store. Apart from , the variables , and can be used for replacements. Given the remote url , variables are filled as follow: | var | value | | --- | --- | | | | | | | | | | | | | DEFAULT Section Defaults suitable for all entries of the mapping file can be specified in a special section of the configuration file named . Everything configure in this section will automatically be available for all further entries in the file, but can be overridden there, too. Using Different Mappings Depending on the Working Directory Using the directive available in git >= 2.13, it is possible to perform matching based on the current working directory by invoking with a conditional . To achieve this, edit your , e.g. like this: With the following contents of (and respectively), , which could contain a entry to e.g. would always be invoked in : See also the official documentation for . Switching Password Stores per Mapping To select a different password store for certain entries, the configuration key can be set. If set, is directed to a different data directory by defining the environment variable when calling . The following config demonstrates this practices Password Store Layout and Data Extraction Password As usual with [pass], this helper assumes that the password is contained in the first line of the password store entry. Although uncommon, it is possible to strip a prefix from the data of the first line (such as by specifying an amount of characters to leave out in the field for an entry or also in the section to apply for all entries: However, other two strategies for extracting passwords are implemented, allowing for more flexibility in handling prefixes. The following strategies can be configured: Specific Line Extraction (default) Extracts the password from a specified line indexed by its line number. Optionally, a fixed-length prefix can be stripped before returning the line contents. Configuration: • : Line number containing the password,…