summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-01-29 11:32:40 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-02-10 15:03:59 +0000
commitf14acdf94156bce61f6ef5f4752af4500869a0c6 (patch)
tree2395a76712e5758a913b18c9a85474b9387c6fa9
parent89ac3e4f25d336be387347aa46508e2b0f904105 (diff)
downloadgitano-f14acdf94156bce61f6ef5f4752af4500869a0c6.tar.gz
Only set the env if we're going to auth
-rw-r--r--lib/gitano/auth.lua41
1 files changed, 24 insertions, 17 deletions
diff --git a/lib/gitano/auth.lua b/lib/gitano/auth.lua
index 3d57a09..9125987 100644
--- a/lib/gitano/auth.lua
+++ b/lib/gitano/auth.lua
@@ -7,6 +7,11 @@ local gall = require 'gall'
-- TODO: this must be split up, it is far too long
function is_authorized(user, cmdline)
+
+ if not user or not cmdline then
+ return nil
+ end
+
local repo_root = "/home/git/repos"
local username = user
local keytag = "default"
@@ -126,31 +131,33 @@ function is_authorized(user, cmdline)
log.critical("Ruleset did not complete cleanly")
end
+ local env
+
if action == "allow" then
log.info(reason or "Ruleset permitted action")
authorized = true
+
+ -- set env vars needed by gitano hooks
+ luxio.setenv("GITANO_ROOT", repo_root)
+ luxio.setenv("GITANO_USER", username)
+ luxio.setenv("GITANO_KEYTAG", keytag)
+ luxio.setenv("GITANO_PROJECT", (repo or {}).name or "")
+ luxio.setenv("GITANO_SOURCE", "http")
+ luxio.setenv("GITANO_TRANSACTION_ID", transactionid)
+
+ env = {
+ ["GITANO_ROOT"] = repo_root,
+ ["GITANO_USER"] = username,
+ ["GITANO_KEYTAG"] = keytag,
+ ["GITANO_PROJECT"] = (repo or {}).name,
+ ["GITANO_SOURCE"] = "ssh",
+ ["GITANO_TRANSACTION_ID"] = transactionid,
+ }
else
log.critical(reason)
log.critical("Ruleset denied action. Sorry.")
end
- -- set env vars needed by gitano hooks
- luxio.setenv("GITANO_ROOT", repo_root)
- luxio.setenv("GITANO_USER", username)
- luxio.setenv("GITANO_KEYTAG", keytag)
- luxio.setenv("GITANO_PROJECT", (repo or {}).name or "")
- luxio.setenv("GITANO_SOURCE", "http")
- luxio.setenv("GITANO_TRANSACTION_ID", transactionid)
-
- local env = {
- ["GITANO_ROOT"] = repo_root,
- ["GITANO_USER"] = username,
- ["GITANO_KEYTAG"] = keytag,
- ["GITANO_PROJECT"] = (repo or {}).name,
- ["GITANO_SOURCE"] = "ssh",
- ["GITANO_TRANSACTION_ID"] = transactionid,
- }
-
return authorized, cmd, parsed_cmdline, config, env
end