types

package
v0.0.0-...-baca4c3 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

README

Deprecated

Remove package once all types are moved out to package with services!

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPolicyNotFound = errors.New("Error: Policy not found")

ErrPolicyNotFound is the error returned if a user can't be found

View Source
var ErrUserNotFound = errors.New("Error: User not found")

ErrUserNotFound is the error returned if a user can't be found

View Source
var IsDNSNameRegex = regexp.MustCompile(`^([a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62}){1}(\.[a-zA-Z0-9_]{1}[a-zA-Z0-9_-]{0,62})*[\._]?$`)

IsDNSNameRegex is used to verify if a string is a DNS Name (Domain Name)

View Source
var SafeString = regexp.MustCompile(`^[a-zA-Z0-9:\-@ !#$^&*().,?]+$`)

Regex's are used to verify the users input

View Source
var ValidEmail = regexp.MustCompile(`^[a-z0-9._%+\-]+@[a-z0-9.\-]+\.[a-z]{2,4}$`)

ValidEmail is a regex used to verify an email is valid

Functions

This section is empty.

Types

type Action

type Action struct {
	EventName        string
	EventDescription string
	Time             time.Time
}

An Action is an event taken by a user.

type Permissions

type Permissions []string

Permissions contains a list of allowed permissions for a user.

type Policy

type Policy struct {
	UUID        PolicyUUID
	DisplayName string
	Payload     []PolicyPayload `graphql:",optional"`
}

A Policy contains instructions that are send to scoped managed device upon enrollment

type PolicyPayload

type PolicyPayload struct {
	DisplayName string
}

PolicyPayload is a raw MDM instruction contain inside a Policy

type PolicyService

type PolicyService interface {
	GetAll() ([]Policy, error)
	Get(uuid PolicyUUID) (Policy, error)
	CreateOrEdit(uuid PolicyUUID, policy Policy) error
}

PolicyService contains the implemented functionality for policies

type PolicyUUID

type PolicyUUID []byte

PolicyUUID is a unique identifier given to each policy

type RawPassword

type RawPassword string

RawPassword is a string that contains the hashed + salted password. This type should NEVER EVER EVER contain a plain text password!!!!!! It is not exposed outside this package to force the use of helpers to keep the password secure!

type User

type User struct {
	DisplayName string
	Email       string
	Password    RawPassword
	Activity    []Action    `graphql:",optional"` // TODO: API Read only
	Permissions Permissions `graphql:",optional"` // TODO: API Require PERM to change
}

A User is either an administrator or end user who owns a managed device.

func (User) Verify

func (user User) Verify() error

Verify checks that the structs fields are valid

type UserService

type UserService interface {
	GetAll() ([]User, error)
	Get(email string) (User, error)
	CreateOrEdit(email string, user User) error
	VerifyLogin(email string, password string) (bool, error)
	HasPermission(email string, permission string) (bool, error)
	HashPassword(password []byte) (RawPassword, error)
}

UserService contains the implemented functionality for users

Jump to

Keyboard shortcuts

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