Documentation ¶
Overview ¶
Package domain contains the domain models and business logic for the application
Index ¶
- Variables
- type AuthService
- func (as *AuthService) AssignRolePermission(ctx context.Context, roleID uuid.UUID, perm PermissionType) error
- func (as *AuthService) AssignUserRole(ctx context.Context, userID uuid.UUID, roleID uuid.UUID) error
- func (as *AuthService) CreateRole(ctx context.Context, newRole *NewRole) (*Role, error)
- func (as *AuthService) CreateUser(ctx context.Context, newUser *NewUser) (*User, map[string]string, error)
- func (as *AuthService) CreateUserSession(ctx context.Context, newSession *NewSession) (uuid.UUID, error)
- func (as *AuthService) DeleteUser(ctx context.Context, id uuid.UUID) error
- func (as *AuthService) DeleteUserSession(ctx context.Context, sessionUUID uuid.UUID) error
- func (as *AuthService) GetUserPermissions(ctx context.Context, userID uuid.UUID) (map[string]string, error)
- func (as *AuthService) ListSubscriptions(ctx context.Context) ([]string, error)
- func (as *AuthService) ListUserRoles(ctx context.Context, userID uuid.UUID) ([]*Role, error)
- func (as *AuthService) PersistToken(ctx context.Context, userID uuid.UUID, token string) error
- func (as *AuthService) ReadUserByEmail(ctx context.Context, email string) (*User, error)
- func (as *AuthService) ReadUserByID(ctx context.Context, id uuid.UUID) (*User, error)
- func (as *AuthService) ReadUserSession(ctx context.Context, sessionUUID uuid.UUID) (*Session, error)
- func (as *AuthService) RemoveRolePermission(ctx context.Context, roleID uuid.UUID) error
- func (as *AuthService) RemoveUserRole(ctx context.Context, userID uuid.UUID, roleID uuid.UUID) error
- func (as *AuthService) UpdateUser(ctx context.Context, updateUser *UpdateUser) (*User, error)
- func (as *AuthService) UpdateUserPassword(ctx context.Context, updatePassword *UpdatePassword) error
- func (as *AuthService) UserLogin(ctx context.Context, login *UserLogin) (uuid.UUID, error)
- func (as *AuthService) VerifyOTP(ctx context.Context, sessionID uuid.UUID, code string) error
- type NewRole
- type NewSession
- type NewUser
- type NewUserRole
- type Permission
- type PermissionType
- type Role
- type Session
- type UpdatePassword
- type UpdateUser
- type User
- type UserLogin
- type UserRole
Constants ¶
This section is empty.
Variables ¶
var ( // ErrPasswordMaxLength error for password too long ErrPasswordMaxLength = errors.New("password too long") // ErrPasswordMinLength error for password too short ErrPasswordMinLength = errors.New("password too short") // ErrUniqueViolation postgres unique key violation ErrUniqueViolation = errors.New("unique key violation") // ErrForeignKeyViolation postgres foreign key violation ErrForeignKeyViolation = errors.New("foreign key violation") // ErrInvalidOldPassword invalid old password ErrInvalidOldPassword = errors.New("invalid old password") // ErrEntityNotFound entity not found ErrEntityNotFound = errors.New("entity not found") // ErrInvalidPassword invalid password ErrInvalidPassword = errors.New("invalid password") // ErrInvalidTOTPCode invalid totp code ErrInvalidTOTPCode = errors.New("invalid totp code") )
Functions ¶
This section is empty.
Types ¶
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
AuthService application layer logic for users
func NewAuthService ¶
func NewAuthService(db *sql.DB, otp totp.ITOTP) *AuthService
NewAuthService create new user service instance
func (*AuthService) AssignRolePermission ¶
func (as *AuthService) AssignRolePermission(ctx context.Context, roleID uuid.UUID, perm PermissionType) error
AssignRolePermission assign role permission
func (*AuthService) AssignUserRole ¶
func (as *AuthService) AssignUserRole(ctx context.Context, userID uuid.UUID, roleID uuid.UUID) error
AssignUserRole assign user role
func (*AuthService) CreateRole ¶
CreateRole create role
func (*AuthService) CreateUser ¶
func (as *AuthService) CreateUser(ctx context.Context, newUser *NewUser) (*User, map[string]string, error)
CreateUser validate password, hash password and create user
func (*AuthService) CreateUserSession ¶
func (as *AuthService) CreateUserSession(ctx context.Context, newSession *NewSession) (uuid.UUID, error)
CreateUserSession create session
func (*AuthService) DeleteUser ¶
DeleteUser delete user
func (*AuthService) DeleteUserSession ¶
DeleteUserSession delete session
func (*AuthService) GetUserPermissions ¶
func (as *AuthService) GetUserPermissions(ctx context.Context, userID uuid.UUID) (map[string]string, error)
GetUserPermissions get user permissions
func (*AuthService) ListSubscriptions ¶
func (as *AuthService) ListSubscriptions(ctx context.Context) ([]string, error)
ListSubscriptions list service subscriptions
func (*AuthService) ListUserRoles ¶
ListUserRoles list user roles
func (*AuthService) PersistToken ¶
PersistToken persist user refresh token
func (*AuthService) ReadUserByEmail ¶
ReadUserByEmail read user by email
func (*AuthService) ReadUserByID ¶
ReadUserByID read user by id
func (*AuthService) ReadUserSession ¶
func (as *AuthService) ReadUserSession(ctx context.Context, sessionUUID uuid.UUID) (*Session, error)
ReadUserSession read session
func (*AuthService) RemoveRolePermission ¶
RemoveRolePermission remove role permission
func (*AuthService) RemoveUserRole ¶
func (as *AuthService) RemoveUserRole(ctx context.Context, userID uuid.UUID, roleID uuid.UUID) error
RemoveUserRole remove user role
func (*AuthService) UpdateUser ¶
func (as *AuthService) UpdateUser(ctx context.Context, updateUser *UpdateUser) (*User, error)
UpdateUser update user
func (*AuthService) UpdateUserPassword ¶
func (as *AuthService) UpdateUserPassword(ctx context.Context, updatePassword *UpdatePassword) error
UpdateUserPassword update user password
type Permission ¶
type Permission struct { ID uuid.UUID RoleID uuid.UUID Perm PermissionType CreatedAt time.Time UpdatedAt time.Time }
Permission ...
type PermissionType ¶
type PermissionType string
PermissionType role permission type
const ( // PermissionTypeRead read only permission PermissionTypeRead PermissionType = "read" // PermissionTypeWrite write only permission PermissionTypeWrite PermissionType = "write" // PermissionTypeEdit edit permission PermissionTypeEdit PermissionType = "edit" )
func (PermissionType) String ¶
func (p PermissionType) String() string
String stringify permission type
type UpdatePassword ¶
UpdatePassword ...
type UpdateUser ¶
UpdateUser ...