Skip to content

Instantly share code, notes, and snippets.

@lopesivan
Forked from meineerde/gist:3654353
Created April 14, 2014 13:15
Show Gist options
  • Save lopesivan/10646779 to your computer and use it in GitHub Desktop.
Save lopesivan/10646779 to your computer and use it in GitHub Desktop.
# This config requires the HTTP Auth Request module
# http://mdounin.ru/hg/ngx_http_auth_request_module/
set $chiliproject_key "supersecret";
# set write permission to commit_access
set $chiliproject_permission "commit_access"
location ~ "^/sys/projects/[^/]/auth(/.*)?" {
# Clean up the request to please the http_auth_request module.
proxy_pass_request_body off;
proxy_set_header Content-Length "";
}
########################################################################
# SUBVERSION
########################################################################
# if we have a read-only request, check browse_repository instead
if ( $request_method =~ "GET|HEAD|PROPFIND|REPORT|OPTIONS" ) {
set $chiliproject_permission "browse_repository";
}
location ~ "^/svn/([^/]+)" {
set $project $1;
auth_request /sys/projects/$project/auth?key=$chiliproject_key&permission=$chiliproject_permission;
}
########################################################################
# GIT
########################################################################
# if we have a read-only request, check browse_repository instead
location ~ "^/git/([^/]+)/*[^/]+/+(info/refs\?service=)?git\-receive\-pack$" {
set $chiliproject_permission "browse_repository";
}
location ~ "^/git/([^/]+)" {
set $project $1;
auth_request /sys/projects/$project/auth?key=$chiliproject_key&permission=$chiliproject_permission;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment