An application developer may want to force a sign out or terminate a session after
N hours regardless of activity. This is known as Maximum Session Timeout and is common for applications with particular session rules. However, the Okta dashboard only provides a configuration for Maximum Idle Session Timeout as shown below.
With the APIs create a policy to contain a rule with an
The API sequence is as followed:
Create Policy > Create Rule > Update Rule with maxSessionLifeTime
Create Rule for Policy with Max Session Timeout
In addition, it's worth noting that the admin dashboard can be used to create the policy and rule followed with a
PUT request to update the rule with the
This approach requires a few additional steps to get the associated IDs:
Update Existing Rule with Max Session Lifetime
The working code sample below can be used for reference or as a script.
You can use the REPL below to execute the script without the need of setting up any additional environments or tools, simply update the environment variables and configure the settings.
When setting the rule the
maxSessionLifetimeMinutes, Okta expects the
maxSessionIdleMinutes to be set to equal or lesser than the sessionlifetime minutes.