Version 33.6.1 adds the ability to configure the time-to-live (TTL) for web authentication tokens. This enables shorter token lifetimes for automated tools and enhanced security while maintaining flexibility for different use cases.
The web interface supports two authentication mechanisms:
Token authentication is particularly useful for automation tools and scripts that make multiple API calls, as it reduces the overhead of authenticating each request. Previously, authentication tokens were issued with a fixed 24-hour (86400 seconds) validity period. You can now configure a custom default TTL between 1 minute and 24 hours.
To configure the default token time-to-live:
configure web authentication token default-ttl <seconds>
Where seconds specifies the validity time in seconds (60-86400, default 86400).
Examples:
# Set 1-minute TTL for short-lived automation tasks configure web authentication token default-ttl 60 # Set 1-hour TTL configure web authentication token default-ttl 3600 # Restore default 24-hour TTL configure web authentication token default-ttl 86400
The configuration persists across reboots.
The configured default TTL applies when an API request for token generation does not include a TTL property in the request body. If an API request specifies a TTL value, that value takes precedence over the configured default.
This allows individual API clients to request specific TTL values while providing a system-wide default for clients that do not specify a TTL.
To view the configured token TTL in the system configuration:
show configuration thttpd
Sample output:
# # Module thttpd configuration. # enable web http enable web https configure ssl certificate hash-algorithm sha512 configure web authentication token default-ttl 60
To view the token TTL in switch management information:
show switch management
Sample output excerpt:
Web access : Enabled (tcp port 80)
: Access Profile : not set
: Auth token default TTL: 60 seconds
Authentication tokens are generated via API calls to the /auth/token endpoint. The token request includes a username and password:
curl --request POST \
--url http://<switch-ip>/auth/token \
--header 'content-type: application/json' \
--data '{
"username": "admin",
"password": ""
}'
Sample response showing the configured TTL:
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
"ttl": 60
}
The ttl field in the response indicates the token's validity period in seconds.
Include the authentication token in subsequent API requests using the x-auth-token header:
curl --request GET \ --url 'http://<switch-ip>/rest/openapi/v0/state/slpp' \ --header 'x-auth-token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...'
The token remains valid for the configured TTL period from the time it was generated. After the TTL expires, API requests using that token will fail with an authentication error, and a new token must be obtained.
Short-Lived Tokens (60-3600 seconds):
Appropriate for automation tools like Ansible modules that execute brief tasks. Shorter token lifetimes reduce the risk window if a token is compromised. Use short-lived tokens when:
Standard Tokens (3600-86400 seconds):
Suitable for interactive sessions or longer-running automation tasks requiring extended token validity. Use standard tokens when:
Security Considerations:
Operational Considerations:
When integrating with automation tools such as Ansible:
Example workflow for a 5-minute Ansible playbook:
# Configure 10-minute token TTL to allow buffer time configure web authentication token default-ttl 600 # Ansible playbook uses token authentication # Token obtained at playbook start # Token valid for entire playbook execution # Token automatically expires after 10 minutes