Example #1
0
# 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.

import falcon
import kubernetes

from promenade.control.base import BaseResource
from promenade.builder import Builder
from promenade.config import Configuration
from promenade import exceptions
from promenade import logging
from promenade import policy

LOG = logging.getLogger(__name__)

SENTINEL = object()


class JoinScriptsResource(BaseResource):
    """
    Lists the versions supported by this API
    """
    @policy.ApiEnforcer('kubernetes_provisioner:get_join_scripts')
    def on_get(self, req, resp):
        leave_kubectl = req.get_param_as_bool('leave_kubectl')
        design_ref = req.get_param('design_ref', required=True)
        # The required IP address to be used by Kubernetes itself
        ip = req.get_param('ip', required=True)
        # The optional IP address to configure as externally-routable
# 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.

import uuid

from promenade import logging
from promenade import policy

LOG = logging.getLogger('promenade')


class AuthMiddleware(object):
    # Authentication
    def process_request(self, req, resp):
        ctx = req.context
        ctx.set_policy_engine(policy.policy_engine)

        # don't spam log with headers for health checks
        if not req.url.endswith('/health'):
            for k, v in req.headers.items():
                LOG.debug("Request with header %s: %s" % (k, v))

        auth_status = req.get_header(
            'X-SERVICE-IDENTITY-STATUS')  # will be set to Confirmed or Invalid