可以通过以下步骤来实现权限日志记录:
from superset.security import SupersetSecurityManager
class CustomSecurityManager(SupersetSecurityManager):
def after_login(self, user, **kwargs):
logging.info('User {} logged in'.format(user.username))
return super().after_login(user, **kwargs)
def after_logout(self, user, **kwargs):
logging.info('User {} logged out'.format(user.username))
return super().after_logout(user, **kwargs)
def view_menu(self):
logging.info('User {} is viewing the menu'.format(g.user.username))
return super().view_menu()
from superset.security import SupersetSecurityManager
from my_custom_security_manager import CustomSecurityManager
# Use my custom security manager
AUTH_TYPE = AUTH_OAUTH # or any other auth type like AUTH_DB, AUTH_LDAP, AUTH_REMOTE_USER, etc.
CUSTOM_SECURITY_MANAGER = CustomSecurityManager
...
这样就可以在Superset中记录用户登录、退出和对菜单的访问等操作的日志。通过将SupersetSecurityManager类进行扩展,利用after_login、after_logout和view_menu等方法进行日志记录即可。