diff --git a/changelog.md b/changelog.md index 4d94095..5ac6d72 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +## Version 0.9.9 + - Add new filters for routes based on method, query strings and headers (missing UI) + ## Version 0.9.1 > 0.9.8 - Fix subdomain logic for composed TLDs - Add option for custom wildcard domains diff --git a/client/src/pages/authentication/auth-forms/AuthRegister.jsx b/client/src/pages/authentication/auth-forms/AuthRegister.jsx index 688aae7..a46d95b 100644 --- a/client/src/pages/authentication/auth-forms/AuthRegister.jsx +++ b/client/src/pages/authentication/auth-forms/AuthRegister.jsx @@ -73,7 +73,7 @@ const AuthRegister = ({nickname, isRegister, isInviteLink, regkey}) => { .max(255) .required('Password is required') .matches( - /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[~!@#$%\^&\*\(\)_\+=\-\{\[\}\]:;"'<,>\.\/])(?=.{9,})/, + /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[~!@#$%\^&\*\(\)_\+=\-\{\[\}\]:;"'<,>\/])(?=.{9,})/, 'Must Contain 9 Characters, One Uppercase, One Lowercase, One Number and one special case Character (~!@#$%^&*()_+=-{[}]:;"\'<>.?/)' ), })} diff --git a/client/src/pages/newInstall/newInstall.jsx b/client/src/pages/newInstall/newInstall.jsx index 24bced7..dbd0a15 100644 --- a/client/src/pages/newInstall/newInstall.jsx +++ b/client/src/pages/newInstall/newInstall.jsx @@ -485,7 +485,7 @@ const NewInstall = () => { // nickname cant be admin or root nickname: Yup.string().required('Nickname is required').min(3).max(32) .matches(/^(?!admin|root).*$/, 'Nickname cannot be admin or root'), - password: Yup.string().required('Password is required').min(8).max(128).matches(/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[~!@#$%\^&\*\(\)_\+=\-\{\[\}\]:;"'<,>\.\/])(?=.{9,})/, 'Password must contain 9 characters: at least 1 lowercase, 1 uppercase, 1 number, and 1 special character'), + password: Yup.string().required('Password is required').min(8).max(128).matches(/^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[~!@#$%\^&\*\(\)_\+=\-\{\[\}\]:;"'<,>\/])(?=.{9,})/, 'Password must contain 9 characters: at least 1 lowercase, 1 uppercase, 1 number, and 1 special character'), email: Yup.string().email('Must be a valid email').max(255), confirmPassword: Yup.string().oneOf([Yup.ref('password'), null], 'Passwords must match'), })} diff --git a/client/src/utils/password-strength.jsx b/client/src/utils/password-strength.jsx index bb7eeb8..320058f 100644 --- a/client/src/utils/password-strength.jsx +++ b/client/src/utils/password-strength.jsx @@ -5,7 +5,7 @@ const hasNumber = (number) => new RegExp(/[0-9]/).test(number); const hasMixed = (number) => new RegExp(/[a-z]/).test(number) && new RegExp(/[A-Z]/).test(number); // has special chars -const hasSpecial = (number) => new RegExp(/[~!@#$%\^&\*\(\)_\+=\-\{\[\}\]:;"'<,>\.\?\/]/).test(number); +const hasSpecial = (number) => new RegExp(/[~!@#$%\^&\*\(\)_\+=\-\{\[\}\]:;"'<,>\?\/]/).test(number); // set color based on password strength export const strengthColor = (count) => { diff --git a/package.json b/package.json index 0469c58..3e879be 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cosmos-server", - "version": "0.9.8", + "version": "0.9.9", "description": "", "main": "test-server.js", "bugs": { diff --git a/src/proxy/routerGen.go b/src/proxy/routerGen.go index dabd956..cdc6f66 100644 --- a/src/proxy/routerGen.go +++ b/src/proxy/routerGen.go @@ -72,6 +72,18 @@ func RouterGen(route utils.ProxyRouteConfig, router *mux.Router, destination htt } destination = http.StripPrefix(route.PathPrefix, destination) } + + for filter := range route.AddionalFilters { + if route.AddionalFilters[filter].Type == "header" { + origin = origin.Headers(route.AddionalFilters[filter].Name, route.AddionalFilters[filter].Value) + } else if route.AddionalFilters[filter].Type == "query" { + origin = origin.Queries(route.AddionalFilters[filter].Name, route.AddionalFilters[filter].Value) + } else if route.AddionalFilters[filter].Type == "method" { + origin = origin.Methods(route.AddionalFilters[filter].Value) + } else { + utils.Error("Unknown filter type: "+route.AddionalFilters[filter].Type, nil) + } + } destination = SmartShieldMiddleware(route.SmartShield)(destination) diff --git a/src/proxy/shield.go b/src/proxy/shield.go index 8396bb2..95b8c89 100644 --- a/src/proxy/shield.go +++ b/src/proxy/shield.go @@ -235,6 +235,11 @@ func calculateLowestExhaustedPercentage(policy utils.SmartShieldPolicy, userCons func GetClientID(r *http.Request) string { // when using Docker we need to get the real IP + utils.Debug("SmartShield TEMPLOG: Getting client ID") + utils.Debug("SmartShield TEMPLOG HOSTNAME: " + os.Getenv("HOSTNAME")) + utils.Debug("SmartShield TEMPLOG x-forwarded-for: " + r.Header.Get("x-forwarded-for")) + utils.Debug("SmartShield TEMPLOG RemoteAddr: " + r.RemoteAddr) + if os.Getenv("HOSTNAME") != "" && r.Header.Get("x-forwarded-for") != "" { ip, _, _ := net.SplitHostPort(r.Header.Get("x-forwarded-for")) utils.Debug("SmartShield: Getting client ID " + ip) diff --git a/src/utils/types.go b/src/utils/types.go index a71061f..4ddbd99 100644 --- a/src/utils/types.go +++ b/src/utils/types.go @@ -149,6 +149,12 @@ type ProxyConfig struct { Routes []ProxyRouteConfig } +type AddionalFiltersConfig struct { + Type string + Name string + Value string +} + type ProxyRouteConfig struct { Name string `validate:"required"` Description string @@ -170,6 +176,7 @@ type ProxyRouteConfig struct { BlockAPIAbuse bool AcceptInsecureHTTPSTarget bool HideFromDashboard bool + AddionalFilters []AddionalFiltersConfig } type EmailConfig struct {