diff --git a/config.go b/config.go index c5dba8c..9d64c0d 100644 --- a/config.go +++ b/config.go @@ -163,14 +163,23 @@ func (c *Config) readConfig() error { log.Printf("Setting log level to '%s'", stringLevel) } - for _, s := range []string{"jwtIssuer", "JwtPrivateKey", "JwtSignatureAlg", "s3Inbox"} { + if viper.GetString("s3Inbox") == "" { + return fmt.Errorf("%s not set", "s3Inbox") + } + + // no need to check the variables for JWT generation if we won't use it + if (cega.ID == "" && cega.Secret == "") && !c.ResignJwt { + return nil + } + + for _, s := range []string{"jwtIssuer", "JwtPrivateKey", "JwtSignatureAlg"} { if viper.GetString(s) == "" { return fmt.Errorf("%s not set", s) } } if _, err := os.Stat(c.JwtPrivateKey); errors.Is(err, os.ErrNotExist) { - return fmt.Errorf("Missing private key file, reason: '%s'", err) + return fmt.Errorf("missing private key file, reason: '%s'", err.Error()) } return nil diff --git a/config_test.go b/config_test.go index 9a2d22b..7cd0ea8 100644 --- a/config_test.go +++ b/config_test.go @@ -202,5 +202,14 @@ func (suite *ConfigTests) TestConfig() { // re-read the config _, err = NewConfig() - assert.ErrorContains(suite.T(), err, "Missing private key file") + assert.ErrorContains(suite.T(), err, "missing private key file") + + // Repeat check with CEGA login and JWT resigning disabled + os.Setenv("CEGA_ID", "") + os.Setenv("CEGA_SECRET", "") + os.Setenv("RESIGNJWT", fmt.Sprintf("%t", false)) + + // re-read the config + _, err = NewConfig() + assert.NoError(suite.T(), err) } diff --git a/dev-server/oidc/server.js b/dev-server/oidc/server.js index 3b3e114..04593b8 100644 --- a/dev-server/oidc/server.js +++ b/dev-server/oidc/server.js @@ -22,7 +22,7 @@ const oidcConfig = { revocation: true, sessionManagement: false }, - format: { + formats: { default: 'jwt', AccessToken: 'jwt', RefreshToken: 'jwt' diff --git a/main.go b/main.go index 6bd3842..97d0c19 100644 --- a/main.go +++ b/main.go @@ -50,7 +50,7 @@ func (auth AuthHandler) getInboxConfig(ctx iris.Context, authType string) { } s3cfmap := s3conf.(map[string]string) ctx.ResponseWriter().Header().Set("Content-Disposition", "attachment; filename=s3cmd.conf") - var s3c string + var s3c string = "[default]\n" for k, v := range s3cfmap { entry := fmt.Sprintf("%s = %s\n", k, v) @@ -239,7 +239,7 @@ func (auth AuthHandler) elixirLogin(ctx iris.Context) *OIDCData { code := ctx.Request().URL.Query().Get("code") idStruct, err := authenticateWithOidc(auth.OAuth2Config, auth.OIDCProvider, code, auth.Config.Elixir.jwkURL) if err != nil { - log.WithFields(log.Fields{"authType": "elixir"}).Errorf("Auhentication failed: %s", err) + log.WithFields(log.Fields{"authType": "elixir"}).Errorf("Authentication failed: %s", err) _, err := ctx.Writef("Authentication failed. You may need to clear your session cookies and try again.") if err != nil { log.Error("Failed to write response: ", err)