From dd74d945d3936420b49acb3ed7434748714ba91a Mon Sep 17 00:00:00 2001 From: lhchavez Date: Mon, 22 Jul 2019 23:12:23 +0000 Subject: [PATCH] Add a flag to skip all authorization checks This change adds a flag (`-insecure-skip-authorization`) that allows all users to do all actions. This should only be used in the omegaUp frontend unit tests. --- cmd/omegaup-gitserver/auth.go | 2 +- cmd/omegaup-gitserver/main.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/omegaup-gitserver/auth.go b/cmd/omegaup-gitserver/auth.go index 987b16a..c10a64b 100644 --- a/cmd/omegaup-gitserver/auth.go +++ b/cmd/omegaup-gitserver/auth.go @@ -304,7 +304,7 @@ func (a *omegaupAuthorization) authorize( } requestContext := request.FromContext(ctx) - if username == "omegaup:system" { + if username == "omegaup:system" || *insecureSkipAuthorization { // This is the frontend, and we trust it completely. requestContext.IsAdmin = true requestContext.CanView = true diff --git a/cmd/omegaup-gitserver/main.go b/cmd/omegaup-gitserver/main.go index 4b2465f..60f1508 100644 --- a/cmd/omegaup-gitserver/main.go +++ b/cmd/omegaup-gitserver/main.go @@ -27,6 +27,11 @@ var ( "/etc/omegaup/gitserver/config.json", "gitserver configuration file", ) + insecureSkipAuthorization = flag.Bool( + "insecure-skip-authorization", + false, + "grant all privileges to all users", + ) version = flag.Bool("version", false, "Print the version and exit") log log15.Logger