add example setup for management refactor

This commit is contained in:
Pascal Fischer
2024-03-13 23:07:00 +01:00
parent 9d213e0b54
commit f31b06fc92
19 changed files with 1560 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
package users
import "github.com/netbirdio/netbird/management/refactor/peers"
type Manager interface {
GetUser(id string) (User, error)
}
type DefaultManager struct {
repository repository
peerManager peers.Manager
}
func NewDefaultManager(repository repository, peerManager peers.Manager) *DefaultManager {
return &DefaultManager{
repository: repository,
peerManager: peerManager,
}
}
func (d DefaultManager) GetUser(id string) (User, error) {
// TODO implement me
panic("implement me")
}

View File

@@ -0,0 +1,4 @@
package users
type repository interface {
}

View File

@@ -0,0 +1,35 @@
package users
import "time"
// UserRole is the role of a User
type UserRole string
type User interface {
IsBlocked() bool
}
// User represents a user of the system
type DefaultUser struct {
Id string `gorm:"primaryKey"`
// AccountID is a reference to Account that this object belongs
AccountID string `json:"-" gorm:"index"`
Role UserRole
IsServiceUser bool
// NonDeletable indicates whether the service user can be deleted
NonDeletable bool
// ServiceUserName is only set if IsServiceUser is true
ServiceUserName string
// AutoGroups is a list of Group IDs to auto-assign to peers registered by this user
AutoGroups []string `gorm:"serializer:json"`
// Blocked indicates whether the user is blocked. Blocked users can't use the system.
Blocked bool
// LastLogin is the last time the user logged in to IdP
LastLogin time.Time
// Issued of the user
Issued string `gorm:"default:api"`
}
func (u *DefaultUser) IsBlocked() bool {
return u.Blocked
}