I have some questions related with user context and auditing for background job execution for SaaS application.
Let's say an admin user scheduled a background job through UI. When the job start running, this job requires to run with a user context, for such case I have following questions:
Question 1: should this job use the admin user in the user context? If so, how about if this is a recurring job and the user leave the company later on and the user account is expired? The job execution will be failed.
Question 2: if the background job need to trigger some code that have permission check logic inside, should we make sure the admin user has been granted with those permissions? Otherwise, the job execution will be failed.
Question 3: if this job will update some PII (personal identifiable information) data, we would like to create audit log for example for GDPR compliance. Should we create an audit log with this admin user as the updater?
I saw some solutions will request end user to provide a technical user when schedule a job. That user is pre-created in the system and usually customer will guarantee this technical user is not expired and with all the permissions granted. However, if we do so, when we create the audit log, should we use the user who triggered the job as the updater or use the technical user?
I am very confused. I would like to know the best practice and pro and cons with different solutions.
Thanks!