Automatic Logging doesn't log the Actor
See original GitHub issueI have installed the plugin and on an Django Rest Framework instance. All the logging is working as expected, except the Logging of the Actor. I added the Middleware as Described in the Docs but its still not logging any Actor.
Here is my configuration:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'corsheaders',
'oauth2_provider',
'rest_framework',
'auditlog',
'stammdaten.apps.StammdatenConfig',
'main.apps.MainConfig',
'rest_framework_swagger',
]
OAUTH2_PROVIDER = {
# this is the list of available scopes
'SCOPES': {'read': 'Read scope', 'write': 'Write scope', 'groups': 'Access to your groups'},
'ACCESS_TOKEN_EXPIRE_SECONDS': 43200
}
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'oauth2_provider.ext.rest_framework.OAuth2Authentication',
),
'DEFAULT_PERMISSION_CLASSES': (
'rest_framework.permissions.IsAuthenticated',
),
'PAGE_SIZE': 10
}
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'oauth2_provider.middleware.OAuth2TokenMiddleware',
'auditlog.middleware.AuditlogMiddleware'
]
What am I missing here? Is it a problem with the OAuth Toolkit or did I missconfig anything?
Issue Analytics
- State:
- Created 6 years ago
- Comments:43 (10 by maintainers)
Top Results From Across the Web
Automatic Logging doesn't log the Actor · Issue #115 - GitHub
I have installed the plugin and on an Django Rest Framework instance. All the logging is working as expected, except the Logging of...
Read more >scala - akka.actor.ActorLogging does not log the stack trace of ...
I am using Logback + SLF4J to do logging for those actors with trait of akka.actor.
Read more >Manage automatic logging | New Relic Documentation
How to manage automatic logging when necessary for agents using APM logs in context.
Read more >Logging - Documentation - Akka
The Logger via the ActorContext will automatically have a name that corresponds to the Behavior Behavior of the actor when the log is...
Read more >Actor Logging with Akka .NET - Gigi Labs
We can adjust our actor's code to use a logger instead of writing directly to the console. The actor doesn't care what kind...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hello everyone!
I had the same issue when trying to integrate
django-auditlog
withDjango Rest Framework
(DRF).I have been digging into the source code of both projects to understand the reason the
actor
is not being set and found a reason.django-auditlog
expects the user being logged at Django’s middleware layer as usual but DRF, for design decision, does not perform the authentication at middleware level instead it performs the authentication at View level by using tte configured mechanisms. It means just before executing the code which processes the request and generates a response. Here is the difference with Django itself! That is the reason whyis_autenticated
is alwaysFalse
at the middleware layer, as result the handler to set the actor onpre_save
signal is not being connected.I’ve created a glue code which works as integration between both projects. The approach I took is to use
mixins
as many components of DRF does . This integrations is not coupled with any AUTH mechanism which is good, it leaves that behavior to DRF, that is a big difference with the approach taken by @ivan-fedorov-probegin (Im not telling it is bad!) . I’ve been using this integration in production without issues at all 😃. I would like to know if you are open to merge some DRF integrations… In that case I’ll be happy to propose a pull request. (cc @jjkester )Integration mixin
Minimal usage example
I would like to hear feedback from the projects! Anyways, you could take this code/ideas for you projects.
Thanks in advance!
for rest_framework_simplejwt