dpguthrie / dbtc

39 stars 12 forks source link

Feature request for audit logs to include failed login attempts #99

Open jens-egerod-ruter opened 11 months ago

jens-egerod-ruter commented 11 months ago

Hi, we would like to monitor failed login attempts to our account. We are using https://dbtc.dpguthrie.com/0.2/guide/cloud/#list_audit_logs to access the audit logs.

it includes these event types: credentials.added credentials.changed environment.changed job_definition.added job_definition.changed job_definition.removed login.sso.succeeded project.changed

please add events for: login.sso.failed login.XYZ.failed

and any/all other relevant events

dpguthrie commented 11 months ago

The events themselves are not something that this package controls - that's internal to dbt Cloud. That being said, we do have some authentication events that are being logged. Are you able to see these?

jens-egerod-ruter commented 11 months ago

Hi yes the authentication events is what we would like to get access too :) How to get access to those events? v1.events.auth_provider.Changed v1.events.auth.CredentialsLoginFailed v1.events.auth.CredentialsLoginSucceeded v1.events.auth.SsoLoginFailed v1.events.auth.SsoLoginSucceeded

The code below is what I use and only receive logs for these events: credentials.added credentials.changed environment.changed job_definition.added job_definition.changed job_definition.removed login.sso.succeeded project.changed

from datetime import date, timedelta
from dbtc import dbtCloudClient

#Date to begin retrieving audit logs Format is yyyy-mm-dd
logged_at_start= str(date.today()- timedelta(days = 20))
#Date to stop retrieving audit logs. Format is yyyy-mm-dd
logged_at_end= str(date.today()- timedelta(days = 1))

#account id to dbt cloud
account_id=1234

audit_logs = client.cloud.list_audit_logs(account_id=account_id,
                                              logged_at_start=logged_at_start,
                                              logged_at_end=logged_at_end )