mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-17 03:28:32 +02:00
admin: redact S3 secret keys for read-only sessions (#11189)
The Admin UI documents its read-only account as view-only and blocks its
write requests, but the authenticated read routes returned object-store
users with plaintext access and secret keys. A read-only admin user could
retrieve another user's live S3 credential pair from GET /api/users and
GET /api/users/{username} and use it directly against the S3 endpoint,
converting view-only access into the victim identity's object-store
authority.
Redact the reusable secret_key in GetUsers, GetUserDetails, and the
rendered users page whenever the requesting session has the read-only
role. The public access_key identifier is retained so identities remain
browsable; only the reusable secret is stripped. Admin and no-auth
sessions are unaffected.
This commit is contained in:
1 parent
78f79a3919
commit
e6f2386a0f
4 files changed
+127
-1
No files matched your search
@@ -113,6 +113,34 @@ type UserDetails struct {
|
||||
Groups []string `json:"groups"`
|
||||
}
|
||||
|
||||
// RoleReadOnly is the session role assigned to read-only (view-only) admin
|
||||
// accounts. It matches the value stored by HandleLogin when the read-only
|
||||
// credentials are used.
|
||||
const RoleReadOnly = "readonly"
|
||||
|
||||
// IsReadOnlyRole reports whether the given admin session role grants only
|
||||
// view-only access. Any other role (admin, or the empty role used when auth
|
||||
// is disabled) is treated as non-read-only.
|
||||
func IsReadOnlyRole(role string) bool {
|
||||
return role == RoleReadOnly
|
||||
}
|
||||
|
||||
// RedactSecretKey clears the plaintext S3 secret key from an object-store
|
||||
// user record. The access key (a public identifier) is retained so the
|
||||
// identity can still be listed; only the reusable secret is removed.
|
||||
func (u *ObjectStoreUser) RedactSecretKey() {
|
||||
u.SecretKey = ""
|
||||
}
|
||||
|
||||
// RedactSecretKeys clears the plaintext S3 secret keys from a user's access
|
||||
// key records. Access key identifiers are retained so the set of keys remains
|
||||
// visible; only the reusable secrets are removed.
|
||||
func (d *UserDetails) RedactSecretKeys() {
|
||||
for i := range d.AccessKeys {
|
||||
d.AccessKeys[i].SecretKey = ""
|
||||
}
|
||||
}
|
||||
|
||||
type FilerNode struct {
|
||||
Address string `json:"address"`
|
||||
DataCenter string `json:"datacenter"`
|
||||
|
||||
Reference in new issue
Block a user