mirror of
https://github.com/minio/minio.git
synced 2025-11-07 21:02:58 -05:00
Add the policy name to the audit logs tags when doing policy-based API calls. Add retention settings to tags (#20638)
* Add the policy name to the audit log tags when doing policy-based API calls * Audit log the retention settings requested in the API call * Audit log of retention on PutObjectRetention API path too
This commit is contained in:
@@ -237,6 +237,25 @@ type Config struct {
|
||||
} `xml:"Rule,omitempty"`
|
||||
}
|
||||
|
||||
// String returns the human readable format of object lock configuration, used in audit logs.
|
||||
func (config Config) String() string {
|
||||
parts := []string{
|
||||
fmt.Sprintf("Enabled: %v", config.Enabled()),
|
||||
}
|
||||
if config.Rule != nil {
|
||||
if config.Rule.DefaultRetention.Mode != "" {
|
||||
parts = append(parts, fmt.Sprintf("Mode: %s", config.Rule.DefaultRetention.Mode))
|
||||
}
|
||||
if config.Rule.DefaultRetention.Days != nil {
|
||||
parts = append(parts, fmt.Sprintf("Days: %d", *config.Rule.DefaultRetention.Days))
|
||||
}
|
||||
if config.Rule.DefaultRetention.Years != nil {
|
||||
parts = append(parts, fmt.Sprintf("Years: %d", *config.Rule.DefaultRetention.Years))
|
||||
}
|
||||
}
|
||||
return strings.Join(parts, ", ")
|
||||
}
|
||||
|
||||
// Enabled returns true if config.ObjectLockEnabled is set to Enabled
|
||||
func (config *Config) Enabled() bool {
|
||||
return config.ObjectLockEnabled == Enabled
|
||||
@@ -349,6 +368,10 @@ type ObjectRetention struct {
|
||||
RetainUntilDate RetentionDate `xml:"RetainUntilDate,omitempty"`
|
||||
}
|
||||
|
||||
func (o ObjectRetention) String() string {
|
||||
return fmt.Sprintf("Mode: %s, RetainUntilDate: %s", o.Mode, o.RetainUntilDate.Time)
|
||||
}
|
||||
|
||||
// Maximum 4KiB size per object retention config.
|
||||
const maxObjectRetentionSize = 1 << 12
|
||||
|
||||
|
||||
Reference in New Issue
Block a user