GitHub user LeandroMartinMacato edited a comment on the discussion: Monitoring 
and Auditing Tools in Superset

Hello we are using Superset version 3.1.1, we tried creating a custom 
`DbEventLogger` and was able to put custom code in actions but there is no 
trigger for User Management actions (Ex: Add user , edit User etc..)

we are planning to make User Management Security Auditing for (CRUD) 
operations, would appreciate help on how we could make logging actions on user 
management

thank you!

```python
# Inside `superset_config.py`

class CustomUserEventLogger(DBEventLogger):
    def log(self, user_id, action, *args, **kwargs):
        print(f"USER: {user_id} >>>>>>>> PERFORMED : {action} 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
        # You can add custom logic here to filter for user management actions
        if action in ["user_create", "user_update", "user_delete"]:
            # Add your custom logging logic here
            print(f"User management action: {action}, user_id: {user_id}, 
details: {kwargs}")
        # Call the parent logger to keep default behavior
        super().log(user_id, action, *args, **kwargs)

EVENT_LOGGER = CustomUserEventLogger()
```

GitHub link: 
https://github.com/apache/superset/discussions/33538#discussioncomment-14642292

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to