Documentation
¶
Index ¶
- func GetRelatedUserGroupIDs(userGroups []*pbUser.RelatedUserGroup, db *pg.Tx) ([]uuid.UUID, error)
- func GetRelatedUserGroups(ids []uuid.UUID, db orm.DB) ([]*pbUser.RelatedUserGroup, error)
- func GetTagIDs(t []*pbUser.Tag, db *pg.Tx) ([]uuid.UUID, error)
- func GetTags(tagIds []uuid.UUID, db *pg.DB) ([]*pbUser.Tag, error)
- func StringOrNull(str string) sql.NullString
- type AccessRole
- type AccessToken
- type AuthUser
- type AuthorizationCode
- type Client
- type Email
- type EmailToken
- type EmailTokenClaims
- type GroupType
- type IDRecord
- type Link
- type Logger
- type RBACService
- type RefreshToken
- type Role
- type Scope
- type StreetAddress
- type Tag
- type Tenant
- type User
- type UserGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRelatedUserGroupIDs ¶
Select user groups in db with given ids in 'userGroups' Return ids slice Used in CreateUserGroup/UpdateUserGroup to add/update ids slice to recommended Artists
func GetRelatedUserGroups ¶
Select user groups in db with given 'ids' Return slice of UserGroup response
func StringOrNull ¶
func StringOrNull(str string) sql.NullString
StringOrNull returns properly configured sql.NullString
Types ¶
type AccessRole ¶
type AccessRole int32
AccessRole represents access role type
const ( // SuperAdminRole has all permissions and can assign admins SuperAdminRole AccessRole = iota + 1 // 1 // AdminRole has admin permissions across all tenants, except the ability to assign other Admins AdminRole // 2 // TenantAdminRole has admin permissions over other users in their tenant. TenantAdminRole // 3 // LabelRole is a like an artist user, but can manage their artists content. LabelRole // 4 // ArtistRole is a like a standard user, but can have multiple personas and the ability to upload ArtistRole // 5 // UserRole is a standard user UserRole // 6 )
type AccessToken ¶
type AccessToken struct {
IDRecord
ClientID uuid.UUID `bun:"type:uuid,notnull"`
UserID uuid.UUID `bun:"type:uuid"`
Client *Client `bun:"rel:has-one"`
User *User `bun:"rel:has-one"`
Token string `bun:"type:varchar(40),unique,notnull"`
ExpiresAt time.Time `bun:",notnull"`
Scope string `bun:"type:varchar(200),notnull"`
}
OauthAccessToken ...
func NewOauthAccessToken ¶
func NewOauthAccessToken(client *Client, user *User, expiresIn int, scope string) *AccessToken
NewOauthAccessToken creates new OauthAccessToken instance
type AuthorizationCode ¶
type AuthorizationCode struct {
IDRecord
ClientID uuid.UUID `bun:"type:uuid,notnull"`
UserID uuid.UUID `bun:"type:uuid,notnull"`
Client *Client `bun:"rel:has-one"`
User *User `bun:"rel:has-one"`
Code string `bun:"type:varchar(40),unique,notnull"`
RedirectURI sql.NullString `bun:"type:varchar(200)"`
ExpiresAt time.Time `bun:",notnull"`
Scope string `bun:"type:varchar(200),notnull"`
}
OauthAuthorizationCode ...
func NewOauthAuthorizationCode ¶
func NewOauthAuthorizationCode(client *Client, user *User, expiresIn int, redirectURI, scope string) *AuthorizationCode
NewOauthAuthorizationCode creates new OauthAuthorizationCode instance
type Client ¶
type Client struct {
IDRecord
Key string `bun:"type:varchar(254),unique,notnull"`
Secret string `bun:"type:varchar(60),notnull"`
RedirectURI sql.NullString `bun:"type:varchar(200)"`
ApplicationName sql.NullString `bun:"type:varchar(200)"`
ApplicationHostname sql.NullString `bun:"type:varchar(200)"`
ApplicationURL sql.NullString `bun:"type:varchar(200)"`
}
OauthClient ...
type EmailToken ¶
type EmailToken struct {
IDRecord
Reference uuid.UUID `bun:"type:uuid,notnull,default:uuid_generate_v4()"`
EmailSent bool `bun:",notnull,default:false"`
EmailSentAt *time.Time
ExpiresAt time.Time `bun:",notnull"`
}
EmailTokenModel is an abstract model which can be used for objects from which we derive redirect emails (email confirmation, password reset and such)
func NewOauthEmailToken ¶
func NewOauthEmailToken(expiresIn *time.Duration) *EmailToken
NewEmailToken creates new OauthEmailToken instance
type EmailTokenClaims ¶
type EmailTokenClaims struct {
Username string `json:"username"`
Reference string `json:"reference"`
jwt.StandardClaims
}
func NewOauthEmailTokenClaims ¶
func NewOauthEmailTokenClaims(email string, emailToken *EmailToken) *EmailTokenClaims
NewOauthEmailTokenClaims creates new NewOauthEmailTokenClaims instance
type IDRecord ¶
type IDRecord struct {
ID uuid.UUID `bun:"type:uuid,default:uuid_generate_v4()"`
CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
UpdatedAt time.Time
DeletedAt time.Time `bun:",soft_delete"`
}
MyGormModel mimixks GormModel but uses uuid's for ID, generated in go
type Link ¶
type Link struct {
ID uuid.UUID `bun:"type:uuid,default:uuid_generate_v4()"`
URI string `bun:",notnull"`
Type string
Platform string `bun:",notnull"`
PersonalData bool `bun:",notnull"`
}
Link is an internet hyperlink
type Logger ¶
type Logger interface {
// source, msg, error, params
Log(context.Context, string, string, error, map[string]interface{})
}
Logger represents logging interface
type RBACService ¶
type RBACService interface {
EnforceRole(context.Context, AccessRole) bool
EnforceUser(context.Context, uuid.UUID) bool
EnforceTenant(context.Context, uuid.UUID) bool
EnforceTenantAdmin(context.Context, int32) bool
EnforceTenantAndRole(context.Context, AccessRole, int32) bool
IsLowerRole(context.Context, AccessRole) bool
}
RBACService represents role-based access control service interface
type RefreshToken ¶
type RefreshToken struct {
IDRecord
ClientID uuid.UUID `bun:"type:uuid,notnull"`
UserID uuid.UUID `bun:"type:uuid"`
Client *Client `bun:"rel:has-one"`
User *User `bun:"rel:has-one"`
Token string `bun:"type:varchar(40),unique,notnull"`
ExpiresAt time.Time `bun:",notnull,default:now()"`
Scope string `bun:"type:varchar(200),notnull"`
}
OauthRefreshToken ...
func NewOauthRefreshToken ¶
func NewOauthRefreshToken(client *Client, user *User, expiresIn int, scope string) *RefreshToken
NewOauthRefreshToken creates new OauthRefreshToken instance
type Role ¶
type Role struct {
ID int32 `bun:"type:,unique"`
Name string `bun:"type:varchar(50),unique,notnull"`
Description string `bun:"type:varchar(200),notnull"`
IsDefault bool `bun:"default:false"`
}
Role is a one of roles user can have
type Scope ¶
type Scope struct {
ID int32 `bun:"type:,unique"`
Name string `bun:"type:varchar(50),unique,notnull"`
Description string `bun:"type:varchar(200)"`
IsDefault bool `bun:"default:false"`
}
OauthScope ...
type StreetAddress ¶
type StreetAddress struct {
ID uuid.UUID `bun:"type:uuid,default:uuid_generate_v4()"`
PersonalData bool `bun:",notnull"`
Data map[string]string `pg:",hstore"`
}
StreetAddress holds geographical data and marks if private
type Tag ¶
type Tag struct {
ID uuid.UUID `bun:"type:uuid,default:uuid_generate_v4()"`
Type string `bun:",notnull"`
Name string `bun:",notnull"`
}
Tag provides basic tag structure
type Tenant ¶
type Tenant struct {
Id uuid.UUID `bun:"type:uuid,default:uuid_generate_v4()"`
Name string `json:"name"`
Active bool `json:"active"`
}
Tenant table
type User ¶
type User struct {
IDRecord
Username string `bun:",notnull,unique"`
FullName string
FirstName string
LastName string
EmailConfirmed bool `bun:"default:false"`
Country string `bun:"type:varchar(2)"`
Member bool `bun:"default:false,notnull"`
NewsletterNotification bool
FollowedGroups []uuid.UUID `bun:",type:uuid[],array"`
OwnerOfGroups []*UserGroup `bun:"rel:has-many"`
TenantID int32
RoleID int32
LastLogin time.Time
LastPasswordChange time.Time
Password sql.NullString `bun:"type:varchar(60)"`
Token string
}
User basic definition of a User and its meta
func (*User) UpdateLoginDetails ¶
UpdateLoginDetails updates login related fields
type UserGroup ¶
type UserGroup struct {
IDRecord
DisplayName string `bun:",unique,notnull"`
Description string
ShortBio string
GroupEmail string
AddressID uuid.UUID `bun:"type:uuid,notnull"` //for Country see User model
Address *StreetAddress
TypeID uuid.UUID `bun:"type:uuid,notnull"` //for e.g. Persona Type
Type *GroupType
OwnerID uuid.UUID `bun:"type:uuid,notnull"`
Owner *User `bun:"rel:has-one"`
Links []uuid.UUID `bun:",type:uuid[],array"`
Members []UserGroup `pg:"many2many:user_group_members,fk:user_group_id,joinFK:member_id"`
MemberOfGroups []UserGroup `pg:"many2many:user_group_members,fk:member_id,joinFK:user_group_id"`
Avatar uuid.UUID `bun:"type:uuid"`
Banner uuid.UUID `bun:"type:uuid"`
Tags []uuid.UUID `bun:",type:uuid[],array"`
}
UserGroup represents a group of Users and maintains a set of metadata