summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lang/en.lua11
-rw-r--r--lib/gitano/auth.lua26
2 files changed, 25 insertions, 12 deletions
diff --git a/lang/en.lua b/lang/en.lua
index 5f78a37..6cf6720 100644
--- a/lang/en.lua
+++ b/lang/en.lua
@@ -118,4 +118,15 @@ example administration repository rules and an admin user and group.
VERIFY_NEW_GITANO_ADMIN = "Verifying new gitano-admin master",
LOOKS_OKAY = "Looks okay",
VERIFY_NEW_ADMIN_SHA = "Verifying new admin sha: ${sha}",
+
+ -- Messages from the auth module
+ ERROR_PARSING_COMMAND = "Error parsing command",
+ ERROR_COULD_NOT_LOAD_CONFIG = "Couldn't load a config from the admin repository",
+ CLIENT_CONNECTED = "Client connected from ${ip} as ${user} (${key}), Executing command: ${cmdline}",
+ ERROR_UNKNOWN_COMMAND = "Unknown command: ${cmd}",
+ ERROR_VALIDATION_FAILED = "Validation of command line failed",
+ ERROR_RULESET_UNCLEAN = "Ruleset did not complete cleanly",
+ RULESET_ALLOWED = "Ruleset permitted action",
+ RULESET_DENIED = "Ruleset denied action. Sorry.",
+
}
diff --git a/lib/gitano/auth.lua b/lib/gitano/auth.lua
index f26dd55..11d74a4 100644
--- a/lib/gitano/auth.lua
+++ b/lib/gitano/auth.lua
@@ -3,6 +3,7 @@ local command = require 'gitano.command'
local log = require 'gitano.log'
local repository = require 'gitano.repository'
local util = require 'gitano.util'
+local i18n = require 'gitano.i18n'
local gall = require 'gall'
local luxio = require 'luxio'
@@ -11,21 +12,21 @@ local function load_admin_conf(repo_root)
"/gitano-admin.git")
if not admin_repo then
- log.critical("Unable to locate administration repository.")
+ log.critical(i18n.expand("ERROR_CANNOT_FIND_ADMIN_REPO"))
return nil
end
local admin_head = admin_repo:get(admin_repo.HEAD)
if not admin_head then
- log.critical("Unable to find the HEAD of the administration repository.")
+ log.critical(i18n.expand("ERROR_BAD_ADMIN_REPO"))
return nil
end
local admin_conf, msg = config.parse(admin_head)
if not admin_conf then
- log.critical("Unable to parse administration repository.")
+ log.critical(i18n.expand("ERROR_CANNOT_PARSE_ADMIN"))
log.critical(" * " .. (msg or "No error?"))
return nil
end
@@ -66,13 +67,13 @@ local function is_authorized(user, source, cmdline, repo_root,
local parsed_cmdline, warnings = util.parse_cmdline(cmdline)
if (#warnings > 0) then
- log.error("Error parsing command");
+ log.error(i18n.expand("ERROR_PARSING_COMMAND"))
return nil
end
local admin_conf = load_admin_conf(repo_root)
if admin_conf == nil then
- log.fatal("Couldn't load a config from the admin repository")
+ log.fatal(i18n.expand("ERROR_COULD_NOT_LOAD_CONFIG"))
end
if admin_conf.groups["gitano-admin"].filtered_members[user] then
@@ -84,13 +85,14 @@ local function is_authorized(user, source, cmdline, repo_root,
end
ip = os.getenv("REMOTE_ADDR") or "unknown ip"
- log.syslog.info("Client connected from", ip, "as", user,
- "(" .. keytag .. ")", "Executing command:", cmdline)
+ log.syslog.info(
+ i18n.expand("CLIENT_CONNECTED",
+ { ip=ip, user=user, key=keytag, cmdline=cmdline}))
local cmd = command.get(parsed_cmdline[1])
if not cmd then
- log.critical("Unknown command: " .. parsed_cmdline[1])
+ log.critical(i18n.expand("ERROR_UNKNOWN_COMMAND", {cmd=parsed_cmdline[1]}))
return nil
end
@@ -103,7 +105,7 @@ local function is_authorized(user, source, cmdline, repo_root,
end
if not cmd.validate(admin_conf, repo, parsed_cmdline) then
- log.critical("Validation of command line failed")
+ log.critical(i18n.expand("ERROR_VALIDATION_FAILED"))
return nil
end
@@ -112,18 +114,18 @@ local function is_authorized(user, source, cmdline, repo_root,
if not action then
log.critical(reason)
- log.critical("Ruleset did not complete cleanly")
+ log.critical(i18n.expand("ERROR_RULESET_UNCLEAN"))
return nil
end
local env
if action == "allow" then
- log.info(reason or "Ruleset permitted action")
+ log.info(reason or i18n.expand("RULESET_ALLOWED"))
authorized = true
env = set_environment(repo_root, repo, context, transactionid)
else
log.critical(reason)
- log.critical("Ruleset denied action. Sorry.")
+ log.critical(i18n.expand("RULESET_DENIED"))
end
return authorized, cmd, parsed_cmdline, admin_conf, env, repo