domain

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeInstant   = 1
	TypeScheduled = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Credentials *Credentials
}

Auth contains the credentials needed to begin the authentication process.

type AuthClaims

type AuthClaims struct {
	jwt.StandardClaims
	UserID uint   `json:"user_id"`
	Usage  string `json:"usage"`
}

AuthClaims are the claims that are part of an AuthToken.

type AuthService

type AuthService interface {
	IsAuthenticated(token TokenValue) (bool, error)
	Authenticate(auth Auth) (*TokenSet, error)
	RefreshToken(token TokenValue) (*TokenSet, error)
	Deauthenticate(token TokenValue) error
	GetUserFromAuthToken(token TokenValue) (*User, error)
}

AuthService manages authentication based on Auths and Tokens.

type AuthToken

type AuthToken struct {
	Value     TokenValue
	Expires   time.Time
	JWTClaims AuthClaims
}

AuthToken represents a JWT used for authentication.

type ConfiguredPlatforms

type ConfiguredPlatforms []*MeetingPlatform

ConfiguredPlatforms are a slice of MeetingPlatforms that are configured for the application.

type CookieService

type CookieService interface {
	SetCookie(g *gin.Context, name string, value string, maxAge int, path string, httpOnly bool)
}

CookieService manages operations on HTTP cookies.

type Credentials

type Credentials struct {
	Username string
	Password string
}

Credentials represents a username and password combination.

type Health

type Health struct {
	Healthy bool
	Reason  string
}

Health contains information about the health of the application.

type HealthService

type HealthService interface {
	GetHealth() (*Health, error)
}

HealthService manages retrieving the health status of the application.

type Invite

type Invite struct {
	gorm.Model
	MeetingID          string
	MeetingStartTime   time.Time
	MeetingDuration    MeetingDuration
	MeetingTitle       string
	MeetingDescription string
	MeetingPlatformID  uint
	MeetingJoinURL     string
	InviterID          uint
	InviteeID          uint
}

type InviteRepository

type InviteRepository interface {
	Create(invite *Invite) (uint, error)
	GetByID(ID uint) (*Invite, error)
	GetAllByInvitee(inviteeID uint) ([]*Invite, error)
	GetAllByInviter(inviteeID uint) ([]*Invite, error)
	DeleteAllByMeetingID(meetingID string) error
	Delete(ID uint) error
}

type InviteRequest

type InviteRequest struct {
	MeetingID         string
	InviterID         uint
	InviteeUsername   string
	MeetingPlatformID uint
}

type InviteService

type InviteService interface {
	SendInvite(invite *InviteRequest) (uint, error)
	GetAllReceivedInvites(userID uint) ([]*Invite, error)
	GetAllSentInvites(userID uint) ([]*Invite, error)
	GetInvite(inviteID uint) (*Invite, error)
	DeleteInvite(inviteID uint) error
	DeleteAllInvitesByMeetingID(meetingID string) error
}

type Meeting

type Meeting struct {
	ID          string
	Title       string
	StartTime   time.Time
	Duration    time.Duration
	Description string
	JoinURL     string
	StartURL    string
	Type        int
}

Meeting represents a meeting on a MeetingPlatform.

type MeetingDuration

type MeetingDuration time.Duration

func (*MeetingDuration) Scan

func (m *MeetingDuration) Scan(src interface{}) error

func (MeetingDuration) Value

func (m MeetingDuration) Value() (driver.Value, error)

type MeetingPlatform

type MeetingPlatform struct {
	gorm.Model
	Name    string
	OAuth   MeetingPlatformOAuthInfo `gorm:"-"`
	Actions MeetingPlatformActions   `gorm:"-"`
}

MeetingPlatform represents an external MeetingPlatform.

type MeetingPlatformActions

type MeetingPlatformActions interface {
	CreateMeeting(oauth OAuthInfo, meeting *Meeting) (*Meeting, error)
	GetMeetings(oauth OAuthInfo, pageReq PageRequest) (*Page, error)
	GetMeeting(oauth OAuthInfo, meetingID string) (*Meeting, error)
	DeleteMeeting(oauth OAuthInfo, meetingID string) error
}

MeetingPlatformActions are implementations of the MeetingPlatform's API.

type MeetingPlatformOAuthInfo

type MeetingPlatformOAuthInfo struct {
	Config oauth2.Config
}

MeetingPlatformOAuthInfo contains configuration information about the MeetingPlatform's OAuth implementation.

type MeetingPlatformRepository

type MeetingPlatformRepository interface {
	Create(platform *MeetingPlatform) (uint, error)
	GetAll() ([]*MeetingPlatform, error)
	GetByID(ID uint) (*MeetingPlatform, error)
	GetByPlatformName(name string) (*MeetingPlatform, error)
	Update(platform *MeetingPlatform) error
	Delete(ID uint) error
}

MeetingPlatformRepository stores information about MeetingPlatforms.

type MeetingPlatformService

type MeetingPlatformService interface {
	Save(platform *MeetingPlatform) (uint, error)
	GetAll() ([]*MeetingPlatform, error)
	Delete(ID uint) error
	GetByID(ID uint) (*MeetingPlatform, error)
	GetByPlatformName(name string) (*MeetingPlatform, error)
	GetOAuthToken(ctx context.Context, authorization string, platform *MeetingPlatform) (*oauth2.Token, error)
	RefreshOAuthToken(ctx context.Context, token *oauth2.Token, platform *MeetingPlatform) (*oauth2.Token, error)
}

MeetingPlatformServices manages CRUD operations on a MeetingPlatform as well as OAuth.

type OAuthInfo

type OAuthInfo struct {
	gorm.Model
	UserID            uint
	MeetingPlatformID uint
	AccessToken       string
	RefreshToken      string
	TokenType         string
	Expiry            time.Time
}

OAuthInfo represents OAuth token information.

func (OAuthInfo) TableName

func (O OAuthInfo) TableName() string

TableName returns the table name that is used in the database for OAuthInfos.

type OAuthInfoRepository

type OAuthInfoRepository interface {
	Create(oauthToken *OAuthInfo) (uint, error)
	GetAll() ([]*OAuthInfo, error)
	GetByID(ID uint) (*OAuthInfo, error)
	GetAllByMeetingPlatformID(ID uint) ([]*OAuthInfo, error)
	GetAllByUserID(userID uint) ([]*OAuthInfo, error)
	GetByUserIDAndMeetingPlatformID(userID uint, meetingPlatformID uint) (*OAuthInfo, error)
	Update(oauthToken *OAuthInfo) error
	Delete(ID uint) error
}

OAuthInfoRepository manages storing and retrieving OAuthInfos.

type OAuthInfoService

type OAuthInfoService interface {
	CreateOAuthInfo(ctx context.Context, authorization string, userID uint, platform *MeetingPlatform) error
	GetOAuthInfo(userID uint, platform *MeetingPlatform) (*OAuthInfo, error)
	GetAllAuthenticatedPlatforms(userID uint) ([]*MeetingPlatform, error)
}

OAuthInfoService manages the creation and retrieval of OAuthInfos for a User.

type Page

type Page struct {
	PageCount         int
	PageNumber        int
	PageSize          int
	TotalRecords      int
	NextPageToken     string
	PreviousPageToken string
	Records           []interface{}
}

Page represents a paginated response.

type PageRequest

type PageRequest struct {
	PageSize      int
	RequestedPage string
}

PageRequest represents a paginated request.

type Password

type Password struct {
	Hash []byte
	// contains filtered or unexported fields
}

Password represents both a plaintext and hased password.

func NewPassword

func NewPassword(plaintext string) *Password

NewPassword creates a new Password based on the plaintext given.

func (*Password) HashPassword

func (p *Password) HashPassword() ([]byte, error)

HashPassword hashes and salts the password.

func (*Password) Scan

func (p *Password) Scan(src interface{}) error

Scan takes the given src as a []byte and stores it in Hash.

func (*Password) Value

func (p *Password) Value() (driver.Value, error)

Value returns the stored Hash of the password.

type RefreshClaims

type RefreshClaims struct {
	jwt.StandardClaims
	UserID          uint   `json:"user_id"`
	AuthTokenHash   string `json:"auth_token_hash"`
	ParentTokenHash string `json:"parent_token_hash"`
	Nonce           string `json:"nonce"`
	Usage           string `json:"usage"`
}

RefreshClaims are the claims that are part of a RefreshToken.

type RefreshToken

type RefreshToken struct {
	gorm.Model
	Value           TokenValue `gorm:"column:token_hash"`
	ExpiresAt       time.Time
	TokenNonceHash  string
	ParentTokenHash string
	UserID          uint
	Revoked         bool
	JWTClaims       RefreshClaims `gorm:"-"`
}

RefreshToken represents a JWT used for refreshing AuthTokens.

func (RefreshToken) Hash

func (r RefreshToken) Hash() string

Hash returns the hash of the RefreshToken's Value.

type RefreshTokenRepository

type RefreshTokenRepository interface {
	Create(token RefreshToken) (uint, error)
	GetAll() ([]*RefreshToken, error)
	GetByToken(token RefreshToken) (*RefreshToken, error)
	GetByTokenNonceHash(nonceHash string) (*RefreshToken, error)
	Update(token *RefreshToken) error
	Delete(ID uint) error
}

RefreshTokenRepository stores information about RefreshTokens.

type RefreshTokenService

type RefreshTokenService interface {
	SaveNewRefreshToken(token RefreshToken) (uint, error)
	ReplaceRefreshToken(token RefreshToken) error
	GetLatestTokenInSession(token RefreshToken) (*RefreshToken, error)
	RevokeLatestRefreshTokenByNonce(token RefreshToken) error
}

RefreshTokenService manages operations on RefreshTokens.

type SchemaMigration

type SchemaMigration struct {
	Version int
	Dirty   int
}

SchemaMigration represents the data provided by the go migrate tool.

type SchemaMigrationRepo

type SchemaMigrationRepo interface {
	GetSchemaMigrationByVersion(version int) (*SchemaMigration, error)
	GetSchemaMigration() (*SchemaMigration, error)
}

SchemaMigrationRepo stores information about SchemaMigrations.

type TokenExistsError

type TokenExistsError struct {
	UserID   uint
	Platform string
}

TokenExistsError is an error that occurs when an OAuthInfo already exists for a User and MeetingPlatform combination, but a new OAuthInfo is trying to be created.

func (TokenExistsError) Error

func (t TokenExistsError) Error() string

type TokenSet

type TokenSet struct {
	Auth    AuthToken
	Refresh RefreshToken
}

TokenSet is a set containing an AuthToken and RefreshToken.

type TokenValue

type TokenValue string

func (*TokenValue) Scan

func (r *TokenValue) Scan(src interface{}) error

func (TokenValue) Value

func (r TokenValue) Value() (driver.Value, error)

type User

type User struct {
	gorm.Model
	Firstname string
	Lastname  string
	Username  string
	Password  *Password
}

User represents a user.

type UserRepository

type UserRepository interface {
	Create(user *User) (uint, error)
	GetAll() ([]*User, error)
	GetByID(ID uint) (*User, error)
	GetByUsername(username string) (*User, error)
	Update(user *User) error
	Delete(ID uint) error
}

UserRepository manages storing and retrieving information about a User.

type UserService

type UserService interface {
	Register(user *User) (uint, error)
	Validate(credentials *Credentials) (*User, error)
	GetAll() ([]*User, error)
	GetByID(ID uint) (*User, error)
	GetByUsername(username string) (*User, error)
	Update(user *User) error
	Delete(ID uint) error
}

UserService manages processing information about a User.

Jump to

Keyboard shortcuts

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