From b69170c3b9abded4bd5b4e9c587f29dac557d0fb Mon Sep 17 00:00:00 2001 From: lhchavez Date: Sun, 14 Jul 2019 17:04:52 +0000 Subject: [PATCH] Rename the public key configuration field to PublicKey This change makes the gitserver config match the Puppet config. --- cmd/omegaup-gitserver/auth.go | 4 ++-- cmd/omegaup-gitserver/config.go | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/omegaup-gitserver/auth.go b/cmd/omegaup-gitserver/auth.go index 36375fc..0ed5f01 100644 --- a/cmd/omegaup-gitserver/auth.go +++ b/cmd/omegaup-gitserver/auth.go @@ -154,7 +154,7 @@ func (a *secretTokenAuthorization) authorize( } func createAuthorizationCallback(config *Config, log log15.Logger) (githttp.AuthorizationCallback, error) { - if config.Gitserver.PublicKeyBase64 == "" && config.Gitserver.SecretToken != "" { + if config.Gitserver.PublicKey == "" && config.Gitserver.SecretToken != "" { log.Warn("using insecure secret token authorization") auth := secretTokenAuthorization{ log: log, @@ -162,7 +162,7 @@ func createAuthorizationCallback(config *Config, log log15.Logger) (githttp.Auth } return auth.authorize, nil } - keyBytes, err := base64.StdEncoding.DecodeString(config.Gitserver.PublicKeyBase64) + keyBytes, err := base64.StdEncoding.DecodeString(config.Gitserver.PublicKey) if err != nil { return nil, errors.Wrap(err, "failed to parse the base64-encoded public key") } diff --git a/cmd/omegaup-gitserver/config.go b/cmd/omegaup-gitserver/config.go index 76f45f9..2f8f40a 100644 --- a/cmd/omegaup-gitserver/config.go +++ b/cmd/omegaup-gitserver/config.go @@ -22,9 +22,9 @@ type GitserverConfig struct { // RootPath is the root path of all repositories. RootPath string - // PublicKeyBase64 is the base64-encoded public key of the omegaUp frontend. + // PublicKey is the base64-encoded public key of the omegaUp frontend. // Used for verifying Paseto tokens. - PublicKeyBase64 string + PublicKey string // SecretToken is a shared secret with the frontend that can be used to // authenticate instead of using PKI for speeding up tests. @@ -62,7 +62,7 @@ var defaultConfig = Config{ }, Gitserver: GitserverConfig{ RootPath: "/var/lib/omegaup/problems.git", - PublicKeyBase64: "gKEg5JlIOA1BsIxETZYhjd+ZGchY/rZeQM0GheAWvXw=", + PublicKey: "gKEg5JlIOA1BsIxETZYhjd+ZGchY/rZeQM0GheAWvXw=", SecretToken: "", Port: 33861, PprofPort: 33862, @@ -82,6 +82,7 @@ func NewConfig(reader io.Reader) (*Config, error) { // Read basic config decoder := json.NewDecoder(reader) + decoder.DisallowUnknownFields() if err := decoder.Decode(&config); err != nil { return nil, err }