
If /etc/resolv.conf is empty the patch controller will raise an uncaught exception due to osprofiler attempting to validate dns. osprofiler is unused by patching, so the module is disabled by the patch controller. All sw-patch CLI commands will fail prior to setting up resolv.conf (bootstrapping) without this fix, since there is no working patch controller sysinv.common.utils also pulls in dns, so the two utility methods are cloned into patching repo. Test Plan: PASS Build/Install AIO-SX Debian PASS upload a patch Story: 2009969 Task: 45838 Signed-off-by: Al Bailey <al.bailey@windriver.com> Change-Id: I0975f5b54a17a0989a78f6ac39160af0b3e26013
45 lines
1.5 KiB
Python
Executable File
45 lines
1.5 KiB
Python
Executable File
# -*- encoding: utf-8 -*-
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
#
|
|
# Copyright (c) 2022 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
from keystonemiddleware import auth_token
|
|
from cgcs_patch import utils
|
|
|
|
|
|
class AuthTokenMiddleware(auth_token.AuthProtocol):
|
|
"""A wrapper on Keystone auth_token middleware.
|
|
|
|
Does not perform verification of authentication tokens
|
|
for public routes in the API.
|
|
|
|
"""
|
|
def __init__(self, app, conf, public_api_routes=None):
|
|
if public_api_routes is None:
|
|
public_api_routes = []
|
|
|
|
self.public_api_routes = set(public_api_routes)
|
|
|
|
super(AuthTokenMiddleware, self).__init__(app, conf)
|
|
|
|
def __call__(self, env, start_response):
|
|
path = utils.safe_rstrip(env.get('PATH_INFO'), '/')
|
|
|
|
if path in self.public_api_routes:
|
|
return self.app(env, start_response) # pylint: disable=no-member
|
|
|
|
return super(AuthTokenMiddleware, self).__call__(env, start_response) # pylint: disable=too-many-function-args
|