# README
uAdmin the Golang Web Framework
Easy to use, blazing fast and secure.
Originally open source by IntegrityNet Solutions and Services
For Documentation:
Social Media:
Screenshots
Dashboard Menu
Log
Login Form
Features
- AB Testing System
- API Configuration
- Approval System
- Authentication and Permissions
- Clean and sharp UI
- Dashboard customization
- Data Access API (dAPI)
- Database schema migration
- Error Handling
- Export to Excel
- Form and List customization
- Image Cropping
- IP address and port configuration
- Log feature that keeps track of many things in your app
- Metric System
- Multilingual translation
- MySQL Database Support
- Offers FREE hosting for your app while you are developing by using a single command: uAdmin publish
- Pretty good security features (SSL, 2-Factor Authentication, Password Reset, Hash Salt, Database Encryption)
- Public access to media
- Self-relation of foreign key/many2many
- Sending an email from your app by establishing an email configuration
- System settings could be used system-wide to keep application settings
- Tag support for fields
- Translation files preloading
- Validation for user input
- Webcam support on image and file fields
Minimum requirements
Operating System | Architectures | Notes |
---|---|---|
FreeBSD 10.3 or later | amd64, 386 | Debian GNU/kFreeBSD not supported |
Linux 2.6.23 or later with glibc | amd64, 386, arm, arm64, s390x, ppc64le | CentOS/RHEL 5.x not supported. Install from source for other libc. |
macOS 10.10 or later | amd64 | Use the clang or gcc† that comes with Xcode‡ for cgo support. |
Windows 7, Server 2008 R2 or later | amd64, 386 | Use MinGW gcc†. No need for cygwin or msys. |
- † A C compiler is required only if you plan to use cgo.
- ‡ You only need to install the command line tools for Xcode. If you have already installed Xcode 4.3+, you can install it from the Components tab of the Downloads preferences panel.
Hardware
- RAM - minimum 256MB
- CPU - minimum 2GHz
Software
- Go Version 1.16 or later
Installation
go get -u github.com/rkj-tech/uadmin-with-postgres-ssl-options/
go install github.com/rkj-tech/uadmin-with-postgres-ssl-options/cmd/uadmin@latest
To test if your installation is fine, run the uadmin
command line:
$ uadmin
Usage: uadmin COMMAND [--src]
This tools helps you prepare a folder for a new project or update static files and templates
Commands:
prepare Generates folders and prepares static and templates
version Shows the version of uAdmin
Arguments:
--src If you want to copy static files and templates from src folder
Get full documentation online:
https://uadmin-docs.readthedocs.io/en/latest/
Your First App
Let's build your first app which is a Todo list. First, we will create a folder for your project and prepare it.
$ mkdir -p ~/go/src/github.com/your_name/todo
$ cd ~/go/src/github.com/your_name/todo
$ uadmin prepare
[ OK ] Created: /Users/abdullah/go/src/github.com/twistedhardware/test/models
[ OK ] Created: /Users/abdullah/go/src/github.com/twistedhardware/test/api
[ OK ] Created: /Users/abdullah/go/src/github.com/twistedhardware/test/views
[ OK ] Created: /Users/abdullah/go/src/github.com/twistedhardware/test/media
[ INFO ] Copying static/templates from: /Users/abdullah/go/pkg/mod/github.com/rkj-tech/[email protected]
[ OK ] Created: /Users/abdullah/go/src/github.com/twistedhardware/test/static
[ OK ] Created: /Users/abdullah/go/src/github.com/twistedhardware/test/templates
Now use your code editor to create main.go
and put this code inside it.
package main
import (
"github.com/rkj-tech/uadmin-with-postgres-ssl-options"
"time"
)
type Todo struct {
uadmin.Model
Name string
Description string `uadmin:"html"`
TargetDate time.Time
Progress int `uadmin:"progress_bar"`
}
func main() {
uadmin.Register(Todo{})
uadmin.StartServer()
}
Prepare modules
$ go mod init
go: creating new go.mod: module github.com/twistedhardware/test
go: to add module requirements and sums:
go mod tidy
$ go mod tidy
go: finding module for package github.com/rkj-tech/uadmin-with-postgres-ssl-options
go: found github.com/rkj-tech/uadmin-with-postgres-ssl-options in github.com/rkj-tech/uadmin-with-postgres-ssl-options v0.6.0
Run your app (Linux, Apple macOS or Windows):
$ go build; ./todo
[ OK ] Initializing DB: [14/14]
[ OK ] Initializing Languages: [185/185]
[ INFO ] Auto generated admin user. Username:admin, Password:admin.
[ OK ] Synching System Settings: [49/49]
[ OK ] Server Started: http://0.0.0.0:8080
___ __ _
__ __/ | ____/ /___ ___ (_)___
/ / / / /| |/ __ / __ '__ \/ / __ \
/ /_/ / ___ / /_/ / / / / / / / / / /
\__,_/_/ |_\__,_/_/ /_/ /_/_/_/ /_/
In Windows:
> go build && todo.exe
[ OK ] Initializing DB: [14/14]
[ OK ] Initializing Languages: [185/185]
[ INFO ] Auto generated admin user. Username:admin, Password:admin.
[ OK ] Synching System Settings: [49/49]
[ OK ] Server Started: http://0.0.0.0:8080
___ __ _
__ __/ | ____/ /___ ___ (_)___
/ / / / /| |/ __ / __ __ \/ / __ \
/ /_/ / ___ / /_/ / / / / / / / / / /
\__,_/_/ |_\__,_/_/ /_/ /_/_/_/ /_/
Quick Reference
Overriding Save Function
func (m *Model) Save() {
// business logic
uadmin.Save(m)
}
Validation
func (m Model) Validate() (ret map[string]string) {
ret = map[string]string{}
if m.Name != "test" {
ret["Name"] = "Error name not found"
}
return
}
# Functions
ABTestClick is a function to register a click for an ABTest group.
AdminPage !.
All fetches all object in the database.
Avg return the average of a column in a table based on a filter.
AvgTable return the average of a column in a table based on a filter.
CheckCSRF checks if the request is a possible CSRF.
CheckRateLimit checks if the request has remaining quota or not.
ClearDB clears the db object.
No description provided by the author
Count return the count of records in a table based on a filter.
CountTable return the count of records in a table based on a filter.
Delete records from database.
DeleteList deletes multiple records from database.
Filter fetches records from the database.
FilterBuilder changes a map filter into a query.
FilterList fetches the all record from the database matching query and args where it selects only visible fields in the form based on given schema.
Filter fetches records from the database.
Filter fetches records from the database.
Filter fetches records from the database.
Filter fetches records from the database.
GenerateBase32 generates a base32 string of length length.
GenerateBase64 generates a base64 string of length length.
GenerateOpenAPISchema generates API schema for dAPI that is compatible with OpenAPI 3.1.0 Use of OpenAPI schema generation is under development and should not be used in production.
Get fetches the first record from the database matching query and args.
GetABTest is like Get function but implements AB testing for the results.
GetActiveLanguages returns a list of active langages.
GetDB returns a pointer to the DB.
GetDefaultLanguage returns the default language.
GetFieldsAPI returns a list of fields in a model.
GetForm fetches the first record from the database matching query and args where it selects only visible fields in the form based on given schema.
GetHostName is a function that returns the host name from a request.
GetID !.
GetModelsAPI returns a list of models.
GetRemoteIP is a function that returns the IP for a remote user from a request.
GetSchema is a function that returns the schema for a request (http, https).
GetSetting return the value of a setting based on its code.
Get fetches the first record from the database matching query and args with sorting.
Get fetches the first record from the database matching query and args with sorting.
GetString returns string representation on an instance of a model.
GetStringer fetches the first record from the database matching query and args and get only fields tagged with `stringer` tag.
Get fetches the first record from the database matching query and args with sorting.
GetUserFromRequest returns a user from a request.
Get fetches the first record from the database matching query and args with sorting.
Handler is a function that takes an http handler function and returns an http handler function that has extra functionality including logging.
IncrementMetric increments the value of a.
IsAuthenticated returns if the http.Request is authenticated or not.
JSONMarshal Generates JSON format from an object.
No description provided by the author
Login return *User and a bool for Is OTP Required.
Login2FA login using username, password and otp for users with OTPRequired = true.
Login2FA login using username, password and otp for users with OTPRequired = true.
Logout logs out a user.
Max return the maximum of a column in a table based on a filter.
MaxTable return the maximum of a column in a table based on a filter.
Min return the minimum of a column in a table based on a filter.
MinTable return the minimum of a column in a table based on a filter.
NewMetric creates a new metric.
NewModel creates a new model from a model name.
NewModelArray creates a new model from a model name.
Preload fills the data from foreign keys into structs.
Register is used to register models to uadmin.
RegisterInlines is a function to register a model as an inline for another model Parameters: ===========
model (struct instance): Is the model that you want to add inlines to.
No description provided by the author
RenderHTML creates a new template and applies a parsed template to the specified data object.
RenderMultiHTML creates a new template and applies a parsed template to the specified data object.
ReturnJSON returns json to the client.
Save saves the object in the database.
SendEmail sends email using system configured variables.
SetMetric sets the value of a gauge metric.
SetSessionCookie sets the session cookie value, The the value passed in session is nil, then the session assigned will be a no user session.
SQLInjection is the function to check for SQL injection attacks.
StartSecureServer !.
StartServer !.
StaticHandler is a function that serves static files.
Std return the standard diviation of a column in a table based on a filter.
StdTable return the standard diviation of a column in a table based on a filter.
Sum return the sum of a column in a table based on a filter.
SumTable return the sum of a column in a table based on a filter.
Syslogf records a log in the system in syslog.
Tf is a function for translating strings into any given language Parameters: ===========
path (string): This is where to get the translation from.
TimeMetric runs a function and times it as a metric.
Trail prints to the log.
Translate is used to get a translation from a multilingual fields.
TranslateSchema translate a model schema.
Update !.
UploadImageHandler handles files sent from Tiny MCE's photo uploader.
ValidateIP is a function to check if the IP in the request is allowed in the allowed based on allowed and block strings.
# Constants
Reporting Levels.
Try SSL, if not available continue with no SSL.
Reporting Levels.
Reporting Levels.
No SSL.
Reporting Levels.
Reporting Levels.
Reporting Levels.
Reporting Levels.
Reporting Levels.
Try SSL first, if not available continue with no SSL.
Only SSL.
Only SSL, verify that the server certificate is issued by a trusted CA and that the server host name matches that in the certificate.
Only SSL, and verify that the server certificate is issued by a trusted certificate authority (CA).
Version number as per Semantic Versioning 2.0.0 (semver.org).
VersionCodeName is the cool name we give to versions with significant changes.
Reporting Levels.
Reporting Levels.
# Variables
AcceptedJWTIssuers is a list of accepted JWT issuers.
AllowDAPISignup allows unauthenticated users to sign up.
AllowedCORSOrigins is a list of allowed CORS origins.
AllowedHosts is a comma separated list of allowed hosts for the server to work.
AllowedIPs is a list of allowed IPs to access uAdmin interfrace in one of the following formats: - "*" = Allow all - "" = Allow none - "192.168.1.1" Only allow this IP - "192.168.1.0/24" Allow all IPs from 192.168.1.1 to 192.168.1.254 You can also create a list of the above formats using comma to separate them.
APIDisabledAdd controls the data API's disabled for add commands.
APIDisabledDelete controls the data API's disabled for delete commands.
APIDisabledEdit controls the data API's disabled for edit commands.
APIDisabledRead controls the data API’s disabled for add commands.
APIDisabledSchema controls the data API's disabled for schema commands.
APILogAdd controls the data API's logging for add commands.
APILogDelete controls the data API's logging for delete commands.
APILogEdit controls the data API's logging for edit commands.
APILogRead controls the data API's logging for read commands.
APILogSchema controls the data API's logging for schema commands.
APIPostQueryAdd controls the data API's post query for add commands.
APIPostQueryAddHandler is a function that runs after all dAPI add requests.
APIPostQueryDelete controls the data API's post query for delete commands.
APIPostQueryDeleteHandler is a function that runs after all dAPI delete requests.
APIPostQueryEdit controls the data API's post query for edit commands.
APIPostQueryEditHandler is a function that runs after all dAPI edit requests.
APIPostQueryRead controls the data API’s post query for add commands.
APIPostQueryReadHandler is a function that runs after all dAPI read requests.
APIPostQuerySchema controls the data API's post query for schema commands.
APIPreQueryAdd controls the data API's pre query for add commands.
APIPreQueryAddHandler is a function that runs before all dAPI add requests.
APIPreQueryDelete controls the data API's pre query for delete commands.
APIPreQueryDeleteHandler is a function that runs before all dAPI delete requests.
APIPreQueryEdit controls the data API's pre query for edit commands.
APIPreQueryEditHandler is a function that runs before all dAPI edit requests.
APIPreQueryRead controls the data API’s pre query for add commands.
APIPreQueryReadHandler is a function that runs before all dAPI read requests.
APIPreQuerySchema controls the data API's pre query for schema commands.
APIPublicAdd controls the data API's public for add commands.
APIPublicDelete controls the data API's public for delete commands.
APIPublicEdit controls the data API's public for edit commands.
APIPublicRead controls the data API’s public for add commands.
APIPublicSchema controls the data API's public for schema commands.
ApprovalHandleFunc is a function that could be called during the save process of each approval.
BindIP is the IP the application listens to.
BlockedIPs is a list of blocked IPs from accessing uAdmin interfrace in one of the following formats: - "*" = Block all - "" = Block none - "192.168.1.1" Only block this IP - "192.168.1.0/24" Block all IPs from 192.168.1.1 to 192.168.1.254 You can also create a list of the above formats using comma to separate them.
CachePermissions allows uAdmin to store permissions data in memory.
CacheSessions allows uAdmin to store sessions data in memory.
CacheTranslation allows a translation to store data in a cache memory.
CompressJSON is a variable that allows the user to reduce the size of JSON responses.
CookieTimeout is the timeout of a login cookie in seconds.
CustomDAPIHeaders are extra handlers that would be added to dAPI responses.
CustomDAPILoginHandler is a function that can provide extra information in the login return.
CustomEmailHandler allows to customize or even override the default email sending method.
CustomizeJSON is a function to allow customization of JSON returns.
No description provided by the author
CustomOpenAPI is a handler to be called to customize OpenAPI schema Use of OpenAPI schema generation is under development and should not be used in production.
CustomOpenAPIJSON is a handler to be called to customize OpenAPI schema JSON output Use of OpenAPI schema generation is under development and should not be used in production.
CustomResetPasswordLink is the link sent to the user's email to reset their password the string may include the following place holder: "{SCHEMA}://{HOST}/resetpassword?u={USER_ID}&key={OTP}".
CustomTranslation is where you can register custom translation files.
DAPISignupActive controls if new signed up users are activate automatically.
DAPISignupAllowRemote controls if new signed up users are can login over the internet.
DAPISignupGroupID is the default user group id new users get when they sign up to leave new signed up users without a group, use value 0 for this variable.
Database is the active Database settings.
DebugDB prints all SQL statements going to DB.
DefaultMediaPermission is the default permission applied to to files uploaded to the system.
DisableAdminUI disables access to the UI and all related APIs.
DisableDAPIAuth enables or disables access to dAPI auth API.
EmailFrom identifies where the email is coming from.
EmailPassword sets the password of an email.
EmailSMTPServer sets the name of the SMTP Server in an email.
EmailSMTPServerPort sets the port number of an SMTP Server in an email.
EmailUsername sets the username of an email.
EnableDAPICORS controller whether dAPI is uses CORS protocol to allow cross-origan requests.
EncryptKey is a key for encryption and decryption of data in the DB.
ErrorHandleFunc is a function that will be called everytime Trail is called.
FavIcon is the fav icon that shows on uAdmin UI.
FullMediaURL allows uAdmin to send you full path URL instead on relative path for dAPI read requests.
HTTPLogFormat is the format used to log HTTP access
%a: Client IP address
%A: Server hostname/IP
%{local}p: Server port
%U: Path
%c: All cookies
%{NAME}c: Cookie named 'NAME'
%{GET}f: GET request parameters
%{POST}f: POST request parameters
%B: Response length
%>s: Response code
%D: Time taken in microseconds
%T: Time taken in seconds
%I: Request length
*/.
JWT secret for signing tokens.
"RS256".
jwtIssuer is a URL to identify the application issuing JWT tokens.
LogAdd adds a log when a record is added.
LogDelete adds a log when a record is deleted.
LogEdit adds a log when a record is edited.
LogHTTPRequests logs http requests to syslog.
Logo is the main logo that shows on uAdmin UI.
LogRead adds a log when a record is read.
LogTrail stores Trail logs to syslog.
MaskPasswordInAPI will replace any password fields with an asterisk mask.
MaxImageHeight sets the maximum height of an image.
MaxImageWidth sets the maximum width of an image.
MaxUploadFileSize is the maximum upload file size in bytes.
OptimizeSQLQuery selects columns during rendering a form a list to visible fields.
OTPAlgorithm is the hashing algorithm of OTP.
OTPDigits is the number of digits for the OTP.
OTPPeriod is the number of seconds for the OTP to change.
OTPSkew is the number of minutes to search around the OTP.
PageLength is the list view max number of records.
PasswordAttempts is the maximum number of invalid password attempts before the IP address is blocked for some time from using the system.
PasswordTimeout is the amount of time in minutes the IP will be blocked for after reaching the the maximum invalid password attempts.
Port is the port used for http or https server.
PreLoginHandler is a function that runs after all dAPI delete requests.
PreLoginHandler is a function that runs after all dAPI delete requests.
PublicMedia allows public access to media handler without authentication.
RateLimit is the maximum number of requests/second for any unique IP.
RateLimitBurst is the maximum number of requests for an idle user.
CompressJSON is a variable that allows the user to reduce the size of JSON responses.
ReportingLevel is the standard reporting level.
ReportTimeStamp set this to true to have a time stamp in your logs.
ResetPasswordMessage is a message that can be sent to the user email when a password reset request sends an email.
RestrictSessionIP is to block access of a user if their IP changes from their original IP during login.
RetainMediaVersions is to allow the system to keep files uploaded even after they are changed.
RootURL is where the listener is mapped to.
Salt is added to password hashing.
Schema is the global schema of the system.
ServerReady is a variable that is set to true once the server is ready to use.
SignupValidationHandler can be used to validate or customize new signed up users.
SiteName is the name of the website that shows on title and dashboard.
SSOURL enables SSO using OpenID Connect.
SystemMetrics enables uAdmin system metrics to be recorded.
Theme is the name of the theme used in uAdmin.
TimeZone specifies the the default time zone for the system.
TrailCacheSize is the number of bytes to keep in memory of trail logs.
TrailLoggingLevel is the minimum level to be logged into syslog.
UserMetrics enables the user metrics to be recorded.
# Structs
ABTest is a model that stores an A/B test.
ABTestValue is a model to represent a possible value of an AB test.
Approval is a model that stores approval data.
Choice is a struct for list choices.
DashboardMenu !.
DBSettings !.
F is a field.
GroupPermission !.
Language !.
Log !.
Model is the standard struct to be embedded in any other struct to make it a model for uadmin.
ModelSchema for a form.
Session !.
Setting model stored system settings.
SettingCategory is a category for system settings.
User !.
UserGroup !.
UserPermission !.
# Interfaces
APIDisabledAdder is an interface for models to disable access to add function in dAPI.
APIDisabledDeleter is an interface for models to disable access to delete function in dAPI.
APIDisabledEditor is an interface for models to disable access to edit function in dAPI.
APIDisabledReader is an interface for models to disable access to read function in dAPI.
APIDisabledSchemer is an interface for models to disable access to schema function in dAPI.
APILogAdder is an interface for models to control logging their add function in dAPI.
APILogDeleter is an interface for models to control logging their delete function in dAPI.
APILogEditor is an interface for models to control logging their edit function in dAPI.
APILogReader is an interface for models to control logging their read function in dAPI.
APILogSchemer is an interface for models to control logging their schema function in dAPI.
APIPostQueryAdder is an interface for models to run after processing add function in dAPI and before returning the results.
APIPostQueryDeleter is an interface for models to run after processing delete function in dAPI and before returning the results.
APIPostQueryEditor is an interface for models to run after processing edit function in dAPI and before returning the results.
APIPostQueryReader is an interface for models to run after processing read function in dAPI and before returning the results.
APIPostQuerySchemer is an interface for models to run after processing schema function in dAPI and before returning the results.
APIPreQueryAdder is an interface for models to run before processing add function in dAPI.
APIPreQueryDeleter is an interface for models to run before processing delete function in dAPI.
APIPreQueryEditor is an interface for models to run before processing edit function in dAPI.
APIPreQueryReader is an interface for models to run before processing read function in dAPI.
APIPreQuerySchemer is an interface for models to run before processing schema function in dAPI.
APIPublicAdder is an interface for models to control public access to add function in dAPI.
APIPublicDeleter is an interface for models to control public access to delete function in dAPI.
APIPublicEditor is an interface for models to control public access to read function in dAPI.
APIPublicReader is an interface for models to control public access to read function in dAPI.
APIPublicSchemer is an interface for models to control public access to schema function in dAPI.
No description provided by the author
GetImageSizer can be inplemented for any model to customize the image size uploaded to that model.
HideInDashboarder used to check if a model should be hidden in dashboard.
SchemaCategory provides a default category for the model.
# Type aliases
ABTestType is the type of the AB testing: model or static.
Action !.
ApprovalAction is a selection of approval actions.
CKey is the standard key used in uAdmin for context keys.
DataType is a list of data types used for settings.
FieldList is a list of fields from schema for a registered model.
FieldType for field type in builder field.
ModelList a list of registered models.
No description provided by the author