middleware

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//RouterPortKey the key of the router port entry in serverconfig table
	RouterPortKey = "http_port"
	//DenyLimitKey the key of the deny limit entry in serverconfig table
	DenyLimitKey = "deny_limit"
	//RootTokenKey is the key of the root token entry in serverconfig table
	RootTokenKey = "root_token"
	//VerifyTokenKey is the key of the verify token entry in serverconfig table
	VerifyTokenKey = "verify_tokens"
	//SchemaVersionKey is the key of the schema version entry in serverconfig table
	SchemaVersionKey = "schema_version"
	//SecretFilePath location of the root key
	SecretFilePath string = "/opt/go-tiny-mfa/secrets/key"
	//RootTokenFilePath location of the root-token export
	RootTokenFilePath string = "/opt/go-tiny-mfa/secrets/root-token.readanddelete"
)
View Source
const (
	CurrentSchemaVersion uint8 = 2
)

Variables

This section is empty.

Functions

func CheckSchemaUpgrade

func CheckSchemaUpgrade(version uint8) bool

func CreateAuditEntry

func CreateAuditEntry(user structs.User, validation tinymfa.Validation) error

CreateAuditEntry creates an audit in the database

func CreateConnection

func CreateConnection() (*sql.DB, error)

CreateConnection creates a connection to a postgres DB

func CreateIssuer

func CreateIssuer(issuer structs.Issuer) (structs.IssuerCreation, error)

CreateIssuer inserts a Issuer struct to the database

func CreateUser

func CreateUser(user structs.User) (structs.User, error)

CreateUser inserts a userstruct to the DB

func DeleteIssuer

func DeleteIssuer(issuer structs.Issuer) (bool, error)

DeleteIssuer deletes an issuer from the database

func DeleteToken

func DeleteToken(issuerid, tokenid string) error

DeleteToken deletes all tokens for a given issuer id

func DeleteTokens

func DeleteTokens(issuerid string) error

DeleteTokens deletes all tokens for a given issuer id

func DeleteUser

func DeleteUser(user structs.User) (bool, error)

DeleteUser deletes a user from the database

func DeleteUsers

func DeleteUsers(objectid string) error

DeleteUsers deletes all tokens for a given object id

func GetAuditEntries

func GetAuditEntries(parameters structs.AuditQueryParameter) ([]structs.AuditEntry, error)

GetAuditEntries returns all audit entries from the db

func GetFailedValidationCount

func GetFailedValidationCount(user structs.User, message int64) (int, error)

GetFailedValidationCount returns the number of times a user failed validation for a given message

func GetIssuer

func GetIssuer(issuer string) (structs.Issuer, error)

GetIssuer returns the requested issuer from the database as Issuer struct

func GetIssuerAccessTokens

func GetIssuerAccessTokens(issuer structs.Issuer) ([]structs.TokenEntry, error)

GetIssuerAccessTokens returns all access tokens for a given issuer from the database

func GetIssuerByID

func GetIssuerByID(issuerID string) (structs.Issuer, error)

GetIssuerByID returns the requested issuer from the database as Issuer struct

func GetIssuerKey

func GetIssuerKey(issuer structs.Issuer) ([]byte, error)

GetIssuerKey returns the decrypted issuer key as byte array

func GetIssuers

func GetIssuers() ([]structs.Issuer, error)

GetIssuers returns all Issuers from the database

func GetOidcConfiguration added in v0.2.4

func GetOidcConfiguration() (structs.OidcConfig, error)

GetOidcConfiguration returns the oidc configuration

func GetQrCodeConfiguration

func GetQrCodeConfiguration() (structs.QrCodeConfig, error)

GetQrCodeConfiguration returns the configured qr colors

func GetRootKey

func GetRootKey() ([]byte, error)

GetRootKey retrieves the key generated on system initialization

func GetSchemaVersion

func GetSchemaVersion() (uint8, error)

func GetSystemConfiguration

func GetSystemConfiguration() (structs.ServerConfig, error)

GetSystemConfiguration returns the system config

func GetSystemProperty

func GetSystemProperty(key string) (string, error)

GetSystemProperty returns the value for the given key

func GetTokenLength

func GetTokenLength(issuer structs.Issuer) (uint8, error)

GetTokenLength returns the length of the desired token

func GetUser

func GetUser(user string, issuer structs.Issuer) (structs.User, error)

GetUser returns a User struct from the database

func GetUserKey

func GetUserKey(user structs.User) ([]byte, error)

GetUserKey returns the decrypted user key as byte array

func GetUserKeyBase32

func GetUserKeyBase32(user structs.User) (string, error)

GetUserKeyBase32 returns the decrypted user key in base32 encoding

func GetUsers

func GetUsers(issuer structs.Issuer) ([]structs.User, error)

GetUsers returns all users for a given issuer

func InitializeSystem

func InitializeSystem() error

InitializeSystem will initialize the database and the root key

func InsertToken

func InsertToken(token structs.Token) error

InsertToken inserts an access token to the database

func PingDatabase

func PingDatabase() error

PingDatabase tries to establish a connection

func UpdateIssuer

func UpdateIssuer(issuer structs.Issuer) (bool, error)

UpdateIssuer updates an existing issuer

func UpdateOidcConfiguration added in v0.2.4

func UpdateOidcConfiguration(oidcconfig structs.OidcConfig) (structs.OidcConfig, error)

UpdateOidcConfiguration returns the oidc configuration

func UpdateQrCodeConfiguration

func UpdateQrCodeConfiguration(qrcodeconfig structs.QrCodeConfig) (structs.QrCodeConfig, error)

UpdateQrCodeConfiguration returns the configured qr colors

func UpdateSystemConfiguration

func UpdateSystemConfiguration(config structs.ServerConfig) (structs.ServerConfig, error)

UpdateSystemConfiguration updates the system configuration

func UpdateUser

func UpdateUser(user structs.User) (bool, error)

UpdateUser updates an existing user

func UpgradeSchema

func UpgradeSchema(version uint8) (uint8, error)

func ValidateToken

func ValidateToken(issuer structs.Issuer, submittedToken string) (bool, error)

ValidateToken returns true if a token could be looked up in the db

Types

This section is empty.

Jump to

Keyboard shortcuts

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