lemur icon indicating copy to clipboard operation
lemur copied to clipboard

Syncing Source for Entrust hit error: '_AppCtxGlobals' object has no attribute 'identity'

Open yiluzhu opened this issue 4 years ago • 6 comments

Hi there,

When I was syncing source Entrust, I got the below error:

Traceback (most recent call last): File "/www/lemur/lemur/sources/cli.py", line 93, in sync data = source_service.sync(source, user) File "/www/lemur/lemur/sources/service.py", line 230, in sync new_certs, updated_certs, updated_certs_by_hash = sync_certificates(source, user) File "/www/lemur/lemur/sources/service.py", line 214, in sync_certificates certificate_create(certificate, source) File "/www/lemur/lemur/sources/service.py", line 30, in certificate_create data, errors = CertificateUploadInputSchema().load(certificate) File "/home/lemur/lemur/lib/python3.6/site-packages/marshmallow/schema.py", line 588, in load result, errors = self._do_load(data, many, partial=partial, postprocess=True) File "/home/lemur/lemur/lib/python3.6/site-packages/marshmallow/schema.py", line 670, in _do_load index_errors=self.opts.index_errors, File "/home/lemur/lemur/lib/python3.6/site-packages/marshmallow/marshalling.py", line 290, in deserialize index=(index if index_errors else None) File "/home/lemur/lemur/lib/python3.6/site-packages/marshmallow/marshalling.py", line 63, in call_and_store value = getter_func(data) File "/home/lemur/lemur/lib/python3.6/site-packages/marshmallow/marshalling.py", line 283, in data File "/home/lemur/lemur/lib/python3.6/site-packages/marshmallow/fields.py", line 266, in deserialize self._validate(output) File "/home/lemur/lemur/lib/python3.6/site-packages/marshmallow/fields.py", line 196, in _validate r = validator(value) File "/www/lemur/lemur/common/validators.py", line 104, in csr common_name(name.value) File "/www/lemur/lemur/common/validators.py", line 20, in common_name return sensitive_domain(value) File "/www/lemur/lemur/common/validators.py", line 29, in sensitive_domain if SensitiveDomainPermission().can(): File "/home/lemur/lemur/lib/python3.6/site-packages/flask_principal.py", line 347, in can return self.require().can() File "/home/lemur/lemur/lib/python3.6/site-packages/flask_principal.py", line 193, in can return self.identity.can(self.permission) File "/home/lemur/lemur/lib/python3.6/site-packages/flask_principal.py", line 188, in identity return g.identity File "/home/lemur/lemur/lib/python3.6/site-packages/werkzeug/local.py", line 347, in getattr return getattr(self._get_current_object(), name) AttributeError: '_AppCtxGlobals' object has no attribute 'identity'

Syncing other sources is fine. Any idea what might be wrong?

yiluzhu avatar Feb 08 '21 23:02 yiluzhu

I've tried syncing both via lemur cli and via celery task, but no difference.

yiluzhu avatar Feb 08 '21 23:02 yiluzhu

@sirferl: This is the Entrust plugin. Could you see what might be wrong here?

yiluzhu avatar Feb 13 '21 12:02 yiluzhu

@yiluzhu not checking always in here, so I saw this just now. Looks like postprocessing after returning the data from the plugin misses attributes in the data. I will check on monday whether I can reproduce.

sirferl avatar Feb 13 '21 14:02 sirferl

Thanks, sirferl. This only happens for Entrust, other source worked fine, so I wondered if that might be related to Entrust certificate data.

yiluzhu avatar Feb 13 '21 18:02 yiluzhu

@yiluzhu I tried it out in my Test-environment and there was no error. On closer examination I noticed in your log-snippet, that the error is thrown when getting the principal. I tried the test with the lemur-user account on my system. Maybe there is something wrong with the account used to perform the sync on your side.

sirferl avatar Feb 15 '21 11:02 sirferl

@sirferl Thanks, that's really helpful. I'll check the account on my side.

yiluzhu avatar Feb 15 '21 17:02 yiluzhu