package auth import ( "fmt" "net/http" "github.com/gravitl/netmaker/servercfg" ) var htmlBaseTemplate = `
%s
`
var oauthNotConfigured = fmt.Sprintf(htmlBaseTemplate, `Please visit the docs here to learn how to.
`) var oauthStateInvalid = fmt.Sprintf(htmlBaseTemplate, `Non-Admins can access the netmaker networks using our Netmaker Desktop App.
`) var userFirstTimeSignUp = fmt.Sprintf(htmlBaseTemplate, `To continue, please log in with your existing credentials or reset your password if needed.
`) 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)) }