[Feature]: support git auth token configuration in GitSkillRepository
When i use GitSkillRepository to load skill, but my git project is private, i can't clone or pull it correctly.
So GitSkillRepository should support git auth configuration.
Why System-Level Authentication?
- Security (Zero Trust): Hardcoding tokens or passwords in source code risks leakage via version control history or logs. System-level authentication keeps secrets managed by the OS or environment, completely out of the codebase.
- Decoupling: Authentication is an infrastructure concern, not application logic. This design allows you to rotate keys, change permissions, or switch auth methods (HTTPS vs SSH) without modifying, recompiling, or redeploying the application.
- Consistency ("It Just Works"): It ensures behavior consistency between the application and the terminal. If you can run
git clonein your environment, the Java application will work automatically without additional configuration.
Solutions
Option 1: HTTPS (Recommended for Personal Access Tokens)
Use this if your URL looks like: https://github.com/org/repo.git
-
Enable Credential Storage: Run this in the environment where the Java app will run:
git config --global credential.helper store(Note: This saves credentials to
~/.git-credentialswhich JGit can read. System pop-ups like macOS Keychain may not work with JGit) -
Cache Credentials: Manually perform one git operation to save the credentials:
git clone https://github.com/your-org/private-repo.git # Enter Username # Enter Password (Use your Personal Access Token, NOT your login password)
The application will now automatically authenticate using the stored credentials.
Option 2: SSH (Recommended for Servers / Deployments)
Use this if your URL looks like: [email protected]:org/repo.git
-
Setup SSH Keys: Ensure your private key (e.g.,
~/.ssh/id_rsa) exists and has correct permissions:chmod 600 ~/.ssh/id_rsaAdd the public key to your repository's Deploy Keys or User Settings.
-
Trust the Host (Critical for JGit): JGit is strict about host verification and will fail if the host is unknown. You must add the server to
known_hostsmanually once:ssh -T [email protected] # Type 'yes' when asked "Are you sure you want to continue connecting?"
Docker / CI Environments
- HTTPS: Mount the host's
.gitconfigand.git-credentialsto the container's user home (e.g.,/root/). - SSH: Mount the
~/.sshdirectory to the container.