feat(auth): add support for disabling auth via metadata
- Added logic to set `auth.Disabled` and update `auth.Status` to `StatusDisabled` when `disabled` metadata is provided and true. - Updated `objectstore`, `gitstore`, and `postgresstore` implementations to handle the new metadata attribute. Closes: #2651
This commit is contained in:
@@ -497,6 +497,10 @@ func (s *GitTokenStore) readAuthFile(path, baseDir string) (*cliproxyauth.Auth,
|
|||||||
auth.Attributes["email"] = email
|
auth.Attributes["email"] = email
|
||||||
}
|
}
|
||||||
cliproxyauth.ApplyCustomHeadersFromMetadata(auth)
|
cliproxyauth.ApplyCustomHeadersFromMetadata(auth)
|
||||||
|
if disabled, ok := metadata["disabled"].(bool); ok && disabled {
|
||||||
|
auth.Disabled = true
|
||||||
|
auth.Status = cliproxyauth.StatusDisabled
|
||||||
|
}
|
||||||
return auth, nil
|
return auth, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -604,6 +604,10 @@ func (s *ObjectTokenStore) readAuthFile(path, baseDir string) (*cliproxyauth.Aut
|
|||||||
NextRefreshAfter: time.Time{},
|
NextRefreshAfter: time.Time{},
|
||||||
}
|
}
|
||||||
cliproxyauth.ApplyCustomHeadersFromMetadata(auth)
|
cliproxyauth.ApplyCustomHeadersFromMetadata(auth)
|
||||||
|
if disabled, ok := metadata["disabled"].(bool); ok && disabled {
|
||||||
|
auth.Disabled = true
|
||||||
|
auth.Status = cliproxyauth.StatusDisabled
|
||||||
|
}
|
||||||
return auth, nil
|
return auth, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -319,6 +319,10 @@ func (s *PostgresStore) List(ctx context.Context) ([]*cliproxyauth.Auth, error)
|
|||||||
NextRefreshAfter: time.Time{},
|
NextRefreshAfter: time.Time{},
|
||||||
}
|
}
|
||||||
cliproxyauth.ApplyCustomHeadersFromMetadata(auth)
|
cliproxyauth.ApplyCustomHeadersFromMetadata(auth)
|
||||||
|
if disabled, ok := metadata["disabled"].(bool); ok && disabled {
|
||||||
|
auth.Disabled = true
|
||||||
|
auth.Status = cliproxyauth.StatusDisabled
|
||||||
|
}
|
||||||
auths = append(auths, auth)
|
auths = append(auths, auth)
|
||||||
}
|
}
|
||||||
if err = rows.Err(); err != nil {
|
if err = rows.Err(); err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user