internal

package
v0.0.0-...-589e68f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PS is the postscript which may optionally be added to a message
	PS = `

P.S. your account will be automatically banned if you reply to this email`
)

Variables

View Source
var (
	// Hub is a reference to the hub object initially passed to the module. It is here so other packages may access it.
	Hub *hub.Hub
	// QRsecret returns the string form of of the OTP url which will be turned into a QR code
	QRsecret = "otpauth://totp/%s (%s)?secret=%s"
)

Functions

func AllowRegistration

func AllowRegistration() bool

AllowRegistration analyzes the configuration and returns true registration is open

func BuildStatement

func BuildStatement() *persistence.StatementBuilder

BuildStatement is a shortcut to the persistence method

func Disconnected

func Disconnected(hub *hub.Hub, delegate core.PostEndpoint, data interface{}) core.Poster

Disconnected takes in a delegate post endpoint and verifies that a user is not logged in before running the delegate

func ParseRecoveryMessage

func ParseRecoveryMessage(name, token string) *core.Message

ParseRecoveryMessage prepares a message for when an account needs to be recovered

func ParseRegistrationMessage

func ParseRegistrationMessage(name, token string) *core.Message

ParseRegistrationMessage prepares a message for when an account registration is attempted

func RawStatement

func RawStatement() *persistence.RawStatement

RawStatement is a shortcut to the persistence method

func ShouldUsePassword

func ShouldUsePassword() bool

ShouldUsePassword analyzes the configuration and returns true if a password should be used during authentication

func ShouldUseTOTP

func ShouldUseTOTP() bool

ShouldUseTOTP analyzes the configuration and returns true if TOTP should be used during authentication

Types

type Configuration

type Configuration struct {
	// Host describes configuration options dealing with the host server
	Host struct {
		// Hostname is the hostname of the server which will run sol
		Hostname string `json:"hostname"`
		// Cookies is the secret string used to pad the encrypted session strings. Reset it to invalidate all connections
		Cookies string `json:"cookies"`
	} `json:"host"`
	// Sol describes configuration options specific to sol
	Sol struct {
		// TOTPMode determines how sol will use TOTP. It can be completely disabled, required, or preferred over passwords
		TOTPMode string `json:"totpMode" values:"disabled,required,prefer"`
		// AppendPS determines whether the PS will be appended to messages Sol makes to send to users
		AppendPS bool `json:"appendPS" optional:"true"`
		// DelayConfirmation will enable users to complete registration without first validating their email address
		DelayConfirmation bool `json:"delayConfirmation" optional:"true"`
		// AutoLogin will automatically log new users in when they register
		AutoLogin bool `json:"autoLogin" optional:"true"`
		// RestrictRegistration will make it so that no one is able to register if set to true
		RestrictRegistration bool `json:"restrictRegistration" optional:"true"`
	} `json:"sol"`
	// Sql describes the connection information for the main SQL server
	SQL struct {
		// Host is the hostname or IP of the SQL server
		Host string `json:"host"`
		// Port is the port to be used to connect to the SQL server
		Port int `json:"port"`
		// Password is the password which is required to connect to the SQL server, this setting is option for if no password
		// is required
		Password string `json:"password" optional:"true"`
		// Database is the database which should be connected to
		Database string `json:"database"`
		// Username is the username required to connect to the database
		Username string `json:"username"`
		// Sslmode describes which postgres SQL Mode should be used when the database is connected to
		Sslmode string `json:"sslmode" values:"disable,allow,prefer,require,verify-ca,verify-full"`
	} `json:"sql"`
}

Configuration is the model of various configuration options

var Config Configuration

Config stores all of the configuration information for each package to be able to read

type CookieJar

type CookieJar struct {
	// contains filtered or unexported fields
}

CookieJar holds all of the cookies

func GetCookieJar

func GetCookieJar() *CookieJar

GetCookieJar is a singleton constructor for a CookieJar

func (*CookieJar) ExpireNow

func (cj *CookieJar) ExpireNow(r *http.Request, w http.ResponseWriter) error

ExpireNow expires a session immediately

func (*CookieJar) GetReceipt

func (cj *CookieJar) GetReceipt(r *http.Request, name string) string

GetReceipt returns the receipt from a session with a given name

func (*CookieJar) SetReceipt

func (cj *CookieJar) SetReceipt(r *http.Request, w http.ResponseWriter, receipt string) error

SetReceipt sets a receipt to a session

type LoginData

type LoginData struct {
	Username string `json:"username"`
	Password string `json:"password"`
	OTP      string `json:"totp"`
}

LoginData is a model for the request made when someone attempts to login

type RegisterData

type RegisterData struct {
	Username     string `json:"username"`
	Password     string `json:"password"`
	Confirm      string `json:"confirm"`
	Email        string `json:"email"`
	Registration string `json:"registration"`
}

RegisterData is a model for the request made when someone attempts to register ass a user

type Reset

type Reset struct {
	Username string `json:"username"`
	Password string `json:"password"`
	Confirm  string `json:"confirm"`
	Token    string `json:"token"`
}

Reset is used for password resets

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL