mirror of
https://github.com/khairul169/vaulterm.git
synced 2026-09-15 17:03:30 +07:00
feat: add auth, hosts, & keychains ownership
This commit is contained in:
@@ -14,6 +14,9 @@ const (
|
||||
type Host struct {
|
||||
Model
|
||||
|
||||
OwnerID string `json:"userId" gorm:"index:hosts_owner_id_idx;type:varchar(26)"`
|
||||
Owner User `json:"user" gorm:"foreignKey:OwnerID"`
|
||||
|
||||
Type string `json:"type" gorm:"not null;index:hosts_type_idx;type:varchar(16)"`
|
||||
Label string `json:"label"`
|
||||
Host string `json:"host" gorm:"type:varchar(64)"`
|
||||
@@ -54,3 +57,14 @@ func (h *Host) DecryptKeys() (*HostDecrypted, error) {
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
type HostHasAccessOptions struct {
|
||||
UserID string
|
||||
}
|
||||
|
||||
func (h *Host) HasAccess(o HostHasAccessOptions) bool {
|
||||
if o.UserID == h.OwnerID {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ const (
|
||||
type Keychain struct {
|
||||
Model
|
||||
|
||||
OwnerID string `json:"userId" gorm:"index:hosts_owner_id_idx;type:varchar(26)"`
|
||||
Owner User `json:"user" gorm:"foreignKey:OwnerID"`
|
||||
|
||||
Label string `json:"label"`
|
||||
Type string `json:"type" gorm:"not null;index:keychains_type_idx;type:varchar(12)"`
|
||||
Data string `json:"-" gorm:"type:text"`
|
||||
|
||||
Reference in New Issue
Block a user