duosecurity/duo_client_python

get_authentication_log mintime argument returns an error on valid timestamps

mrinehart-r7 opened this issue · 8 comments

So this isn't totally library-related, but the get_authentication_log mintime argument will cause a RuntimeError if any value is used outside of None.

Samples to reproduce:

import duo_client


admin_api = duo_client.Admin(
            ikey="xxxxxx",
            skey="xxxxxx",
            host="xxxxxxx"
        ).get_authentication_log(2, mintime="1555453710")
import duo_client


admin_api = duo_client.Admin(
            ikey="xxxxxx",
            skey="xxxxxx",
            host="xxxxxxx"
        ).get_authentication_log(2, mintime=1555453710)
import duo_client


admin_api = duo_client.Admin(
            ikey="xxxxxx",
            skey="xxxxxx",
            host="xxxxxxx"
        ).get_authentication_log(2, mintime=0)

The only way I have been able to successfully use this API endpoint is to totally omit the mintime value.

Hi, we will take a look and give an update once we've investigated this a bit. Thanks for letting us know!

Sounds great, thank you @imranraja85 ! For reference, I (and our users) would see the ability to use an epoch timestamp from a website like the following as a successful fix. https://www.epochconverter.com/

Thanks for your patience @mrinehart-r7! It looks like you're passing in seconds instead of milliseconds. As noted in the admin api doc, mintime is expected to be in milliseconds https://currentmillis.com/

@imranraja85 following your advice and using that link to generate a millisecond timestamp for 1/1/1993, the ms timestamp provided still throws the same error.

response = duo_client.Admin(
            ikey="xxxxx",
            skey="xxxxx",
            host="xxxxxx"
        ).get_authentication_log(2, mintime=728503200000)

Can you give me an example of a timestamp of 1/1/1993 that does successfully work in this example code?

Since we don't have logs that go back that far (way before our time :p) we also check the length of the timestamp. We assume that if its less than 13 characters than the user might have put in seconds instead of milliseconds and we return an error. Sorry, we should have been more clear but we will update our documentation to at least mention that the size needs to be 13 characters (or the earliest date we can represent with 13 chars)

Okay that makes sense - I had a feeling some tight validation was going on. Thanks for the clarification.

What is the earliest possible time one can use to get all logs since the beginning of the use of Duo? In other words, when did Duo become a product? I'd like to get all logs possible.

@mrinehart-r7,

Any 13 char mintime value is valid (so you could even use 1000000000000).

However, on May 2 we will start limiting the authentication log v1 endpoint results via API to the previous 180 days. The v2 authentication logs endpoint is already limited to returning 180 days.