"Fossies" - the Fresh Open Source Software Archive

Member "ec2-api-12.0.0/ec2api/api/auth.py" (14 Apr 2021, 1423 Bytes) of package /linux/misc/openstack/ec2-api-12.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "auth.py" see the Fossies "Dox" file reference documentation.

    1 # Copyright 2014
    2 # The Cloudscaling Group, Inc.
    3 #
    4 # Licensed under the Apache License, Version 2.0 (the "License");
    5 # you may not use this file except in compliance with the License.
    6 # You may obtain a copy of the License at
    7 # http://www.apache.org/licenses/LICENSE-2.0
    8 #
    9 # Unless required by applicable law or agreed to in writing, software
   10 # distributed under the License is distributed on an "AS IS" BASIS,
   11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   12 # See the License for the specific language governing permissions and
   13 # limitations under the License.
   14 
   15 """
   16 Common Auth Middleware.
   17 
   18 """
   19 
   20 from oslo_config import cfg
   21 from oslo_log import log as logging
   22 
   23 
   24 auth_opts = [
   25     cfg.BoolOpt('use_forwarded_for',
   26                 default=False,
   27                 help='Treat X-Forwarded-For as the canonical remote address. '
   28                      'Only enable this if you have a sanitizing proxy.'),
   29 ]
   30 
   31 CONF = cfg.CONF
   32 CONF.register_opts(auth_opts)
   33 
   34 LOG = logging.getLogger(__name__)
   35 
   36 
   37 def pipeline_factory(loader, global_conf, **local_conf):
   38     """A paste pipeline replica that keys off of auth_strategy."""
   39     auth_strategy = "keystone"
   40     pipeline = local_conf[auth_strategy]
   41     pipeline = pipeline.split()
   42     filters = [loader.get_filter(n) for n in pipeline[:-1]]
   43     app = loader.get_app(pipeline[-1])
   44     filters.reverse()
   45     for fltr in filters:
   46         app = fltr(app)
   47     return app