Automatic userId relation on creation

Is there a way to automatically provide a field userId (from authenticable entity User) using the Bearer token while item creation? I'd like to make the field userId optional in the request, and provide the requesting user's id when not provided. I was thinking about using middlewares, but how do I access the current user?
Was this page helpful?