cleared out more janus stuff + .env

main
Gabe Farrell 3 years ago
parent c8697d6ef6
commit 62dbcd1135

2
.gitignore vendored

@ -0,0 +1,2 @@
.env*
!.env.local

@ -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 {

@ -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.Password = strings.TrimSpace(r.FormValue("password"))
// truncate extremely long passwords
if len(h.Password) > 128 {

@ -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
}

@ -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
}
}

@ -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")
}
Loading…
Cancel
Save