From 62dbcd113565b0a5638227fd40b7371e3e13a3eb Mon Sep 17 00:00:00 2001 From: Gabe Farrell Date: Tue, 16 May 2023 02:54:03 +0000 Subject: [PATCH] cleared out more janus stuff + .env --- .env.local | 0 .gitignore | 2 ++ server/auth/auth_long_test.go | 7 ------- server/auth/forms.go | 10 +++------- server/config/config.go | 23 ----------------------- server/config/dbconfig.go | 8 -------- server/config/mailconfig.go | 27 --------------------------- 7 files changed, 5 insertions(+), 72 deletions(-) create mode 100644 .env.local create mode 100644 .gitignore delete mode 100644 server/config/mailconfig.go diff --git a/.env.local b/.env.local new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a33eb25 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env* +!.env.local \ No newline at end of file diff --git a/server/auth/auth_long_test.go b/server/auth/auth_long_test.go index 21d51fc..4a6be6f 100644 --- a/server/auth/auth_long_test.go +++ b/server/auth/auth_long_test.go @@ -10,7 +10,6 @@ import ( "testing" "github.com/mnrva-dev/owltier.com/server/auth" - "github.com/mnrva-dev/owltier.com/server/config" "github.com/mnrva-dev/owltier.com/server/db" ) @@ -45,9 +44,6 @@ func TestRegister(t *testing.T) { defer ts.Close() data := url.Values{} data.Set("username", testuser.Username) - if config.UsernamesEnabled() { - data.Set("username", testuser.Username) - } data.Set("password", testuser.Password) resp, err := http.PostForm(fmt.Sprintf("%s/register", ts.URL), data) if err != nil { @@ -69,9 +65,6 @@ func TestLogin(t *testing.T) { defer ts.Close() data := url.Values{} data.Set("username", testuser.Username) - if config.UsernamesEnabled() { - data.Set("username", testuser.Username) - } data.Set("password", testuser.Password) resp, err := http.PostForm(fmt.Sprintf("%s/login", ts.URL), data) if err != nil { diff --git a/server/auth/forms.go b/server/auth/forms.go index 809f29d..8ae9bba 100644 --- a/server/auth/forms.go +++ b/server/auth/forms.go @@ -6,7 +6,6 @@ import ( "regexp" "strings" - "github.com/mnrva-dev/owltier.com/server/config" passwordvalidator "github.com/wagslane/go-password-validator" ) @@ -20,13 +19,13 @@ type RequestForm struct { } func (h *RequestForm) validate() error { - if h.Username == "" && config.UsernamesEnabled() { + if h.Username == "" { return errors.New("username is required") } if h.Password == "" { return errors.New("password is required") } - if !regexp.MustCompile(`^[a-zA-Z0-9-_]{3,24}$`).MatchString(h.Username) && config.UsernamesEnabled() { + if !regexp.MustCompile(`^[a-zA-Z0-9-_]{3,24}$`).MatchString(h.Username) { return errors.New("username is not valid") } return passwordvalidator.Validate(h.Password, minPasswordEntropy) @@ -37,10 +36,7 @@ func (h *RequestForm) Parse(r *http.Request) error { if err != nil { return err } - - if config.UsernamesEnabled() { - h.Username = strings.TrimSpace(r.FormValue("username")) - } + h.Username = strings.TrimSpace(r.FormValue("username")) h.Password = strings.TrimSpace(r.FormValue("password")) // truncate extremely long passwords if len(h.Password) > 128 { diff --git a/server/config/config.go b/server/config/config.go index 3e3ffa5..621be12 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -4,7 +4,6 @@ import ( "log" "os" "regexp" - "strings" "github.com/joho/godotenv" ) @@ -33,25 +32,3 @@ func Environment() string { func ListenAddr() string { return os.Getenv("LISTEN_ADDR") } - -func AccessSecret() []byte { - return []byte(os.Getenv("JWT_ACCESS_SECRET")) -} - -func RefreshSecret() []byte { - return []byte(os.Getenv("JWT_REFRESH_SECRET")) -} - -func EmailTokenSecret() []byte { - return []byte(os.Getenv("JWT_EMAIL_SECRET")) -} - -func JwtIssuer() string { - return os.Getenv("JWT_ISSUER") -} - -func JwtAudience() []string { - aud := os.Getenv("JWT_AUDIENCE") - audience := strings.Split(aud, ",") - return audience -} diff --git a/server/config/dbconfig.go b/server/config/dbconfig.go index 3ec94cf..34c982b 100644 --- a/server/config/dbconfig.go +++ b/server/config/dbconfig.go @@ -17,11 +17,3 @@ func DbGsiName() string { func DbGsiAttr() string { return os.Getenv("DB_GSI_ATTR") } - -func UsernamesEnabled() bool { - if os.Getenv("CFG_USERNAMES_ENABLED") == "true" { - return true - } else { - return false - } -} diff --git a/server/config/mailconfig.go b/server/config/mailconfig.go deleted file mode 100644 index 437fd99..0000000 --- a/server/config/mailconfig.go +++ /dev/null @@ -1,27 +0,0 @@ -package config - -import "os" - -func GoogleAccessToken() string { - return os.Getenv("GOOGLE_ACCESS_TOKEN") -} - -func GoogleRefreshToken() string { - return os.Getenv("GOOGLE_REFRESH_TOKEN") -} - -func GoogleClientID() string { - return os.Getenv("GOOGLE_CLIENT_ID") -} - -func GoogleClientSecret() string { - return os.Getenv("GOOGLE_CLIENT_SECRET") -} - -func AmazonSmtpUsername() string { - return os.Getenv("AMZN_SMTP_USERNAME") -} - -func AmazonSmtpPassword() string { - return os.Getenv("AMZN_SMTP_PASSWORD") -}