New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gitolite: wrap gitolite-shell #75005
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import ./make-test-python.nix ( | ||
{ pkgs, ... }: | ||
|
||
let | ||
user = "gitolite-admin"; | ||
password = "some_password"; | ||
|
||
# not used but needed to setup gitolite | ||
adminPublicKey = '' | ||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO7urFhAA90BTpGuEHeWWTY3W/g9PBxXNxfWhfbrm4Le root@client | ||
''; | ||
in | ||
{ | ||
name = "gitolite-fcgiwrap"; | ||
|
||
meta = with pkgs.stdenv.lib.maintainers; { | ||
maintainers = [ bbigras ]; | ||
}; | ||
|
||
nodes = { | ||
|
||
server = | ||
{ ... }: | ||
{ | ||
networking.firewall.allowedTCPPorts = [ 80 ]; | ||
|
||
services.fcgiwrap.enable = true; | ||
services.gitolite = { | ||
enable = true; | ||
adminPubkey = adminPublicKey; | ||
}; | ||
|
||
services.nginx = { | ||
enable = true; | ||
recommendedProxySettings = true; | ||
virtualHosts."server".locations."/git".extraConfig = '' | ||
# turn off gzip as git objects are already well compressed | ||
gzip off; | ||
|
||
# use file based basic authentication | ||
auth_basic "Git Repository Authentication"; | ||
auth_basic_user_file /etc/gitolite/htpasswd; | ||
|
||
# common FastCGI parameters are required | ||
include ${pkgs.nginx}/conf/fastcgi_params; | ||
|
||
# strip the CGI program prefix | ||
fastcgi_split_path_info ^(/git)(.*)$; | ||
fastcgi_param PATH_INFO $fastcgi_path_info; | ||
|
||
# pass authenticated user login(mandatory) to Gitolite | ||
fastcgi_param REMOTE_USER $remote_user; | ||
|
||
# pass git repository root directory and hosting user directory | ||
# these env variables can be set in a wrapper script | ||
fastcgi_param GIT_HTTP_EXPORT_ALL ""; | ||
fastcgi_param GIT_PROJECT_ROOT /var/lib/gitolite/repositories; | ||
fastcgi_param GITOLITE_HTTP_HOME /var/lib/gitolite; | ||
fastcgi_param SCRIPT_FILENAME ${pkgs.gitolite}/bin/gitolite-shell; | ||
|
||
# use Unix domain socket or inet socket | ||
fastcgi_pass unix:/run/fcgiwrap.sock; | ||
''; | ||
}; | ||
|
||
# WARNING: DON'T DO THIS IN PRODUCTION! | ||
# This puts unhashed secrets directly into the Nix store for ease of testing. | ||
environment.etc."gitolite/htpasswd".source = pkgs.runCommand "htpasswd" {} '' | ||
${pkgs.apacheHttpd}/bin/htpasswd -bc "$out" ${user} ${password} | ||
''; | ||
}; | ||
|
||
client = | ||
{ pkgs, ... }: | ||
{ | ||
environment.systemPackages = [ pkgs.git ]; | ||
}; | ||
}; | ||
|
||
testScript = '' | ||
start_all() | ||
|
||
server.wait_for_unit("gitolite-init.service") | ||
server.wait_for_unit("nginx.service") | ||
server.wait_for_file("/run/fcgiwrap.sock") | ||
|
||
client.wait_for_unit("multi-user.target") | ||
client.succeed( | ||
"git clone http://${user}:${password}@server/git/gitolite-admin.git" | ||
) | ||
''; | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw those comments were copy/pasted from some gist. I hope it's still fine.