models

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrIncidentIsNotSet  = "incident is not set"
	ErrIncidentTypeError = "incident type error"
)
View Source
const (
	IncidentType_IllegalAccessAttempt     = 1
	IncidentType_FakeToken                = 2
	IncidentType_VerificationCodeMismatch = 3
	IncidentType_DoubleLogInAttempt       = 4
	IncidentType_PreSessionHacking        = 5
	IncidentType_CaptchaAnswerMismatch    = 6
	IncidentType_PasswordMismatch         = 7
	IncidentType_PasswordChangeHacking    = 8
	IncidentType_EmailChangeHacking       = 9
)
View Source
const (
	ErrLogEventIsNotSet  = "log event is not set"
	ErrLogEventTypeError = "log event type error"
)
View Source
const (
	LogEventType_LogIn  = 1
	LogEventType_LogOut = 2
)
View Source
const (
	IncidentTypesCount = 9
)
View Source
const (
	LogEventTypesCount = 2
)

Variables

This section is empty.

Functions

func CheckIncident

func CheckIncident(inc *Incident) (err error)

func CheckLogEvent

func CheckLogEvent(le *LogEvent) (err error)

Types

type ApproveAndRegisterUserParams

type ApproveAndRegisterUserParams struct {
	cmr.CommonParams

	// E-mail address of an approved user.
	Email string `json:"email"`
}

type ApproveAndRegisterUserResult

type ApproveAndRegisterUserResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type BanUserParams

type BanUserParams struct {
	cmr.CommonParams

	UserId uint `json:"userId"`
}

type BanUserResult

type BanUserResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type ChangeEmailParams

type ChangeEmailParams struct {
	cmr.CommonParams

	// Step number.
	StepN byte `json:"stepN"`

	// New e-mail address.
	// Is used on step 1.
	NewEmail string `json:"newEmail"`

	// Request ID.
	// It protects e-mail changes from being hi-jacked.
	// Is used on step 2.
	RequestId string `json:"requestId"`

	// Authentication data provided for the challenge.
	// Is used on step 2.
	AuthChallengeResponse []byte `json:"authChallengeResponse"`

	// Verification Code for the old e-mail.
	// Is used on step 2.
	VerificationCodeOld string `json:"verificationCodeOld"`

	// Verification Code for the new e-mail.
	// Is used on step 2.
	VerificationCodeNew string `json:"verificationCodeNew"`

	// Captcha answer.
	// This field is optional and may be used on step 2.
	CaptchaAnswer string `json:"captchaAnswer"`
}

type ChangeEmailResult

type ChangeEmailResult struct {
	cmr.CommonResult

	// Next required step.
	// If set to zero, no further step is required.
	NextStep byte `json:"nextStep"`

	RequestId     string `json:"requestId"`
	AuthDataBytes []byte `json:"authDataBytes"`

	// Captcha parameters.
	IsCaptchaNeeded bool   `json:"isCaptchaNeeded"`
	CaptchaId       string `json:"captchaId"`

	// Success flag.
	OK bool `json:"ok"`
}

type ChangePasswordParams

type ChangePasswordParams struct {
	cmr.CommonParams

	// Step number.
	StepN byte `json:"stepN"`

	// New password.
	// Is used on step 1.
	NewPassword string `json:"newPassword"`

	// Request ID.
	// It protects password changes from being hi-jacked.
	// Is used on step 2.
	RequestId string `json:"requestId"`

	// Authentication data provided for the challenge.
	// Is used on step 2.
	AuthChallengeResponse []byte `json:"authChallengeResponse"`

	// Verification Code.
	// Is used on step 2.
	VerificationCode string `json:"verificationCode"`

	// Captcha answer.
	// This field is optional and may be used on step 2.
	CaptchaAnswer string `json:"captchaAnswer"`
}

type ChangePasswordResult

type ChangePasswordResult struct {
	cmr.CommonResult

	// Next required step.
	// If set to zero, no further step is required.
	NextStep byte `json:"nextStep"`

	RequestId     string `json:"requestId"`
	AuthDataBytes []byte `json:"authDataBytes"`

	// Captcha parameters.
	IsCaptchaNeeded bool   `json:"isCaptchaNeeded"`
	CaptchaId       string `json:"captchaId"`

	// Success flag.
	OK bool `json:"ok"`
}

type EmailChange

type EmailChange struct {
	Id             uint
	UserId         uint
	TimeOfCreation time.Time
	RequestId      *string

	// IP address of a user. B = Byte array.
	UserIPAB net.IP

	AuthDataBytes     []byte
	IsCaptchaRequired bool
	CaptchaId         sql.NullString
	EmailChangeVerificationFlags

	// Old e-mail.
	VerificationCodeOld *string
	IsOldEmailSent      bool

	// New e-mail.
	NewEmail            string
	VerificationCodeNew *string
	IsNewEmailSent      bool
}

func NewEmailChange

func NewEmailChange() (ec *EmailChange)

func NewEmailChangeFromScannableSource

func NewEmailChangeFromScannableSource(src cm.IScannable) (ec *EmailChange, err error)

type EmailChangeVerificationFlags

type EmailChangeVerificationFlags struct {
	IsVerifiedByCaptcha  sql.NullBool
	IsVerifiedByPassword bool
	IsVerifiedByOldEmail bool
	IsVerifiedByNewEmail bool
}

type GetListOfLoggedUsersParams

type GetListOfLoggedUsersParams struct {
	cmr.CommonParams
}

type GetListOfLoggedUsersResult

type GetListOfLoggedUsersResult struct {
	cmr.CommonResult

	LoggedUserIds []uint `json:"loggedUserIds"`
}

type GetSelfRolesParams

type GetSelfRolesParams struct {
	cmr.CommonParams
}

type GetSelfRolesResult

type GetSelfRolesResult struct {
	cmr.CommonResult

	UserId uint `json:"userId"`
	cm.UserRoles
}

type GetUserRolesParams

type GetUserRolesParams struct {
	cmr.CommonParams

	UserId uint `json:"userId"`
}

type GetUserRolesResult

type GetUserRolesResult struct {
	cmr.CommonResult

	UserId uint `json:"userId"`
	cm.UserRoles
}

type Incident

type Incident struct {
	Id      uint
	Time    time.Time
	Type    IncidentType
	Email   string
	UserIPA net.IP
}

type IncidentType

type IncidentType byte

func (IncidentType) IsValid

func (it IncidentType) IsValid() (ok bool)

type IsUserLoggedInParams

type IsUserLoggedInParams struct {
	cmr.CommonParams

	UserId uint `json:"userId"`
}

type IsUserLoggedInResult

type IsUserLoggedInResult struct {
	cmr.CommonResult

	UserId         uint `json:"userId"`
	IsUserLoggedIn bool `json:"isUserLoggedIn"`
}

type LogEvent

type LogEvent struct {
	Id       uint
	Time     time.Time
	Type     LogEventType
	UserId   uint
	Email    string
	UserIPAB net.IP
}

type LogEventType

type LogEventType byte

func (LogEventType) IsValid

func (let LogEventType) IsValid() (ok bool)

type LogUserInParams

type LogUserInParams struct {
	cmr.CommonParams

	// Step number.
	StepN byte `json:"stepN"`

	// E-mail address.
	// This is the main identifier of a user.
	// It is used on all steps.
	Email string `json:"email"`

	// Request ID.
	// It protects preliminary sessions from being hi-jacked.
	// Is used on steps 2 and 3.
	RequestId string `json:"requestId"`

	// Captcha answer.
	// This field is optional and may be used on step 2.
	CaptchaAnswer string `json:"captchaAnswer"`

	// Authentication data provided for the challenge.
	// Is used on step 2.
	AuthChallengeResponse []byte `json:"authChallengeResponse"`

	// Verification Code.
	// Is used on step 3.
	VerificationCode string `json:"verificationCode"`
}

type LogUserInResult

type LogUserInResult struct {
	cmr.CommonResult

	// Next required step.
	// If set to zero, no further step is required.
	NextStep byte `json:"nextStep"`

	RequestId     string `json:"requestId"`
	AuthDataBytes []byte `json:"authDataBytes"`

	// Captcha parameters.
	IsCaptchaNeeded bool   `json:"isCaptchaNeeded"`
	CaptchaId       string `json:"captchaId"`

	// JWT key maker.
	IsWebTokenSet bool   `json:"isWebTokenSet"`
	WTS           string `json:"wts,omitempty"` // Web token string.
}

type LogUserOutParams

type LogUserOutParams struct {
	cmr.CommonParams
}

type LogUserOutResult

type LogUserOutResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type PasswordChange

type PasswordChange struct {
	Id             uint
	UserId         uint
	TimeOfCreation time.Time
	RequestId      *string

	// IP address of a user. B = Byte array.
	UserIPAB net.IP

	AuthDataBytes        []byte
	IsCaptchaRequired    bool
	CaptchaId            sql.NullString
	IsVerifiedByCaptcha  sql.NullBool
	IsVerifiedByPassword bool
	VerificationCode     *string
	IsEmailSent          bool
	IsVerifiedByEmail    bool
	NewPassword          []byte
}

func NewPasswordChange

func NewPasswordChange() (pc *PasswordChange)

func NewPasswordChangeFromScannableSource

func NewPasswordChangeFromScannableSource(src cm.IScannable) (pc *PasswordChange, err error)

type PasswordChangeVerificationFlags

type PasswordChangeVerificationFlags struct {
	IsVerifiedByCaptcha  sql.NullBool
	IsVerifiedByPassword bool
	IsVerifiedByEmail    bool
}

type PingParams

type PingParams = cmr.PingParams

type PingResult

type PingResult = cmr.PingResult

type PreSession

type PreSession struct {
	Id             uint
	UserId         uint
	TimeOfCreation time.Time
	RequestId      string

	// IP address of a user. B = Byte array.
	UserIPAB net.IP

	AuthDataBytes        []byte
	IsCaptchaRequired    bool
	CaptchaId            sql.NullString
	IsVerifiedByCaptcha  sql.NullBool
	IsVerifiedByPassword bool

	// Verification code is set on Step 2, so it is NULL on Step 1.
	VerificationCode sql.NullString

	IsEmailSent       bool
	IsVerifiedByEmail bool
}

func NewPreSession

func NewPreSession() (ps *PreSession)

func NewPreSessionFromScannableSource

func NewPreSessionFromScannableSource(src cm.IScannable) (ps *PreSession, err error)

type RegisterUserParams

type RegisterUserParams struct {
	cmr.CommonParams

	// Step number.
	StepN byte `json:"stepN"`

	// E-mail address.
	// Is used on steps 1, 2 and 3.
	Email string `json:"email"`

	// Verification code.
	// Is used on steps 2 and 3.
	VerificationCode string `json:"verificationCode"`

	// Name.
	// Is used on step 3.
	Name string `json:"name"`

	// Password.
	// Is used on step 3.
	Password string `json:"password"`
}

type RegisterUserResult

type RegisterUserResult struct {
	cmr.CommonResult

	// Next required step.
	// If set to zero, no further step is required.
	NextStep byte `json:"nextStep"`
}

type RequestId

type RequestId = uint

type Session

type Session struct {
	Id        uint
	UserId    uint
	StartTime time.Time

	// IP address of a user. B = Byte array.
	UserIPAB net.IP
}

func NewSession

func NewSession() (s *Session)

func NewSessionFromScannableSource

func NewSessionFromScannableSource(src cm.IScannable) (s *Session, err error)

type SetUserRoleAuthorParams

type SetUserRoleAuthorParams struct {
	cmr.CommonParams

	UserId        uint `json:"userId"`
	IsRoleEnabled bool `json:"isRoleEnabled"`
}

type SetUserRoleAuthorResult

type SetUserRoleAuthorResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type SetUserRoleReaderParams

type SetUserRoleReaderParams struct {
	cmr.CommonParams

	UserId        uint `json:"userId"`
	IsRoleEnabled bool `json:"isRoleEnabled"`
}

type SetUserRoleReaderResult

type SetUserRoleReaderResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type SetUserRoleWriterParams

type SetUserRoleWriterParams struct {
	cmr.CommonParams

	UserId        uint `json:"userId"`
	IsRoleEnabled bool `json:"isRoleEnabled"`
}

type SetUserRoleWriterResult

type SetUserRoleWriterResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type ShowDiagnosticDataParams

type ShowDiagnosticDataParams struct{}

type ShowDiagnosticDataResult

type ShowDiagnosticDataResult struct {
	cmr.CommonResult
	cmr.RequestsCount
}

type TestParams

type TestParams struct{}

type TestResult

type TestResult struct {
	cmr.CommonResult
}

type UnbanUserParams

type UnbanUserParams struct {
	cmr.CommonParams

	UserId uint `json:"userId"`
}

type UnbanUserResult

type UnbanUserResult struct {
	cmr.CommonResult

	OK bool `json:"ok"`
}

type User

type User struct {
	Password string `json:"-"`
	cm.UserParameters
}

func NewUser

func NewUser() (u *User)

func NewUserFromScannableSource

func NewUserFromScannableSource(src cm.IScannable) (u *User, err error)

type UserData

type UserData struct {
	User    *User
	Session *Session
}

func NewUserData

func NewUserData() (ud *UserData)

type ViewUserParametersParams

type ViewUserParametersParams struct {
	cmr.CommonParams

	UserId uint `json:"userId"`
}

type ViewUserParametersResult

type ViewUserParametersResult struct {
	cmr.CommonResult

	cm.UserParameters
}

Jump to

Keyboard shortcuts

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