mirror of
https://github.com/ferdzo/fs.git
synced 2026-04-05 01:56:25 +00:00
add admin user delete endpoint and service support
This commit is contained in:
@@ -154,6 +154,23 @@ func (h *MetadataHandler) PutAuthIdentity(identity *models.AuthIdentity) error {
|
||||
})
|
||||
}
|
||||
|
||||
func (h *MetadataHandler) DeleteAuthIdentity(accessKeyID string) error {
|
||||
accessKeyID = strings.TrimSpace(accessKeyID)
|
||||
if accessKeyID == "" {
|
||||
return errors.New("access key id is required")
|
||||
}
|
||||
return h.update(func(tx *bbolt.Tx) error {
|
||||
bucket := tx.Bucket(authIdentitiesIndex)
|
||||
if bucket == nil {
|
||||
return errors.New("auth identities index not found")
|
||||
}
|
||||
if bucket.Get([]byte(accessKeyID)) == nil {
|
||||
return fmt.Errorf("%w: %s", ErrAuthIdentityNotFound, accessKeyID)
|
||||
}
|
||||
return bucket.Delete([]byte(accessKeyID))
|
||||
})
|
||||
}
|
||||
|
||||
func (h *MetadataHandler) GetAuthIdentity(accessKeyID string) (*models.AuthIdentity, error) {
|
||||
accessKeyID = strings.TrimSpace(accessKeyID)
|
||||
if accessKeyID == "" {
|
||||
@@ -205,6 +222,23 @@ func (h *MetadataHandler) PutAuthPolicy(policy *models.AuthPolicy) error {
|
||||
})
|
||||
}
|
||||
|
||||
func (h *MetadataHandler) DeleteAuthPolicy(accessKeyID string) error {
|
||||
accessKeyID = strings.TrimSpace(accessKeyID)
|
||||
if accessKeyID == "" {
|
||||
return errors.New("access key id is required")
|
||||
}
|
||||
return h.update(func(tx *bbolt.Tx) error {
|
||||
bucket := tx.Bucket(authPoliciesIndex)
|
||||
if bucket == nil {
|
||||
return errors.New("auth policies index not found")
|
||||
}
|
||||
if bucket.Get([]byte(accessKeyID)) == nil {
|
||||
return fmt.Errorf("%w: %s", ErrAuthPolicyNotFound, accessKeyID)
|
||||
}
|
||||
return bucket.Delete([]byte(accessKeyID))
|
||||
})
|
||||
}
|
||||
|
||||
func (h *MetadataHandler) GetAuthPolicy(accessKeyID string) (*models.AuthPolicy, error) {
|
||||
accessKeyID = strings.TrimSpace(accessKeyID)
|
||||
if accessKeyID == "" {
|
||||
|
||||
Reference in New Issue
Block a user