|
| 1 | +# Configuration Guide |
| 2 | + |
| 3 | +The Jetty-based GitProxy server supports configuration via YAML files. This allows you to configure providers, filters, and other server settings without modifying code. |
| 4 | + |
| 5 | +## Configuration Files |
| 6 | + |
| 7 | +The server loads configuration from the following files in order: |
| 8 | +1. `src/main/resources/application.yml` - Base configuration |
| 9 | +2. `src/main/resources/application-local.yml` - Local overrides (merged with base) |
| 10 | + |
| 11 | +Configuration from `application-local.yml` will override or extend settings from `application.yml`. |
| 12 | + |
| 13 | +## Server Configuration |
| 14 | + |
| 15 | +```yaml |
| 16 | +server: |
| 17 | + port: 8080 # HTTP port for the server |
| 18 | +``` |
| 19 | +
|
| 20 | +## Provider Configuration |
| 21 | +
|
| 22 | +Providers define the Git hosting services that the proxy will forward requests to. |
| 23 | +
|
| 24 | +### Built-in Providers |
| 25 | +
|
| 26 | +The following providers are built-in: |
| 27 | +- `github` - GitHub (https://github.com) |
| 28 | +- `gitlab` - GitLab (https://gitlab.com) |
| 29 | +- `bitbucket` - Bitbucket (https://bitbucket.org) |
| 30 | + |
| 31 | +### Example Provider Configuration |
| 32 | + |
| 33 | +```yaml |
| 34 | +git-proxy: |
| 35 | + base-path: "/git" # Optional base path for all servlets |
| 36 | + providers: |
| 37 | + github: |
| 38 | + enabled: true |
| 39 | + gitlab: |
| 40 | + enabled: true |
| 41 | + servlet-path: /custom-gitlab # Optional custom path |
| 42 | + bitbucket: |
| 43 | + enabled: false |
| 44 | + # Custom provider example |
| 45 | + internal-github: |
| 46 | + enabled: true |
| 47 | + servlet-path: /enterprise-github |
| 48 | + uri: https://githubserver.example.com |
| 49 | +``` |
| 50 | + |
| 51 | +### Provider Options |
| 52 | + |
| 53 | +- `enabled` (boolean): Enable/disable the provider |
| 54 | +- `uri` (string): Custom URI for the provider (for self-hosted instances) |
| 55 | +- `servlet-path` (string): Custom servlet path (default is based on provider name) |
| 56 | +- `log-proxy` (boolean): Enable proxy logging (default: true) |
| 57 | +- `connect-timeout` (int): Connection timeout in milliseconds (default: -1, no timeout) |
| 58 | +- `read-timeout` (int): Read timeout in milliseconds (default: -1, no timeout) |
| 59 | + |
| 60 | +## Filter Configuration |
| 61 | + |
| 62 | +Filters control access to repositories and enforce policies. |
| 63 | + |
| 64 | +### GitHub User Authentication Filter |
| 65 | + |
| 66 | +Requires authentication for GitHub operations. |
| 67 | + |
| 68 | +```yaml |
| 69 | +git-proxy: |
| 70 | + filters: |
| 71 | + github-user-authenticated: |
| 72 | + enabled: true |
| 73 | + order: 1 |
| 74 | + operations: |
| 75 | + - PUSH |
| 76 | + required-auth-schemes: bearer, token, basic # Can be comma-separated or list |
| 77 | + providers: |
| 78 | + - github |
| 79 | +``` |
| 80 | + |
| 81 | +Options: |
| 82 | +- `enabled` (boolean): Enable/disable the filter |
| 83 | +- `order` (int): Filter execution order (lower numbers run first) |
| 84 | +- `operations` (list): Git operations to apply filter to (PUSH, FETCH) |
| 85 | +- `required-auth-schemes` (string or list): Required authentication schemes (bearer, token, basic) |
| 86 | +- `providers` (list): Provider names to apply filter to |
| 87 | + |
| 88 | +### Whitelist Filters |
| 89 | + |
| 90 | +Control which repositories can be accessed. |
| 91 | + |
| 92 | +```yaml |
| 93 | +git-proxy: |
| 94 | + filters: |
| 95 | + whitelists: |
| 96 | + - enabled: true |
| 97 | + order: 5 |
| 98 | + operations: |
| 99 | + - FETCH |
| 100 | + - PUSH |
| 101 | + providers: |
| 102 | + - github |
| 103 | + slugs: |
| 104 | + - coopernetes/test-repo |
| 105 | + - finos/git-proxy |
| 106 | + - enabled: true |
| 107 | + order: 10 |
| 108 | + operations: |
| 109 | + - PUSH |
| 110 | + providers: |
| 111 | + - gitlab |
| 112 | + owners: |
| 113 | + - finosfoundation |
| 114 | + - enabled: true |
| 115 | + order: 20 |
| 116 | + operations: |
| 117 | + - FETCH |
| 118 | + providers: |
| 119 | + - github |
| 120 | + names: |
| 121 | + - hello-world |
| 122 | +``` |
| 123 | + |
| 124 | +Options: |
| 125 | +- `enabled` (boolean): Enable/disable the filter |
| 126 | +- `order` (int): Filter execution order |
| 127 | +- `operations` (list): Git operations to apply filter to (PUSH, FETCH) |
| 128 | +- `providers` (list): Provider names to apply filter to |
| 129 | +- `slugs` (list): Repository slugs (owner/repo) to whitelist |
| 130 | +- `owners` (list): Repository owners to whitelist |
| 131 | +- `names` (list): Repository names to whitelist |
| 132 | + |
| 133 | +Note: You can use `slugs`, `owners`, and `names` together in a single whitelist entry, or separately for more granular control. |
| 134 | + |
| 135 | +## Running the Server |
| 136 | + |
| 137 | +```bash |
| 138 | +# Build the application |
| 139 | +./gradlew build |
| 140 | +
|
| 141 | +# Run the application |
| 142 | +./gradlew run |
| 143 | +
|
| 144 | +# Or run the JAR directly |
| 145 | +java -jar build/libs/jgit-proxy-*.jar |
| 146 | +``` |
| 147 | + |
| 148 | +The server will read configuration from the YAML files and start with the configured providers and filters. |
| 149 | + |
| 150 | +## Example Usage |
| 151 | + |
| 152 | +Once the server is running, you can use it as a proxy for Git operations: |
| 153 | + |
| 154 | +```bash |
| 155 | +# Clone via proxy |
| 156 | +git clone http://localhost:8080/github.com/finos/git-proxy.git |
| 157 | +
|
| 158 | +# Clone from GitLab via proxy |
| 159 | +git clone http://localhost:8080/gitlab.com/coopernetes/test-repo.git |
| 160 | +
|
| 161 | +# Clone from custom provider |
| 162 | +git clone http://localhost:8080/debian/salsa/test-repo.git |
| 163 | +``` |
| 164 | + |
| 165 | +## Logging |
| 166 | + |
| 167 | +The application uses SLF4J with Logback. You can configure logging levels in the YAML files: |
| 168 | + |
| 169 | +```yaml |
| 170 | +logging: |
| 171 | + level: |
| 172 | + org.finos.gitproxy: DEBUG |
| 173 | + org.finos.gitproxy.git: DEBUG |
| 174 | +``` |
0 commit comments