services

package
v0.0.0-...-0ddd045 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package services provides different services which combine functions from modules and the store interface

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultExpireTimespan describes the default expire timespan of an invite
	DefaultExpireTimespan = time.Hour * 24 * 7
)

Functions

This section is empty.

Types

type AuthService

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

AuthService wraps authentication dependencies

func NewAuthService

func NewAuthService(store *store.Store, config *config.Config, logger *log.Logger) AuthService

NewAuthService returns a new authentication service

func (AuthService) ComparePassword

func (s AuthService) ComparePassword(input, hashed string) (bool, error)

ComparePassword returns if the input and the real password match

func (AuthService) GenerateTOTP

func (s AuthService) GenerateTOTP(issuer, account string) (twofa.TOTPKey, error)

GenerateTOTP generates a new TOTP

func (AuthService) GenerateVerifyToken

func (s AuthService) GenerateVerifyToken() (string, error)

GenerateVerifyToken generates a random verify token

func (AuthService) HashPassword

func (s AuthService) HashPassword(password string) (string, error)

HashPassword returns the Argon2-hashed password or an error

func (AuthService) Login

func (s AuthService) Login(c echo.Context) (string, error)

Login handles the login process of a user

func (AuthService) NewJWT

func (s AuthService) NewJWT(secret string, c *jwt.Claims) *jwt.JWT

NewJWT returns a new JWT

func (AuthService) ParseJWT

func (s AuthService) ParseJWT(input, key string, c jwt.Claims) (*jwt.JWT, error)

ParseJWT parses a JWT

func (AuthService) Register

func (s AuthService) Register(c echo.Context) error

Register handles the registration process of a new user

func (AuthService) ValidateTOTP

func (s AuthService) ValidateTOTP(code, secret string) bool

ValidateTOTP validates a 6 digit TOTP code

type CallService

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

func NewCallService

func NewCallService() CallService

func (CallService) NewCall

func (s CallService) NewCall(username, roomHash string, w http.ResponseWriter, r *http.Request) error

type InviteService

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

InviteService provides a service to create, get and delete invites

func NewInviteService

func NewInviteService(store *store.Store, config *config.Config, logger *log.Logger) InviteService

NewInviteService returns a new invite service

func (InviteService) CreateInvite

func (s InviteService) CreateInvite(username string, c echo.Context) (*models.Invite, error)

CreateInvite creates a new invite link

type RoomService

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

RoomService provides a service to create, get, update and delete rooms

func NewRoomService

func NewRoomService(store *store.Store, logger *log.Logger) RoomService

NewRoomService returns a new room service

func (RoomService) CreateRoom

func (s RoomService) CreateRoom(c echo.Context) error

CreateRoom creates and inserts a new room into the database

func (RoomService) DeleteRoom

func (s RoomService) DeleteRoom(c echo.Context) error

DeleteRoom deletes ONE room from the database identified by the provided room hash

func (RoomService) GetRoom

func (s RoomService) GetRoom(c echo.Context) (*models.Room, error)

GetRoom returns ONE room from the database identified by the provided hash

func (RoomService) GetRooms

func (s RoomService) GetRooms() ([]models.Room, error)

GetRooms returns multiple rooms from the database

func (RoomService) UpdateRoom

func (s RoomService) UpdateRoom(c echo.Context) error

UpdateRoom updates ONE room in the database indentified by the provided hash

type ServerService

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

ServerService wraps dependencies

func NewServerService

func NewServerService(store *store.Store, logger *log.Logger) ServerService

NewServerService returns a new server service

func (ServerService) CreateServer

func (s ServerService) CreateServer(c echo.Context) error

CreateServer creates a new virtual server

func (ServerService) DeleteServer

func (s ServerService) DeleteServer(hash string) error

DeleteServer deletes one virtual server dentified by 'hash'

func (ServerService) GetServer

func (s ServerService) GetServer(c echo.Context) (*models.Server, error)

GetServer returns one virtual server identified by 'hash'

func (ServerService) GetServers

func (s ServerService) GetServers() ([]models.Server, error)

GetServers returns all virtual servers

func (ServerService) UpdateServer

func (s ServerService) UpdateServer(hash string) error

UpdateServer updates one virtual server identified by 'hash'

type UserService

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

UserService is the top-level service struct

func NewUserService

func NewUserService(s *store.Store, c *config.Config) UserService

NewUserService returns a new user service

func (UserService) CreateUser

func (s UserService) CreateUser(user models.PublicUser) error

CreateUser creates a new 'user' or returns an error if the new user could not be created

func (UserService) GetUser

func (s UserService) GetUser(username string) (models.User, error)

GetUser returns a user identified by the provided 'username' or an error if the user does not exist

func (UserService) GetUserPublicKey

func (s UserService) GetUserPublicKey(username string) (string, error)

func (UserService) PutUserServer

func (s UserService) PutUserServer(username string) ([]models.Server, error)

func (UserService) UpdateTwoFAVerify

func (s UserService) UpdateTwoFAVerify(username, verify string) error

Directories

Path Synopsis
Package errors provides service level errors
Package errors provides service level errors

Jump to

Keyboard shortcuts

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