misc

package
v0.0.0-...-c6bd9c1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2015 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package misc provides miscellaneous structs and methods used by the application.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidCipherText describes invalid ciphertext
	ErrInvalidCipherText = errors.New("Invalid CipherText")
)
View Source
var (
	// Logger is a accessible logger, providing formatted log messages with different output levels
	Logger *factorlog.FactorLog
)

Functions

func CalculateMessageHMACSHA256

func CalculateMessageHMACSHA256(message string, secret string) string

CalculateMessageHMACSHA256 calculates the HMAC of a message using the SHA256 algorithm and the given secret

func CreateAPIClient

func CreateAPIClient(account *models.Account) *eveapi.API

CreateAPIClient creates an EVE Online API client used for querying API data

func DecryptAndAuthenticate

func DecryptAndAuthenticate(encodedCipherText, secret string) (string, error)

DecryptAndAuthenticate decrypts and authenticates a message using AES-GCM

func EncryptAndAuthenticate

func EncryptAndAuthenticate(message, secret string) (string, error)

EncryptAndAuthenticate encrypts and authenticates a message using AES-GCM

func GenerateRandomString

func GenerateRandomString(length int) string

GenerateRandomString returns a random alphanumerical string with the given length

func SetupLogger

func SetupLogger(debugLevel int)

SetupLogger configures the logger, setting a custom format and output level

func VerifyMessageHMACSHA256

func VerifyMessageHMACSHA256(message string, calculated string, secret string) bool

VerifyMessageHMACSHA256 verifies the received HMAC of a message using the SHA256 algorithm and the given secret

Types

type AuthStatus

type AuthStatus int

AuthStatus represents the result of an authentication attempt by the user

const (
	// AuthStatusUnknown indicates an unknown status during the authentication
	AuthStatusUnknown AuthStatus = iota
	// AuthStatusError indicates an (internal) error during the authentication
	AuthStatusError
	// AuthStatusCredentialMismatch indicates a mismatch of the given passwords and stored bcrypt hash
	AuthStatusCredentialMismatch
	// AuthStatusUnverifiedEmail indicates the user's email address has not been verified yet
	AuthStatusUnverifiedEmail
	// AuthStatusSuccess indicates a successful authentication attempt
	AuthStatusSuccess
)

func (AuthStatus) String

func (authStatus AuthStatus) String() string

String returns an easily readable (string) representation of the AuthStatus

type Configuration

type Configuration struct {
	// DatabaseType represents the database type to be used as a backend
	DatabaseType int
	// DatabaseHost represents the hostname:port of the database backend
	DatabaseHost string
	// DatabaseSchema represents the schema/collection of the database backend
	DatabaseSchema string
	// DatabaseUser represents the username used to authenticate with the database backend
	DatabaseUser string
	// DatabasePassword represents the password used to authenticate with the database backend
	DatabasePassword string
	// RedisHost represents the hostname:port of the Redis data store
	RedisHost string
	// RedisPassword represents the password used to authenticate with the Redis data store
	RedisPassword string
	// RedisDB represents the database to select for the session store
	RedisDB string
	// SMTPHost represents the hostname:port of the SMTP server used for sending mails
	SMTPHost string
	// SMTPStartTLS indicates whether the SMTP connection should use the StartTLS command to secure communications
	SMTPStartTLS bool
	// SMTPUser represents the username used to authenticate with the SMTP server
	SMTPUser string
	// SMTPPassword represents the password used to authenticate with the SMTP server
	SMTPPassword string
	// SMTPSender represents the email address set as the sender of all outgoing emails
	SMTPSender string
	// DebugLevel represents the debug level for log messages
	DebugLevel int
	// DebugTemplates toggles the reloading of all templates for every request
	DebugTemplates bool
	// HTTPHost represents the hostname:port the application should listen to for requests
	HTTPHost string
	// HTTPPublicURL represents the public URL the eveauth app is reachable at
	HTTPPublicURL string
}

Configuration stores all configuration values required by the application

func LoadConfig

func LoadConfig() (*Configuration, error)

LoadConfig creates a Configuration by either using commandline flags or a configuration file, returning an error if the parsing failed

func ParseCommandlineFlags

func ParseCommandlineFlags(config *Configuration) *Configuration

ParseCommandlineFlags parses the command line flags used with the application

func ParseJSONConfig

func ParseJSONConfig(path string) (*Configuration, error)

ParseJSONConfig parses a Configuration from a JSON encoded file, returning an error if the process failed

Jump to

Keyboard shortcuts

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