File: policies.rst

package info (click to toggle)
glance 2014.1.3-12
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 12,804 kB
  • sloc: python: 54,757; sql: 381; sh: 320; makefile: 37
file content (142 lines) | stat: -rw-r--r-- 4,137 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
..
      Copyright 2012 OpenStack Foundation
      All Rights Reserved.

      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.

Policies
========

Glance's public API calls may be restricted to certain sets of users using a
policy configuration file. This document explains exactly how policies are
configured and what they apply to.

A policy is composed of a set of rules that are used by the policy "Brain" in
determining if a particular action may be performed by the authorized tenant.

Constructing a Policy Configuration File
----------------------------------------

A policy configuration file is a simply JSON object that contain sets of
rules. Each top-level key is the name of a rule. Each rule
is a string that describes an action that may be performed in the Glance API.

The actions that may have a rule enforced on them are:

* ``get_images`` - List available image entities

  * ``GET /v1/images``
  * ``GET /v1/images/detail``
  * ``GET /v2/images``

* ``get_image`` - Retrieve a specific image entity

  * ``HEAD /v1/images/<IMAGE_ID>``
  * ``GET /v1/images/<IMAGE_ID>``
  * ``GET /v2/images/<IMAGE_ID>``

* ``download_image`` - Download binary image data

  * ``GET /v1/images/<IMAGE_ID>``
  * ``GET /v2/images/<IMAGE_ID>/file``

* ``upload_image`` - Upload binary image data

  * ``POST /v1/images``
  * ``PUT /v1/images/<IMAGE_ID>``
  * ``PUT /v2/images/<IMAGE_ID>/file``

* ``copy_from`` - Copy binary image data from URL

  * ``POST /v1/images``
  * ``PUT /v1/images/<IMAGE_ID>``

* ``add_image`` - Create an image entity

  * ``POST /v1/images``
  * ``POST /v2/images``

* ``modify_image`` - Update an image entity

  * ``PUT /v1/images/<IMAGE_ID>``
  * ``PUT /v2/images/<IMAGE_ID>``

* ``publicize_image`` - Create or update images with attribute

  * ``POST /v1/images`` with attribute ``is_public`` = ``true``
  * ``PUT /v1/images/<IMAGE_ID>`` with attribute ``is_public`` = ``true``
  * ``POST /v2/images`` with attribute ``visibility`` = ``public``
  * ``PUT /v2/images/<IMAGE_ID>`` with attribute ``visibility`` = ``public``

* ``delete_image`` - Delete an image entity and associated binary data

  * ``DELETE /v1/images/<IMAGE_ID>``
  * ``DELETE /v2/images/<IMAGE_ID>``

* ``add_member`` - Add a membership to the member repo of an image

  * ``POST /v2/images/<IMAGE_ID>/members``

* ``get_members`` - List the members of an image

  * ``GET /v1/images/<IMAGE_ID>/members``
  * ``GET /v2/images/<IMAGE_ID>/members``

* ``delete_member`` - Delete a membership of an image

  * ``DELETE /v1/images/<IMAGE_ID>/members/<MEMBER_ID>``
  * ``DELETE /v2/images/<IMAGE_ID>/members/<MEMBER_ID>``

* ``modify_member`` - Create or update the membership of an image

  * ``PUT /v1/images/<IMAGE_ID>/members/<MEMBER_ID>``
  * ``PUT /v1/images/<IMAGE_ID>/members``
  * ``POST /v2/images/<IMAGE_ID>/members``
  * ``PUT /v2/images/<IMAGE_ID>/members/<MEMBER_ID>``

* ``manage_image_cache`` - Allowed to use the image cache management API


To limit an action to a particular role or roles, you list the roles like so ::

  {
    "delete_image": ["role:admin", "role:superuser"]
  }

The above would add a rule that only allowed users that had roles of either
"admin" or "superuser" to delete an image.

Examples
--------

Example 1. (The default policy configuration)

 ::

  {
      "default": []
  }

Note that an empty JSON list means that all methods of the
Glance API are callable by anyone.

Example 2. Disallow modification calls to non-admins

 ::

  {
      "default": [],
      "add_image": ["role:admin"],
      "modify_image": ["role:admin"],
      "delete_image": ["role:admin"]
  }