diff --git a/document_roots/webhost/assets/css/style.css b/document_roots/webhost/assets/css/style.css new file mode 100644 index 0000000..6e27941 --- /dev/null +++ b/document_roots/webhost/assets/css/style.css @@ -0,0 +1,3 @@ +.navbar { + background-color:#E0EBF5 !important; +} diff --git a/document_roots/webhost/assets/js/main.js b/document_roots/webhost/assets/js/main.js new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/document_roots/webhost/assets/js/main.js @@ -0,0 +1 @@ + diff --git a/document_roots/webhost/gPanel.html b/document_roots/webhost/gPanel.html new file mode 100644 index 0000000..b1100bd --- /dev/null +++ b/document_roots/webhost/gPanel.html @@ -0,0 +1,50 @@ + + + + gPanel + + + + + + + + + + +
+
+
+
+
+

Public Server

+
Handle operations for the public serving server
+ + + + +
+
+
+
+
+ + + + + + + + + diff --git a/document_roots/webhost/index.html b/document_roots/webhost/index.html index 2fbd0d8..9b9dc44 100644 --- a/document_roots/webhost/index.html +++ b/document_roots/webhost/index.html @@ -1,547 +1,54 @@ - + - - gPanel - Home - - - + + gPanel - - + + - - - - - - -
-
-
-
- -
- -
-
Basic WebHost Manager Setup
-
Change Root Password
-
Configure ePanel Cron Jobs
-
Initial Quota Setup
-
Server Time
-
Statistics Software Configuration
-
Tweak Settings
-
Update Preferences
-
-
- -
-
-

- Support -

-
-
-
Create Support Ticket
-
Grant gPanel Support Access
-
Support Center
-
-
- -
- -
-
Change Hostname
-
Resolver Configuration
-
-
- -
-
-

- Security Center -

-
-
-
Apache mod_userdir Tweak
-
Compiler Access
-
Configure Security Policies
-
cPHulk Brute Force Protection
-
Host Access Control
-
Manage External Authentications
-
Manage root’s SSH Keys
-
Manage Wheel Group Users
-
ModSecurity™ Configuration
-
ModSecurity™ Tools
-
ModSecurity™ Vendors
-
Password Strength Configuration
-
PHP open_basedir Tweak
-
cPanel Security Advisor
-
Security Questions
-
Shell Fork Bomb Protection
-
SMTP Restrictions
-
SSH Password Authorization Tweak
-
Traceroute Enable/Disable
-
Two-Factor Authentication
-
-
- -
-
-

- Server Contacts -

-
-
-
Contact Manager
-
Edit System Mail Preferences
-
-
- -
-
-

- Reseller -

-
-
-
Change Ownership of an Account
-
Change Ownership of Multiple Accounts
-
Edit Reseller Nameservers and Privileges
-
Email All Resellers
-
Manage Reseller’s IP Delegation
-
Manage Reseller’s Shared IP
-
Reseller Center
-
Reset Resellers
-
Show Reseller Accounts
-
View Reseller Usage and Manage Account Status
-
-
- -
-
-

- Locales -

-
-
-
Configure Application Locales
-
Copy a Locale
-
Delete a Locale
-
Edit a Locale
-
Locale XML Download
-
Locale XML Upload
-
View Available Locales
-
-
- -
-
-

- Backup -

-
-
-
Backup Configuration
-
Backup Restoration
-
Backup User Selection
-
Configuration File Rollback
-
Legacy Backup Configuration
-
Legacy Restore Backups
-
Legacy Restore Multiple Backups
-
Restore a Full Backup/cpmove File
-
-
- - -
-
-

- Clusters -

-
-
-
Configuration Cluster
-
DNS Cluster
-
Remote Access Key
-
-
- - -
-
-

- System Reboot -

-
-
-
Forceful Server Reboot
-
Graceful Server Reboot
-
-
- -
-
-

- Server Status -

-
-
-
Apache Status
-
Daily Process Log
-
Server Information
-
Service Status
-
-
- -
- -
-
List Accounts
-
List Parked Domains
-
List Subdomains
-
Suspended Accounts
-
Show Accounts Over Quota
-
View Bandwidth Usage
-
-
- -
- -
-
Change Site’s IP Address
-
Create a New Account
-
Email All Users
-
Force Password Change
-
Limit Bandwidth Usage
-
Manage Account Suspension
-
Manage Demo Mode
-
Manage Shell Access
-
Modify an Account
-
Password Modification
-
Quota Modification
-
Raw Apache Log Download
-
Raw FTP Log Download
-
Rearrange an Account
-
Reset Account Bandwidth Limit
-
Show Active and Inactive Accounts
-
Skeleton Directory
-
Terminate Accounts
-
Unsuspend Bandwidth Exceeders
-
Upgrade/Downgrade an Account
-
Web Template Editor
-
-
- -
- -
-
Change Multiple Sites’ IP Addresses
-
Modify/Upgrade Multiple Accounts
-
-
- -
-
-

- Transfers -

-
-
-
Convert Addon Domain to Account
-
Copy an Account From Another Server With an Account Password
-
Review Transfers and Restores
-
Transfer Tool
-
-
- -
-
-

- Themes -

-
-
-
Change WebHost Manager® Theme
-
Theme Manager
-
-
- -
-
-

- Packages -

-
-
-
Add a Package
-
Delete a Package
-
Edit a Package
-
Feature Manager
-
-
- -
-
-

- DNS Functions -

-
-
-
Add a DNS Zone
-
Add an A Entry for Your Hostname
-
DNS Zone Removal
-
DNS Zone Editor
-
MX Entry Editor
-
Edit Zone Templates
-
Nameserver Record Report
-
Park a Domain
-
Perform a DNS Cleanup
-
Reset a DNS Zone
-
Set Zone Time To Live (TTL)
-
Setup/Edit Domain Forwarding
-
Synchronize DNS Records
-
-
- -
-
-

- SQL Services -

-
-
-
Additional MySQL Access Hosts
-
Change MySQL User Password
-
Database Map Tool
-
Manage Database Users
-
Manage Databases
-
Manage MySQL® Profiles
-
MySQL Root Password
-
phpMyAdmin
-
Repair a MySQL Database
-
Show MySQL Processes
-
-
- -
-
-

- IP Functions -

-
-
-
Add a New IP Address
-
Assign IPv6 Address
-
Change a Site’s IP Address
-
Configure Remote Service IPs
-
IP Migration Wizard
-
IPv6 Address Ranges
-
Rebuild the IP Address Pool
-
Show IP Address Usage
-
Show or Delete Current IP Addresses
-
Show/Edit Reserved IPs
-
-
- -
-
-

- Software -

-
-
-
EasyApache 4
-
Install a Perl Module
-
Install an RPM
-
Module Installers
-
MultiPHP INI Editor
-
MultiPHP Manager
-
MySQL/MariaDB Upgrade
-
Rebuild RPM Database
-
System Update
-
Update Server Software
-
-
- -
-
-

- Email -

-
-
-
Greylisting
-
Mail Delivery Reports
-
Mail Queue Manager
-
Mail Troubleshooter
-
Mailbox Conversion
-
Repair Mailbox Permissions
-
Spamd Startup Configuration
-
View Mail Statistics Summary
-
View Relayers
-
View Sent Summary
-
-
- -
-
-

- System Health -

-
-
-
Background Process Killer
-
Process Manager
-
Show Current Disk Usage
-
Show Current Running Processes
-
-
- -
-
-

- cPanel -

-
-
-
Customization
-
Install cPAddons Site Software
-
Manage cPAddons Site Software
-
Manage Plugins
-
Modify cPanel & WHM News
-
Reset a Mailman Password
-
Synchronize FTP Passwords
-
Upgrade to Latest Version
-
-
- -
-
-

- SSL/TLS -

-
-
-
Generate an SSL Certificate and Signing Request
-
Install an SSL Certificate on a Domain
-
Manage AutoSSL
-
Manage SSL Hosts
-
Purchase and Install an SSL Certificate
-
SSL Storage Manager
-
-
- -
-
-

- Market -

-
-
-
Market Provider Manager
-
-
- -
- -
-
DNS Server
-
FTP Server (ProFTPd/PureFTPd)
-
HTTP Server (Apache)
-
IMAP Server
-
Mail Server (Exim)
-
Mailing List Manager (Mailman)
-
PHP-FPM service for Apache
-
SQL Server (MySQL)
-
SSH Server (OpenSSH)
-
-
- -
-
-

- Development -

-
-
-
Apps Managed by AppConfig
-
cPanel Developement Forum
-
cPanel Plugin File Generator
-
Manage Hooks
-
Software Development Kit
-
-
- + + -
-
-

Help Wanted

-
-

Help Wanted

-
-

Help Wanted

-
-

Help Wanted

-
-
Help Wanted
-
-
Help Wanted
-
-
-
+ +
+
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
- - - - - + + + + + + + diff --git a/document_roots/webhost/styles.css b/document_roots/webhost/styles.css deleted file mode 100644 index f5c0a25..0000000 --- a/document_roots/webhost/styles.css +++ /dev/null @@ -1,31 +0,0 @@ -/* Remove the navbar's default margin-bottom and rounded borders */ -.navbar { - margin-bottom: 0; - border-radius: 0; -} - -/* Set height of the grid so .sidenav can be 100% (adjust as needed) */ -.row.content {height: 450px} - -/* Set gray background color and 100% height */ -.sidenav { - padding-top: 20px; - background-color: #f1f1f1; - height: 100%; -} - -/* Set black background color, white text and some padding */ -footer { - background-color: #555; - color: white; - padding: 15px; -} - -/* On small screens, set height to 'auto' for sidenav and grid */ -@media screen and (max-width: 767px) { - .sidenav { - height: auto; - padding: 15px; - } - .row.content {height:auto;} -} \ No newline at end of file diff --git a/pkg/public/public.go b/pkg/public/public.go index 520cde7..e241057 100644 --- a/pkg/public/public.go +++ b/pkg/public/public.go @@ -2,7 +2,7 @@ package public import ( - "bufio" + "io" "net/http" "os" @@ -33,23 +33,26 @@ func (pub *PublicWeb) ServeHTTP(w http.ResponseWriter, req *http.Request) { f, err := os.Open(path) - if err == nil { - bufferedReader := bufio.NewReader(f) - contentType, err := routing.GetContentType(path) - - if err == nil { - w.Header().Add("Content Type", contentType) - bufferedReader.WriteTo(w) - - logging.Console(logging.PUBLIC_PREFIX, logging.NORMAL_LOG, "Path \""+path+"\" rendered a 200 success.") - } else { - routing.HttpThrowStatus(http.StatusUnsupportedMediaType, w) - logging.Console(logging.PUBLIC_PREFIX, logging.NORMAL_LOG, "Path \""+path+"\" content type could not be determined, 404 error.") - } - - } else { + if err != nil { routing.HttpThrowStatus(http.StatusNotFound, w) logging.Console(logging.PUBLIC_PREFIX, logging.NORMAL_LOG, "Path \""+path+"\" rendered a 404 error.") + return } + contentType, err := routing.GetContentType(path) + + if err != nil { + routing.HttpThrowStatus(http.StatusUnsupportedMediaType, w) + logging.Console(logging.PUBLIC_PREFIX, logging.NORMAL_LOG, "Path \""+path+"\" content type could not be determined, 404 error.") + return + } + + w.Header().Add("Content-Type", contentType) + _, err = io.Copy(w, f) + + if err != nil { + routing.HttpThrowStatus(http.StatusInternalServerError, w) + logging.Console(logging.PUBLIC_PREFIX, logging.NORMAL_LOG, "Path \""+path+"\" rendered a 500 error.") + return + } } diff --git a/pkg/webhost/check_auth.go b/pkg/webhost/check_auth.go deleted file mode 100644 index ddcf921..0000000 --- a/pkg/webhost/check_auth.go +++ /dev/null @@ -1,15 +0,0 @@ -// Package webhost handles the logic of the webhosting panel -package webhost - -import "strings" - -var allowedUnauthorizedPathSuffixes = [...]string{"api_testing.html", "user_auth", "user_register"} - -func CheckAuth(path string) bool { - for _, suffix := range allowedUnauthorizedPathSuffixes { - if strings.HasSuffix(path, suffix) { - return true - } - } - return false -} diff --git a/pkg/webhost/webhost.go b/pkg/webhost/webhost.go index d325c9b..57fcedf 100644 --- a/pkg/webhost/webhost.go +++ b/pkg/webhost/webhost.go @@ -2,9 +2,10 @@ package webhost import ( - "bufio" + "io" "net/http" "os" + "strings" "github.com/Ennovar/gPanel/pkg/api" "github.com/Ennovar/gPanel/pkg/logging" @@ -23,6 +24,30 @@ func NewPrivateHost() PrivateHost { } } +// reqAuth function checks to see if the given path requires authentication. +func reqAuth(path string) bool { + path = strings.ToLower(path) + + dismissibleTypes := []string{".css", ".js"} + for _, t := range dismissibleTypes { + if strings.HasSuffix(path, t) { + return false + } + } + + dismissibleFiles := []string{ + "api_testing.html", + "index.html", + } + for _, f := range dismissibleFiles { + if strings.HasSuffix(path, f) { + return false + } + } + + return true +} + // ServeHTTP function routes all requests for the private webhost server. It is used in the main // function inside of the http.ListenAndServe() function for the private webhost host. func (priv *PrivateHost) ServeHTTP(w http.ResponseWriter, req *http.Request) { @@ -33,43 +58,58 @@ func (priv *PrivateHost) ServeHTTP(w http.ResponseWriter, req *http.Request) { path = (priv.Directory + path) } - store := networking.GetStore(networking.COOKIES_USER_AUTH) - val, err := store.Read(w, req, "auth") - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) + var auth interface{} = true + if reqAuth(path) { + store := networking.GetStore(networking.COOKIES_USER_AUTH) + + auth, err := store.Read(w, req, "auth") + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + auth, ok := auth.(bool) + if !ok { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + } + + if !auth.(bool) { + routing.HttpThrowStatus(http.StatusUnauthorized, w) + logging.Console(logging.PRIVATE_PREFIX, logging.NORMAL_LOG, "Path \""+path+"\" rendered a 401 error.") return } - if val != true && !CheckAuth(path) { - routing.HttpThrowStatus(http.StatusUnauthorized, w) - logging.Console(logging.PRIVATE_PREFIX, logging.NORMAL_LOG, "Path \""+path+"\" rendered a 401 error.") - } else { - isApi, _ := api.HandleAPI(path, w, req) - - if isApi != true { - f, err := os.Open(path) - - if err == nil { - bufferedReader := bufio.NewReader(f) - contentType, err := routing.GetContentType(path) - - if err == nil { - w.Header().Add("Content Type", contentType) - bufferedReader.WriteTo(w) - - logging.Console(logging.PRIVATE_PREFIX, logging.NORMAL_LOG, "Path \""+path+"\" rendered a 200 success.") - } else { - routing.HttpThrowStatus(http.StatusUnsupportedMediaType, w) - logging.Console(logging.PRIVATE_PREFIX, logging.NORMAL_LOG, "Path \""+path+"\" content type could not be determined, 404 error.") - } - - } else { - routing.HttpThrowStatus(http.StatusNotFound, w) - logging.Console(logging.PRIVATE_PREFIX, logging.NORMAL_LOG, "Path \""+path+"\" rendered a 404 error.") - } - - } + isApi, _ := api.HandleAPI(path, w, req) + if isApi { + // API methods handle HTTP logic from here + return } + f, err := os.Open(path) + + if err != nil { + routing.HttpThrowStatus(http.StatusNotFound, w) + logging.Console(logging.PRIVATE_PREFIX, logging.NORMAL_LOG, "Path \""+path+"\" rendered a 404 error.") + return + } + + contentType, err := routing.GetContentType(path) + + if err != nil { + routing.HttpThrowStatus(http.StatusUnsupportedMediaType, w) + logging.Console(logging.PUBLIC_PREFIX, logging.NORMAL_LOG, "Path \""+path+"\" content type could not be determined, 404 error.") + return + } + + w.Header().Add("Content-Type", contentType) + _, err = io.Copy(w, f) + + if err != nil { + routing.HttpThrowStatus(http.StatusInternalServerError, w) + logging.Console(logging.PUBLIC_PREFIX, logging.NORMAL_LOG, "Path \""+path+"\" rendered a 500 error.") + return + } }