Skip to content

Commit

Permalink
Rename the public key configuration field to PublicKey
Browse files Browse the repository at this point in the history
This change makes the gitserver config match the Puppet config.
  • Loading branch information
lhchavez committed Jul 14, 2019
1 parent 8de50d7 commit b69170c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/omegaup-gitserver/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ 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,
secretToken: config.Gitserver.SecretToken,
}
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")
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/omegaup-gitserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand All @@ -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
}
Expand Down

0 comments on commit b69170c

Please sign in to comment.