Question
How do I properly configure access control, user management, and IAM policies in MinIO to secure my object storage and control who can access what resources?
Answer
MinIO provides comprehensive Identity and Access Management (IAM) features that allow you to control access to your object storage resources. Here’s a complete guide to setting up secure access control:
Overview of MinIO IAM
MinIO IAM supports:
- Users and Groups: Local user management
- Service Accounts: For application access
- Policies: Fine-grained permission control
- External Identity Providers: LDAP, OIDC, AD
- Temporary Credentials: STS (Security Token Service)
1. Initial Admin Setup
Change Default Credentials
# Set strong root credentials (before first start)export MINIO_ROOT_USER=minio-adminexport MINIO_ROOT_PASSWORD=SecurePassword123!
# Or in /etc/minio/minio.confMINIO_ROOT_USER=minio-adminMINIO_ROOT_PASSWORD=SecurePassword123!Configure MinIO Client
# Install MinIO clientwget https://dl.min.io/client/mc/release/linux-amd64/mcchmod +x mc && sudo mv mc /usr/local/bin/
# Add your MinIO servermc alias set myminio http://localhost:9000 minio-admin SecurePassword123!
# Verify connectionmc admin info myminio2. User Management
Creating Users
# Create a new usermc admin user add myminio alice SecurePassword456!
# Create user with specific permissionsmc admin user add myminio bob SecurePassword789!
# List all usersmc admin user list myminio
# Show user infomc admin user info myminio aliceUser Operations
# Enable/disable usermc admin user enable myminio alicemc admin user disable myminio bob
# Remove usermc admin user remove myminio bob
# Change user passwordmc admin user add myminio alice NewSecurePassword!3. Group Management
Creating and Managing Groups
# Create a groupmc admin group add myminio developers alice bob charlie
# Add users to existing groupmc admin group add myminio developers dave
# Remove users from groupmc admin group remove myminio developers charlie
# List all groupsmc admin group list myminio
# Show group infomc admin group info myminio developers4. Policy Configuration
Built-in Policies
MinIO includes several predefined policies:
# List built-in policiesmc admin policy list myminio
# Common built-in policies:# - readwrite: Full access to all resources# - readonly: Read-only access to all resources# - writeonly: Write-only access to all resources# - diagnostics: Access to diagnostic informationCreating Custom Policies
Read-Only Bucket Policy:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:GetBucketLocation", "s3:GetObject", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*" ] } ]}Upload-Only Policy:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:PutObject", "s3:PutObjectAcl" ], "Resource": [ "arn:aws:s3:::uploads/*" ] } ]}Department-Specific Policy:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:GetBucketLocation", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::company-data" ], "Condition": { "StringLike": { "s3:prefix": [ "marketing/*", "public/*" ] } } }, { "Effect": "Allow", "Action": [ "s3:GetObject", "s3:PutObject", "s3:DeleteObject" ], "Resource": [ "arn:aws:s3:::company-data/marketing/*", "arn:aws:s3:::company-data/public/*" ] } ]}Applying Policies
# Create policy from filemc admin policy create myminio readonly-bucket readonly-bucket-policy.json
# Apply policy to usermc admin policy attach myminio readonly-bucket --user alice
# Apply policy to groupmc admin policy attach myminio readonly-bucket --group developers
# Detach policymc admin policy detach myminio readonly-bucket --user alice
# List user policiesmc admin user info myminio alice5. Service Accounts
Service accounts provide programmatic access without exposing user credentials:
Creating Service Accounts
# Create service account for usermc admin user svcacct add myminio alice
# Create service account with custom access/secret keysmc admin user svcacct add myminio alice \ --access-key "AKIAIOSFODNN7EXAMPLE" \ --secret-key "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
# Create service account with policymc admin user svcacct add myminio alice --policy readonly-bucket
# List service accountsmc admin user svcacct list myminio alice
# Service account infomc admin user svcacct info myminio AKIAIOSFODNN7EXAMPLEService Account Operations
# Enable/disable service accountmc admin user svcacct enable myminio AKIAIOSFODNN7EXAMPLEmc admin user svcacct disable myminio AKIAIOSFODNN7EXAMPLE
# Update service account policymc admin user svcacct edit myminio AKIAIOSFODNN7EXAMPLE --policy new-policy
# Remove service accountmc admin user svcacct remove myminio AKIAIOSFODNN7EXAMPLE6. External Identity Providers
LDAP Configuration
Add to MinIO configuration:
# LDAP SettingsMINIO_IDENTITY_LDAP_SERVER_ADDR=ldap.company.com:389MINIO_IDENTITY_LDAP_USERNAME_FORMAT="uid=${username},cn=accounts,dc=company,dc=com"MINIO_IDENTITY_LDAP_GROUP_SEARCH_FILTER="(&(objectclass=groupOfNames)(member=${username}))"MINIO_IDENTITY_LDAP_GROUP_NAME_ATTRIBUTE=cnMINIO_IDENTITY_LDAP_GROUP_SEARCH_BASE_DN="cn=groups,cn=accounts,dc=company,dc=com"
# TLS Settings (recommended)MINIO_IDENTITY_LDAP_TLS_SKIP_VERIFY=offMINIO_IDENTITY_LDAP_SERVER_INSECURE=offOIDC/OAuth Configuration
# OpenID Connect SettingsMINIO_IDENTITY_OPENID_CONFIG_URL=https://accounts.google.com/.well-known/openid_configurationMINIO_IDENTITY_OPENID_CLIENT_ID=your-client-idMINIO_IDENTITY_OPENID_CLIENT_SECRET=your-client-secretMINIO_IDENTITY_OPENID_CLAIM_NAME=policyMINIO_IDENTITY_OPENID_SCOPES=openid,profile,emailMINIO_IDENTITY_OPENID_REDIRECT_URI=https://console.minio.example.com/oauth_callback7. Bucket Policies
Setting Bucket-Level Policies
# Set public read policy on bucketmc anonymous set public myminio/public-bucket
# Set download-only policymc anonymous set download myminio/downloads-bucket
# Remove anonymous accessmc anonymous set none myminio/private-bucket
# Custom bucket policycat > bucket-policy.json << EOF{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "*" }, "Action": "s3:GetObject", "Resource": "arn:aws:s3:::public-bucket/*", "Condition": { "StringEquals": { "s3:ExistingObjectTag/public": "true" } } } ]}EOF
mc anonymous set-json bucket-policy.json myminio/public-bucket8. Advanced Security Features
Encryption Configuration
# Server-side encryption with MinIO managed keysMINIO_KMS_SECRET_KEY=my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw=
# External KMS (HashiCorp Vault)MINIO_KMS_VAULT_ENDPOINT=https://vault.example.com:8200MINIO_KMS_VAULT_AUTH_TYPE=approleMINIO_KMS_VAULT_APPROLE_ID=your-role-idMINIO_KMS_VAULT_APPROLE_SECRET=your-secret-idMINIO_KMS_VAULT_KEY_NAME=minio-default-keyAudit Logging
# Enable audit loggingMINIO_AUDIT_WEBHOOK_ENABLE=onMINIO_AUDIT_WEBHOOK_ENDPOINT=https://webhook.example.com/minio-auditMINIO_AUDIT_WEBHOOK_AUTH_TOKEN=your-auth-token
# Audit log formatMINIO_AUDIT_WEBHOOK_CLIENT_CERT=/path/to/client.crtMINIO_AUDIT_WEBHOOK_CLIENT_KEY=/path/to/client.key9. Security Best Practices
Password Policies
{ "Version": "2012-10-17", "Statement": [ { "Sid": "DenyInsecureConnections", "Effect": "Deny", "Principal": "*", "Action": "s3:*", "Resource": [ "arn:aws:s3:::*", "arn:aws:s3:::*/*" ], "Condition": { "Bool": { "aws:SecureTransport": "false" } } } ]}Regular Security Maintenance
# Rotate service account keys regularlymc admin user svcacct edit myminio AKIAIOSFODNN7EXAMPLE --secret-key "NewSecretKey"
# Review user access regularlymc admin user list myminiomc admin group list myminio
# Monitor active sessionsmc admin trace myminio
# Review policiesmc admin policy list myminio10. Example Use Cases
Application Access Pattern
# 1. Create application usermc admin user add myminio app-user AppSecurePassword!
# 2. Create application-specific policycat > app-policy.json << EOF{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:GetObject", "s3:PutObject", "s3:DeleteObject" ], "Resource": [ "arn:aws:s3:::app-data/*" ] } ]}EOF
mc admin policy create myminio app-policy app-policy.json
# 3. Create service account with policymc admin user svcacct add myminio app-user --policy app-policy
# 4. Use service account credentials in applicationMulti-Tenant Setup
# Create tenant groupsmc admin group add myminio tenant-a user1 user2mc admin group add myminio tenant-b user3 user4
# Create tenant-specific policiescat > tenant-a-policy.json << EOF{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": ["s3:*"], "Resource": [ "arn:aws:s3:::tenant-a-*", "arn:aws:s3:::tenant-a-*/*" ] } ]}EOF
mc admin policy create myminio tenant-a-policy tenant-a-policy.jsonmc admin policy attach myminio tenant-a-policy --group tenant-aTroubleshooting Access Issues
- Check User Status: Verify user is enabled
- Verify Policies: Ensure correct policies are attached
- Test Permissions: Use
mcclient to test access - Review Logs: Check MinIO server logs for access denials
- Validate Network: Ensure proper network connectivity
This comprehensive access control setup provides secure, scalable user and permission management for your MinIO deployment.