agentscope-java icon indicating copy to clipboard operation
agentscope-java copied to clipboard

[Feature]: support git auth token configuration in GitSkillRepository

Open tcsp opened this issue 9 months ago • 1 comments

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.

tcsp avatar Feb 26 '26 08:02 tcsp

Why System-Level Authentication?

  1. 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.
  2. 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.
  3. Consistency ("It Just Works"): It ensures behavior consistency between the application and the terminal. If you can run git clone in 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

  1. 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-credentials which JGit can read. System pop-ups like macOS Keychain may not work with JGit)

  2. 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

  1. Setup SSH Keys: Ensure your private key (e.g., ~/.ssh/id_rsa) exists and has correct permissions:

    chmod 600 ~/.ssh/id_rsa
    

    Add the public key to your repository's Deploy Keys or User Settings.

  2. 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_hosts manually 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 .gitconfig and .git-credentials to the container's user home (e.g., /root/).
  • SSH: Mount the ~/.ssh directory to the container.

fang-tech avatar Feb 27 '26 06:02 fang-tech