# Inactivity logout

**URL:** <https://devforum.okta.com/t/inactivity-logout/22659>\
**Category:** Questions\
**Created:** [December 1, 2022, 6:12pm UTC](https://devforum.okta.com/t/inactivity-logout/22659 "2022-12-01T18:12:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![broeks](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/broeks/32/4269_2.png) [@broeks](https://devforum.okta.com/u/broeks)\
**Post date:** [December 1, 2022, 6:12pm UTC](https://devforum.okta.com/t/inactivity-logout/22659/1 "2022-12-01T18:12:53Z")

</div>

I would like to have an inactivity signout policy for my SPA.  
I am using the okta widget.  
I am using terraform.

There is a configuration policy for sign on rules documented in terraform  
[https://registry.terraform.io/providers/okta/okta/latest/docs/resources/app\_signon\_policy\_rule#inactivity\_period](https://registry.terraform.io/providers/okta/okta/latest/docs/resources/app_signon_policy_rule#inactivity_period)

I cannot find any details on how this works. Does the widget get this configuration from the server and is watching for user activity via javascript events? Or some other mechanism? I set it to 15 minutes, and it seems to sign the user out, however they can hit the sign in button and they are then immediately logged back in.

I am unable to find the configuration for this inactivity timeout duration in the okta admin UI.

I made a javascript solution that watches for inactivity and will “properly” sign the user all the way out by calling the widget logout function – the user then needs to completely reauthenticate which is what I want. However, if there’s a way to do it with just configuration and the widget, I would like to use it.

---

<div class="post-metadata">

**Author:** ![erik](https://avatars.discourse-cdn.com/v4/letter/e/b5ac83/32.png) [@erik](https://devforum.okta.com/u/erik)\
**Post date:** [December 1, 2022, 10:38pm UTC](https://devforum.okta.com/t/inactivity-logout/22659/2 "2022-12-01T22:38:55Z")

</div>

Hello,

The values for `inactivity`/`re_authentication_frequency` are specific to Okta Org (domain) activity. For example the Okta dashboard app, if 15 minutes goes by where a user does not click any links that would cause a request to the domain, then the session would need to re authenticate/challenge/etc.

For applications like a SPA application the `okta-auth-js` SDK does not track user activity in any way. The only thing the SDK does by default is keep track of token expiration and refresh tokens automatically if configured and running as a service.

There have been clients who have used [token about to expire events](https://github.com/okta/okta-auth-js/tree/1263546ef236f95420025bc2e25ac1b11378d120#tokenmanageronevent-callback-context) to check if a session is still valid or should be logged out. You still need a way to keep track of activity by the user however. If your SPA happens to make use of [isAuthenticated()](https://github.com/okta/okta-auth-js/tree/1263546ef236f95420025bc2e25ac1b11378d120#isauthenticatedoptions) often you might be able to update an activity global variable here, but activity tracking functionality is not build into the frontend SDKs and is up to the app to track.

---

<div class="post-metadata">

**Author:** ![abole](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/abole/32/3030_2.png) [@abole](https://devforum.okta.com/u/abole)\
**Post date:** [December 4, 2022, 10:13am UTC](https://devforum.okta.com/t/inactivity-logout/22659/3 "2022-12-04T10:13:43Z")

</div>

Hi @broeks you can also check out Refresh token inactivity in your Access Policy. You can set a rule in your Access Policy so that your refresh token will expire if it is not used within a defined period of time.

![image](https://global.discourse-cdn.com/oktadev/original/2X/3/3e668e2c870d4c75b6ca31e76319e44906708b29.png)

---

<div class="post-metadata">

**Author:** ![broeks](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/broeks/32/4269_2.png) [@broeks](https://devforum.okta.com/u/broeks)\
**Post date:** [December 15, 2022, 5:57pm UTC](https://devforum.okta.com/t/inactivity-logout/22659/4 "2022-12-15T17:57:34Z")

</div>

Very helpful, thanks!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [December 16, 2022, 5:58pm UTC](https://devforum.okta.com/t/inactivity-logout/22659/5 "2022-12-16T17:58:25Z")

</div>

Closed on December 16, 2022, 5:58pm UTC

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
