charm-helpers icon indicating copy to clipboard operation
charm-helpers copied to clipboard

openstack: add keystone audit middleware support

Open arif-ali opened this issue 2 years ago • 4 comments

This PR is in preparation to fulfil the audit middleware specification as documented in

https://specs.openstack.org/openstack/charm-specs/specs/2023.1/backlog/audit-middleware.html

First review for nova-cloud-controller charm

https://review.opendev.org/c/openstack/charm-nova-cloud-controller/+/887213

Once this is merged, we can then do the rest of the charms in LP#1856555

arif-ali avatar Jun 28 '23 17:06 arif-ali

One minor style point that is not important, but may make the code a little easier to read.

Updated the PR

Only thing needed prior to merging is a gerrit review that exercises the change so we can verify that the change is good. Please could you link a review to the PR's description? Thanks.

I've added the first review and the LP bug in the description. The review still needs rebasing once this PR is merged so that I can remove the location off the charmhelpers sync.

There are several other charms that need doing too, so once this PR is merged we can crack on with the others

arif-ali avatar Jul 01 '23 10:07 arif-ali

just found an issue with this, while testing, so marking it as a draft

seems like that self.service could be None, hence the process will not work; so need another way to overcome that

arif-ali avatar Jul 04 '23 23:07 arif-ali

To avoid the issues encountered by using an optional field, I think this should likely just be a new Context object with the explicit needs of enabling the Audit Middleware. This way, the service will explicitly opt into it via a config option as well as leveraging the new Context.

wolsen avatar Sep 29 '23 15:09 wolsen

@arif-ali if the additional items are pulled out into a new context, as @wolsen suggests, it would look something like:

class KeystoneAuditMiddleware(OSContextGenerator):
    def __init__(self, service_name):
        self.service_name = service_name
    def __call__(self):
        ctxt = {
            'audit_middleware': config('audit-middleware) or False,
            'service_name': service_name,
        }
        return ctxt

And then it can just be used by including the new Context in the resource_map and then it could be used in the templates as is in the current patch. This would also significantly simplify the testing.

ajkavanagh avatar Sep 29 '23 17:09 ajkavanagh

As Myles is now working on this, I'm closing this PR

arif-ali avatar Jun 12 '24 15:06 arif-ali