Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use user token in external enforcement if not configured #116

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions blazar/enforcement/enforcement.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def format_context(self, context, lease_values):
region_name = CONF.os_region_name
auth_url = base.url_for(
ctx['service_catalog'], CONF.identity_service,
endpoint_interface="public",
os_region_name=region_name)

return dict(user_id=lease_values['user_id'],
Expand Down
8 changes: 7 additions & 1 deletion blazar/enforcement/filters/external_service_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from blazar.enforcement.filters import base_filter
from blazar.exceptions import BlazarException
from blazar.i18n import _
from blazar.utils.openstack.keystone import BlazarKeystoneClient

from oslo_config import cfg
from oslo_log import log as logging
Expand Down Expand Up @@ -96,7 +97,12 @@ def __init__(self, conf=None):
raise ExternalServiceMisconfigured(
message=_("ExternalService has no endpoints set."))

self.token = conf.enforcement.external_service_token
if conf.enforcement.external_service_token:
self.token = (self.external_service_token)
else:
client = BlazarKeystoneClient()
self.token = client.session.get_token()


@staticmethod
def _validate_url(url):
Expand Down