Users Guide
The users module manages the full user lifecycle in Ceph RGW:
- create users
- fetch user details (by uid or access key)
- modify user metadata
- grant and revoke admin capabilities (caps)
- suspend/enable accounts
- list users
- fetch storage stats
- delete users (optionally purging all data)
API reference: Users types and methods
Prerequisites
import { RadosGWAdminClient } from 'radosgw-admin';
const rgw = new RadosGWAdminClient({
host: 'https://ceph-rgw.example.com',
accessKey: process.env.RGW_ADMIN_ACCESS_KEY!,
secretKey: process.env.RGW_ADMIN_SECRET_KEY!,
timeout: 15000,
maxRetries: 2,
});
1) Create User
const user = await rgw.users.create({
uid: 'alice',
displayName: 'Alice Example',
email: 'alice@example.com',
maxBuckets: 100,
});
When to use:
- tenant onboarding
- programmatic user provisioning
2) Get User
const user = await rgw.users.get('alice');
console.log(user.displayName, user.keys.length, user.userQuota.enabled);
Multi-tenant lookup — pass the tenant as a second argument instead of embedding it in the uid:
// Both resolve to the same user — prefer the explicit form
const user = await rgw.users.get('alice', 'acme'); // → acme$alice
Use this for audits and policy validation.
3) Get User by Access Key
Look up a user when you have their S3 access key but not their uid:
const user = await rgw.users.getByAccessKey('AKIAIOSFODNN7EXAMPLE');
console.log('Key belongs to:', user.userId);
Useful for mapping incoming S3 requests back to the owning user in audit logs or billing pipelines.
4) Modify User
const updated = await rgw.users.modify({
uid: 'alice',
displayName: 'Alice Production',
maxBuckets: 200,
});
Common updates:
- display name
- max buckets
- suspend flag
RGW's Modify User operation does not accept capabilities. Use addCaps() / removeCaps() to change them. modify({ userCaps }) still works but is deprecated: it sends a second request to add the caps (merging them, never replacing). Before v0.2.2, userCaps passed to modify() was silently ignored by RGW.
5) Grant and Revoke Capabilities
Capabilities ("caps") decide which Admin Ops APIs a user may call — for example a billing exporter needs usage=read, a provisioning service needs users=*. They do not affect S3 data access.
A caps string is "type=perm", or several joined with ;. Valid perms: *, read, write, read, write.
Grant with addCaps(). Permissions merge with what the user already has:
// Billing exporter: read usage and bucket stats, nothing else
const caps = await rgw.users.addCaps('billing-exporter', 'usage=read;buckets=read');
// → [{ type: 'buckets', perm: 'read' }, { type: 'usage', perm: 'read' }]
// Adding write to an existing read grant results in '*'
await rgw.users.addCaps('billing-exporter', 'usage=write'); // usage → '*'
Revoke with removeCaps(). Only the listed permission is removed:
// usage '*' minus 'write' leaves 'read'
await rgw.users.removeCaps('billing-exporter', 'usage=write');
// Removing '*' deletes the whole entry
const remaining = await rgw.users.removeCaps('billing-exporter', 'buckets=*');
Both methods return the user's complete capability list after the change, not just the caps you passed.
To set caps when a user is first created, pass userCaps to create() instead.
Errors you will hit in practice:
RGWValidationError— malformed caps string (e.g.'usage'or'usage=all'), rejected before any requestRGWNotFoundError— the user does not exist
Caps grant admin power over the whole cluster. Grant the narrowest type and read where possible, and audit users=* / buckets=* grants — a leaked key with users=* can create users and mint new keys.
6) Suspend and Enable
await rgw.users.suspend('alice');
await rgw.users.enable('alice');
Use suspension for temporary policy enforcement without deleting data.
7) List Users
const uids = await rgw.users.list();
console.log('Total users:', uids.length);
Useful for inventory and reconciliation jobs.
8) Fetch User Stats
const stats = await rgw.users.getStats('alice', true);
console.log(stats.stats.numObjects, stats.stats.sizeKbActual);
Use this in billing and quota reporting flows.
9) Delete User Safely
Safe delete:
await rgw.users.delete({ uid: 'alice' });
Force delete with data purge (destructive):
await rgw.users.delete({ uid: 'alice', purgeData: true });
purgeData: true permanently deletes user-owned objects. Use only after explicit operator approval.
Error Handling Pattern
import {
RGWValidationError,
RGWNotFoundError,
RGWConflictError,
RGWAuthError,
} from 'radosgw-admin';
try {
await rgw.users.create({ uid: 'alice', displayName: 'Alice' });
} catch (error) {
if (error instanceof RGWConflictError) {
// user already exists
} else if (error instanceof RGWValidationError) {
// input invalid
} else if (error instanceof RGWAuthError) {
// credentials/caps issue
} else if (error instanceof RGWNotFoundError) {
// referenced entity missing
} else {
throw error;
}
}
Production Notes
- Avoid destructive calls in automated retry loops.
- Use unique, policy-compliant user IDs from your identity source of truth.
- Keep admin keys out of logs and rotate them periodically.
- Pair create/delete operations with audit logs in your application.
- Validate business constraints before SDK calls to fail fast.