Authentication Methods
Bearer Token Authentication
The primary authentication method uses bearer tokens in the Authorization header:Basic Authentication
Basic authentication can be used for initial token generation:Token Types
Rancher supports multiple token types for different use cases.User Tokens
User tokens are associated with a specific user account:string
required
The ID of the user who owns this token
string
required
Authentication provider (local, github, activedirectory, etc.)
integer
Token TTL in milliseconds. 0 means never expires
boolean
default:"true"
Whether the token is enabled and can be used
string
Human-readable description of the token’s purpose
Service Account Tokens
Service account tokens are used for automated workflows:string
required
Name of the service account
string
UID of the service account
string
The actual token value (only returned on creation)
Creating API Tokens
Create User Token via UI
- Navigate to User Settings > API & Keys
- Click Add Key
- Set description and expiration
- Save the token securely (shown only once)
Create Token via API
Response
string
The authentication token value. Save this securely - it won’t be shown again.
string
Unique identifier for the token
string
ID of the user who owns this token
string
ISO 8601 timestamp when the token expires
object
Principal information for the token owner
Token Management
List Tokens
Retrieve all tokens for the authenticated user:Delete Token
Revoke a token:Update Token
Modify token properties (description, enabled status):Token Security Best Practices
Use Short-Lived Tokens for Automation
Use Short-Lived Tokens for Automation
Set appropriate TTL values for automated workflows. Tokens for CI/CD should expire after the pipeline completes.
Rotate Tokens Regularly
Rotate Tokens Regularly
Implement token rotation policies, especially for long-lived service accounts.
Scope Tokens Appropriately
Scope Tokens Appropriately
Use cluster-scoped tokens when possible instead of global admin tokens.
Store Tokens Securely
Store Tokens Securely
Never commit tokens to version control. Use secret management systems like:
- Kubernetes Secrets
- HashiCorp Vault
- Cloud provider secret managers
Monitor Token Usage
Monitor Token Usage
Track token activity via audit logs to detect suspicious behavior.
Token Attributes
Token Object Schema
Frompkg/apis/management.cattle.io/v3/authn_types.go:30:
string
The actual token value (write-only, only returned on creation)
Principal
Principal representing the authenticated user
array<Principal>
List of group principals the user belongs to
map<string, string>
Additional information from the authentication provider
string
Reference to the user who owns this token
string
Authentication provider (local, github, ldap, etc.)
integer
Time to live in milliseconds. 0 means never expires.
timestamp
Last time the token was used for authentication
boolean
Whether this is a derived token (created automatically)
string
Human-readable description of the token
boolean
Whether the token has expired
string
Cluster scope for cluster-scoped tokens
boolean
default:"true"
Whether the token is active and can be used
API Access Patterns
Cluster-Scoped Access
Create tokens scoped to specific clusters:Project-Scoped Access
Access resources within a specific project using project membership and RBAC:Global Access
Global admin tokens can access all resources:Troubleshooting Authentication
Common Issues
403 Forbidden
403 Forbidden
- User lacks permissions for the requested resource
- Check RBAC roles and bindings
- Verify cluster/project membership
Token Not Working After Creation
Token Not Working After Creation
- Allow a few seconds for token propagation
- Verify the token was copied correctly
- Check that
enabledfield is true
Next Steps
Cluster Management
Use your token to manage clusters
RBAC
Learn about role-based access control