hera_models

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AvailableFormats = []string{
		"{{ .NameOfUser }}",
		"{{ .Code }}",
	}
	AvailableTemplates = []*models.Template{
		{Type: models.TemplateType_EMAIL_VERIFICATION_TEMPLATE, Format: AvailableFormats, Enabled: false},
		{Type: models.TemplateType_EMAIL_RESET_PASSWORD_TEMPLATE, Format: AvailableFormats, Enabled: false},
		{Type: models.TemplateType_EMAIL_MAGIC_LINK_TEMPLATE, Format: AvailableFormats, Enabled: false},
		{Type: models.TemplateType_TEXT_VERIFICATION_TEMPLATE, Format: AvailableFormats, Enabled: false},
		{Type: models.TemplateType_TEXT_RESET_PASSWORD_TEMPLATE, Format: AvailableFormats, Enabled: false},
		{Type: models.TemplateType_TEXT_MAGIC_LINK_TEMPLATE, Format: AvailableFormats, Enabled: false},
	}
)
View Source
var (
	AvailableOidcProviders = []*models.OidcProvider{
		{
			Type: models.OidcProviderType_NUNTIO_PROVIDER,
			Name: "Nuntio",
			Logo: "",
		},
		{
			Type: models.OidcProviderType_GOOGLE_PROVIDER,
			Name: "Google",
			Logo: "",
		},
	}
)

Functions

func ConfigToProtoConfig

func ConfigToProtoConfig(config *Config) *models.HeraConfig

func ContactToProto

func ContactToProto(contact *Contact) *models.Contact

func GroupToProto

func GroupToProto(group *Group) *models.Group

func HashToProto

func HashToProto(hash *Hash) *models.Hash

func ImageToProto

func ImageToProto(image *Image) *models.Image

func OidcProviderToProto

func OidcProviderToProto(provider *OidcProvider) *models.OidcProvider

func TemplateToProto

func TemplateToProto(template *Template) *models.Template

func TokenToProtoToken

func TokenToProtoToken(token *Token) *models.Token

func TokensToProto

func TokensToProto(tokens []*Token) []*models.Token

func UserToProto

func UserToProto(user *User) *models.User

func UsersToProto

func UsersToProto(users []*User) []*models.User

func VerificationCodeToProto

func VerificationCodeToProto(verificationCode *VerificationCode) *models.VerificationCode

Types

type Bcrypt

type Bcrypt struct {
	Cost int `bson:"cost" json:"cost"`
}

type Config

type Config struct {
	Id                       string                   `bson:"_id" json:"_id"`
	Name                     string                   `bson:"name" json:"name"`
	EnableSignup             bool                     `bson:"enable_signup" json:"enable_signup"`
	EnableLogin              bool                     `bson:"enable_login" json:"enable_login"`
	CreatedAt                time.Time                `bson:"created_at" json:"created_at"`
	UpdatedAt                time.Time                `bson:"updated_at" json:"updated_at"`
	ValidatePassword         bool                     `bson:"validate_password" json:"validate_password"`
	PublicKey                string                   `bson:"public_key" json:"public_key"`
	HashingAlgorithm         models.HashingAlgorithm  `bson:"hashing_algorithm" json:"hashing_algorithm"`
	Bcrypt                   *Bcrypt                  `bson:"bcrypt" json:"bcrypt"`
	Scrypt                   *Scrypt                  `bson:"scrypt" json:"scrypt"`
	OidcProviders            map[string]*OidcProvider `bson:"oidc_providers" json:"oidc_providers"`
	SupportedLoginMechanisms []models.LoginType       `bson:"supported_login_mechanisms" json:"supported_login_mechanisms"`
	Templates                map[string]*Template     `bson:"templates" json:"templates"`
	AccessTokenExpiry        int32                    `bson:"access_token_expiry" json:"access_token_expiry"`
	RefreshTokenExpiry       int32                    `bson:"refresh_token_expiry" json:"refresh_token_expiry"`
	VerificationCodeExpiry   int32                    `bson:"verification_code_expiry" json:"verification_code_expiry"`
	PasswordUpdatedAt        time.Time                `bson:"password_updated_at" json:"password_updated_at"`
	Callbacks                []string                 `bson:"callbacks" json:"callbacks"`
}

func ProtoConfigToConfig

func ProtoConfigToConfig(config *models.HeraConfig) *Config

type Contact

type Contact struct {
	Id         string    `bson:"_id" json:"_id"`
	FromUserId string    `bson:"from_user_id" json:"from_user_id"`
	ToUserId   string    `bson:"to_user_id" json:"to_user_id"`
	From       *User     `bson:"from" json:"from"`
	To         *User     `bson:"to" json:"to"`
	Accepted   bool      `bson:"accepted" json:"accepted"`
	AcceptedAt time.Time `bson:"accepted_at" json:"accepted_at"`
	SentAt     time.Time `bson:"sent_at" json:"sent_at"`
}

func ProtoToContact

func ProtoToContact(contact *models.Contact) *Contact

type Group

type Group struct {
	Id        string    `bson:"_id" json:"_id"`
	Name      string    `bson:"name" json:"name"`
	CreatedAt time.Time `bson:"created_at"  json:"created_at"`
	UpdatedAt time.Time `bson:"updated_at"  json:"updated_at"`
}

func ProtoToGroup

func ProtoToGroup(group *models.Group) *Group

type Hash

type Hash struct {
	Variant models.HashingAlgorithm `json:"variant,omitempty"`
	Body    string                  `json:"body,omitempty"`
	Params  map[string]string       `json:"params,omitempty"`
}

func ProtoToHash

func ProtoToHash(hash *models.Hash) *Hash

type Image

type Image struct {
	Url       string    `json:"url,omitempty"`
	ExpiresAt time.Time `json:"updated_at,omitempty"`
	Expires   bool      `json:"expires,omitempty"`
	Key       string    `json:"key,omitempty"`
}

func ProtoToImage

func ProtoToImage(image *models.Image) *Image

func (*Image) GetExpiresAt

func (i *Image) GetExpiresAt() time.Time

func (*Image) GetUrl

func (i *Image) GetUrl() string

type OidcProvider

type OidcProvider struct {
	Id      string                  `bson:"id,omitempty" json:"id,omitempty"`
	Secret  string                  `bson:"secret,omitempty" json:"secret,omitempty"`
	Name    string                  `bson:"name,omitempty" json:"name,omitempty"`
	Enabled bool                    `bson:"enabled,omitempty" json:"enabled,omitempty"`
	Url     string                  `bson:"url,omitempty" json:"url,omitempty"`
	Type    models.OidcProviderType `bson:"type,omitempty" json:"type,omitempty"`
	Scopes  []string                `bson:"scopes,omitempty" json:"scopes,omitempty"`
}

func ProtoToOidcProvider

func ProtoToOidcProvider(provider *models.OidcProvider) *OidcProvider

type Scrypt

type Scrypt struct {
	SignerKey     string `bson:"signer_key,omitempty" json:"signer_key,omitempty"`
	SaltSeparator string `bson:"salt_separator,omitempty" json:"salt_separator,omitempty"`
	Rounds        int    `bson:"rounds,omitempty" json:"rounds,omitempty"`
	MemCost       int    `bson:"mem_cost,omitempty" json:"mem_cost,omitempty"`
	P             int    `bson:"p,omitempty" json:"p,omitempty"`
	KeyLen        int    `bson:"key_len,omitempty" json:"key_len,omitempty"`
}

type ScryptHera

type ScryptHera struct {
	SignerKey     string `bson:"signer_key" json:"signer_key"`
	SaltSeparator string `bson:"salt_separator" json:"salt_separator"`
	Rounds        int    `bson:"rounds" json:"rounds"`
	MemCost       int    `bson:"mem_cost" json:"mem_cost"`
	P             int    `bson:"p" json:"p"`
	KeyLen        int    `bson:"key_len" json:"key_len"`
}

type Template

type Template struct {
	Id      string              `bson:"_id" json:"_id"`
	Body    string              `bson:"body" json:"body"`
	Subject string              `bson:"subject" json:"subject"`
	Type    models.TemplateType `bson:"type" json:"type"`
	Enabled bool                `bson:"enabled" json:"enabled"`
}

func ProtoToTemplate

func ProtoToTemplate(template *models.Template) *Template

type Token

type Token struct {
	Id               string                  `bson:"_id" json:"_id"`
	UserId           string                  `bson:"user_id,omitempty" json:"user_id,omitempty"`
	Blocked          bool                    `bson:"blocked,omitempty" json:"blocked,omitempty"`
	DeviceInfo       string                  `bson:"device_info,omitempty" json:"device_info,omitempty"`
	LoggedInFrom     string                  `bson:"logged_in_from,omitempty" json:"logged_in_from,omitempty"`
	TokenType        models.TokenType        `bson:"token_type,omitempty" json:"token_type,omitempty"`
	LoginType        models.LoginType        `bson:"login_type,omitempty" json:"login_type,omitempty"`
	PlatformType     models.PlatformType     `bson:"platform_type,omitempty" json:"platform_type,omitempty"`
	OidcProviderType models.OidcProviderType `bson:"oidc_provider_type,omitempty" json:"oidc_provider_type,omitempty"`
	BlockedAt        time.Time               `bson:"blocked_at,omitempty" json:"blocked_at,omitempty"`
	CreatedAt        time.Time               `bson:"created_at,omitempty" json:"created_at,omitempty"`
	UsedAt           time.Time               `bson:"used_at,omitempty" json:"used_at,omitempty"`
	ExpiresAt        time.Time               `bson:"expires_at,omitempty" json:"expires_at,omitempty"` // unix time
}

func ProtoTokenToToken

func ProtoTokenToToken(token *models.Token) *Token

type User

type User struct {
	Id                   string             `bson:"_id" json:"_id"`
	Username             string             `bson:"username,omitempty" json:"username,omitempty"`
	Email                string             `bson:"email,omitempty" json:"email,omitempty"`
	Password             *Hash              `bson:"password,omitempty" json:"password,omitempty"`
	ProfileImage         *Image             `bson:"profile_image,omitempty" json:"profile_image,omitempty"`
	CoverImage           *Image             `bson:"cover_image,omitempty" json:"cover_image,omitempty"`
	CreatedAt            time.Time          `bson:"created_at,omitempty" json:"created_at,omitempty"`
	UpdatedAt            time.Time          `bson:"updated_at,omitempty" json:"updated_at,omitempty"`
	FirstName            string             `bson:"first_name,omitempty" json:"first_name,omitempty"`
	LastName             string             `bson:"last_name,omitempty" json:"last_name,omitempty"`
	Birthdate            string             `bson:"birthdate,omitempty" json:"birthdate,omitempty"`
	VerifiedEmails       []string           `bson:"verified_emails,omitempty" json:"verified_emails,omitempty"`
	EmailHash            string             `bson:"email_hash,omitempty" json:"email_hash,omitempty"`
	Phone                string             `bson:"phone,omitempty" json:"phone,omitempty"`
	PhoneHash            string             `bson:"phone_hash,omitempty" json:"phone_hash,omitempty"`
	VerifiedPhoneNumbers []string           `bson:"verified_phone_numbers,omitempty" json:"verified_phone_numbers,omitempty"`
	PreferredLanguage    models.CountryCode `bson:"preferred_language,omitempty" json:"preferred_language,omitempty"`
	UsernameHash         string             `bson:"username_hash,omitempty" json:"username_hash,omitempty"`
	Gender               string             `bson:"gender,omitempty" json:"gender,omitempty"`
	Country              string             `bson:"country,omitempty" json:"country,omitempty"`
	Address              string             `bson:"address,omitempty" json:"address,omitempty"`
	City                 string             `bson:"city,omitempty" json:"city,omitempty"`
	PostalCode           string             `bson:"postal_code,omitempty" json:"postal_code,omitempty"`
	Role                 string             `bson:"role,omitempty" json:"role,omitempty"`
	Ssn                  string             `bson:"ssn,omitempty" json:"ssn,omitempty"`
	RegistrationType     models.LoginType   `bson:"registration_type,omitempty" json:"registration_type,omitempty"`
	ContactAccepted      bool               `bson:"contact_accepted,omitempty" json:"contact_accepted,omitempty"`
	Groups               []*Group           `bson:"groups,omitempty" json:"groups,omitempty"`
}

func ProtoToUser

func ProtoToUser(user *models.User) *User

func ProtoToUsers

func ProtoToUsers(users []*models.User) []*User

type VerificationCode

type VerificationCode struct {
	Id          string                  `bson:"_id" json:"_id"`
	Code        *Hash                   `bson:"code" json:"code"`
	SentAt      time.Time               `bson:"sent_at" json:"sent_at"`
	ExpiresAt   time.Time               `bson:"expires_at" json:"expires_at"`    // unix time
	LastAttempt time.Time               `bson:"last_attempt" json:"LastAttempt"` // unix time
	Attempts    int32                   `bson:"attempts" json:"attempts"`
	UserId      string                  `bson:"user_id" json:"user_id"`
	Type        models.VerificationType `bson:"verification_type" json:"verification_type"`
}

func ProtoToVerificationCode

func ProtoToVerificationCode(verificationCode *models.VerificationCode) *VerificationCode

Jump to

Keyboard shortcuts

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