package auth import ( "fmt" "net/http" "github.com/gravitl/netmaker/servercfg" ) var htmlBaseTemplate = ` Netmaker :: SSO %s ` var oauthNotConfigured = fmt.Sprintf(htmlBaseTemplate, `

Your Netmaker server does not have OAuth configured.

Please visit the docs here to learn how to.

`) var oauthStateInvalid = fmt.Sprintf(htmlBaseTemplate, `

Invalid OAuth Session. Please re-try again.

`) var userNotAllowed = fmt.Sprintf(htmlBaseTemplate, `

Your account does not have access to the dashboard. Please contact your administrator for more information about your account.

Non-Admins can access the netmaker networks using our Netmaker Desktop App.

`) var userFirstTimeSignUp = fmt.Sprintf(htmlBaseTemplate, `

Thank you for signing up. Please contact your administrator for access.

`) var userSignUpApprovalPending = fmt.Sprintf(htmlBaseTemplate, `

Your account is yet to be approved. Please contact your administrator for access.

`) var userNotFound = fmt.Sprintf(htmlBaseTemplate, `

User Not Found.

`) var somethingwentwrong = fmt.Sprintf(htmlBaseTemplate, `

Something went wrong. Contact Admin.

`) var notallowedtosignup = fmt.Sprintf(htmlBaseTemplate, `

Your email is not allowed. Please contact your administrator.

`) var authTypeMismatch = fmt.Sprintf(htmlBaseTemplate, `

It looks like you already have an account with us using Basic Authentication.

To continue, please log in with your existing credentials or reset your password if needed.

`) var userAccountDisabled = fmt.Sprintf(htmlBaseTemplate, `

Your account has been disabled. Please contact your administrator for more information about your account.

`) func handleOauthUserNotFound(response http.ResponseWriter) { response.Header().Set("Content-Type", "text/html; charset=utf-8") response.WriteHeader(http.StatusNotFound) response.Write([]byte(userNotFound)) } func handleOauthUserNotAllowed(response http.ResponseWriter) { response.Header().Set("Content-Type", "text/html; charset=utf-8") response.WriteHeader(http.StatusForbidden) response.Write([]byte(userNotAllowed)) } func handleFirstTimeOauthUserSignUp(response http.ResponseWriter) { response.Header().Set("Content-Type", "text/html; charset=utf-8") response.WriteHeader(http.StatusForbidden) response.Write([]byte(userFirstTimeSignUp)) } func handleOauthUserSignUpApprovalPending(response http.ResponseWriter) { response.Header().Set("Content-Type", "text/html; charset=utf-8") response.WriteHeader(http.StatusForbidden) response.Write([]byte(userSignUpApprovalPending)) } func handleOauthUserNotAllowedToSignUp(response http.ResponseWriter) { response.Header().Set("Content-Type", "text/html; charset=utf-8") response.WriteHeader(http.StatusForbidden) response.Write([]byte(notallowedtosignup)) } // handleOauthNotConfigured - returns an appropriate html page when oauth is not configured on netmaker server but an oauth login was attempted func handleOauthNotConfigured(response http.ResponseWriter) { response.Header().Set("Content-Type", "text/html; charset=utf-8") response.WriteHeader(http.StatusInternalServerError) response.Write([]byte(oauthNotConfigured)) } func handleOauthNotValid(response http.ResponseWriter) { response.Header().Set("Content-Type", "text/html; charset=utf-8") response.WriteHeader(http.StatusBadRequest) response.Write([]byte(oauthStateInvalid)) } func handleSomethingWentWrong(response http.ResponseWriter) { response.Header().Set("Content-Type", "text/html; charset=utf-8") response.WriteHeader(http.StatusInternalServerError) response.Write([]byte(somethingwentwrong)) } func handleAuthTypeMismatch(response http.ResponseWriter) { response.Header().Set("Content-Type", "text/html; charset=utf-8") response.WriteHeader(http.StatusBadRequest) response.Write([]byte(authTypeMismatch)) } func handleUserAccountDisabled(response http.ResponseWriter) { response.Header().Set("Content-Type", "text/html; charset=utf-8") response.WriteHeader(http.StatusUnauthorized) response.Write([]byte(userAccountDisabled)) }