Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseModel ¶
type BaseModel struct { // Default values for PostgreSQL, change it for other DBMS ID uuid.UUID `gorm:"primary_key;type:uuid;default:uuid_generate_v4()"` CreatedAt *time.Time `gorm:"index;not null;default:current_timestamp"` UpdatedAt *time.Time `gorm:"index;not null;default:current_timestamp"` }
BaseModel defines the common columns that all db structs should hold, usually db structs based on this have no soft delete
type BaseModelSeq ¶
type BaseModelSeq struct { // Default values for PostgreSQL, change it for other DBMS ID uint `gorm:"primary_key,auto_increment"` CreatedAt *time.Time `gorm:"index;not null;default:current_timestamp"` UpdatedAt *time.Time `gorm:"index;not null;default:current_timestamp"` }
BaseModelSeq defines the common columns that all db structs should hold, with an INT key
type BaseModelSeqSoftDelete ¶
type BaseModelSeqSoftDelete struct { BaseModelSeq DeletedAt *time.Time `gorm:"index"` }
BaseModelSeqSoftDelete defines the common columns that all db structs should hold, usually. This struct also defines the fields for GORM triggers to detect the entity should soft delete
type BaseModelSoftDelete ¶
BaseModelSoftDelete defines the common columns that all db structs should hold, usually. This struct also defines the fields for GORM triggers to detect the entity should soft delete
type Permission ¶
type Permission struct { BaseModelSeq Tag string `gorm:"not null;unique_index"` Description string `gorm:"size:1024"` }
Permission defines a permission scope for the user
type Role ¶
type Role struct { BaseModelSeq Name string `gorm:"not null;unique_index"` Description string `gorm:"size:1024"` ParentRoles []Role `gorm:"many2many:role_parents;association_jointable_foreignkey:parent_role_id"` ChildRoles []Role `gorm:"many2many:role_parents;association_jointable_foreignkey:role_id"` Permissions []Permission `gorm:"many2many:role_permissions;association_autoupdate:false;association_autocreate:false"` }
Role defines a role for the user
type User ¶
type User struct { BaseModelSoftDelete // We don't to actually delete the users, audit Email string `gorm:"not null;unique;index"` FirstName *string LastName *string UserProfiles []UserProfile `gorm:"association_autocreate:false;association_autoupdate:false"` Roles []Role `gorm:"many2many:user_roles;association_autocreate:false;association_autoupdate:false"` Permissions []Permission `gorm:"many2many:user_permissions;association_autocreate:false;association_autoupdate:false"` }
User defines a user for the service
func GothUserToDBUser ¶
GothUserToDBUser transforms [user] goth to db model
func (*User) HasPermission ¶
HasPermission verifies if user has a specific permission
func (*User) HasPermissionTag ¶
HasPermissionTag verifies if user has a specific permission tag
type UserAPIKey ¶
type UserAPIKey struct { BaseModelSeqSoftDelete Name string User User `gorm:"association_autocreate:false;association_autoupdate:false"` UserID uuid.UUID `gorm:"not null;index"` APIKey string `gorm:"size:128;unique;index;default:uuid_generate_v4()"` Permissions []Permission `gorm:"many2many:user_api_key_permissions;association_autocreate:false;association_autoupdate:false"` }
UserAPIKey generated api keys for the users
type UserPermission ¶
UserPermission relation between an user and its permissions
type UserProfile ¶
type UserProfile struct { BaseModelSeq Email string `gorm:"uniqueIndex:idx_email_provider_external_user_id"` UserID uuid.UUID `gorm:"not null;index"` User User `gorm:"association_autocreate:false;association_autoupdate:false"` Provider string `gorm:"not null;index;unique_index:idx_email_provider_external_user_id;default:'DB'"` // DB means database or no ExternalUserID ExternalUserID string `gorm:"not null;index;unique_index:idx_email_provider_external_user_id"` // User ID FirstName string LastName string AvatarURL string `gorm:"size:1024"` Description string `gorm:"size:1024"` }
UserProfile saves all the related OAuth Profiles
func GothUserToDBUserProfile ¶
GothUserToDBUserProfile transforms [user] goth to db model