Git Product home page Git Product logo

swiftpolicy's Introduction

SwiftPolicy Middleware

The SwiftPolicy Middleware for OpenStack Swift allows to use a JSON policy file to handle swift authorizations.

SwiftPolicy is an adaptation of the keystoneauth middleware here: https://github.com/openstack/swift/blob/master/swift/common/middleware/keystoneauth.py

Install

  1. Install SwiftPolicy with sudo python setup.py install or sudo python setup.py develop.

  2. Alter your proxy-server.conf pipeline to include SwiftPolicy:

For example, you can use SwiftPolicy in place of the keystoneauth middleware:

Change::

    [pipeline:main]
    pipeline = catch_errors cache tempauth proxy-server

To::

    [pipeline:main]
    pipeline = catch_errors cache swiftpolicy tempauth proxy-server
  1. Add to your proxy-server.conf the section for the SwiftPolicy WSGI filter.

The policy file is set with the policy option ::

[filter:swift3]
use = egg:swiftpolicy#swiftpolicy
policy = %(here)s/default.json

This middleware comes with a default policy file in /etc/swift/default.json that maintains compatibility with keystoneauth.

Policy file

The policy file will list all possible actions on a swift proxy. Action's syntax is: <http verb>_<swift entity> (example: "get_container", "put_object", etc).

...
"get_container": "rule:allowed_for_user",
"put_container": "rule:allowed_for_user",
"delete_container": "rule:allowed_for_user",
...

The policy file contains also two specific rules: "swift_owner" "reseller_request", they are defined when swift_owner and reseller_request headers are set to true, as those two values are part of the contract with the auth system (more details here: http://docs.openstack.org/developer/swift/overview_auth.html)

...
"swift_owner": "rule:swift_reseller or rule:swift_operator",
"reseller_request": "rule:swift_reseller",
...

  Example

  • To forbid the creation of new containers: set put_container to '!':

      ...
      "get_container": "rule:allowed_for_user",
      "put_container": "!",
      ...
    
  • To restrict the creation of new containers to users with the role "admin":

      ...
      "get_container": "rule:allowed_for_user",
      "put_container": "role:admin",
      ...
    

Limitations

  • swiftpolicy does not support dynamic reload of policies, and thus, the swift proxy has to be restarted when the policy file is updated.

swiftpolicy's People

Contributors

grindizer avatar mhuin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.