Tychobra / polished

Authentication and Administration for Shiny apps
https://polished.tech
Other
233 stars 36 forks source link

Last Login Time for each user #197

Closed muschellij2 closed 2 years ago

muschellij2 commented 2 years ago

Is it possible to see on https://dashboard.polished.tech/ the last login time for each user or extract that information via the API? If not, we can push something to a database/txt file every time someone logs in via session data, but I didn't know if this was catalogued and already stored.

merlinoa commented 2 years ago

This info is not on dashboard.polished.tech, but it is available in the "Admin Panel" of each app.

There are also a couple options to get it from the API.

  1. We have this API endpoint which is used by the Admin Panel on each app:
res <- httr::GET(
    url = paste0("https://auth-api.polished.tech/v1/last-active-session-time"),
        query = list(
          app_uid = .polished$app_uid
        ),
        httr::authenticate(
          user = get_api_key(),
          password = ""
     )
)

The above is just for internal use, so it may be removed or break in the future.

We also have a GET /logs endpoint which is also not yet documented. It uses has the following query params:

start and end are dates in yyyy-mm-dd format.

I'm planning to make wrapper functions in polished and documenting the /logs endpoints at some point.

Finally, you could use polished::get_sessions() but it might not always be accurate as dormant sessions are periodically deleted from the database.

Closing this out. Please reopen if that did not answer your question.

muschellij2 commented 2 years ago

Awesome, thanks for the quick response!