~ubuntu-branches/ubuntu/precise/keystone/precise

« back to all changes in this revision

Viewing changes to doc/source/old/middleware.rst

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2012-03-16 11:19:40 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120316111940-kpyy12noi4aikyde
Tags: 2012.1~rc1~20120316.2145-0ubuntu1
New upstream release. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
..
2
 
      Copyright 2011-2012 OpenStack, LLC
3
 
      All Rights Reserved.
4
 
 
5
 
      Licensed under the Apache License, Version 2.0 (the "License"); you may
6
 
      not use this file except in compliance with the License. You may obtain
7
 
      a copy of the License at
8
 
 
9
 
          http://www.apache.org/licenses/LICENSE-2.0
10
 
 
11
 
      Unless required by applicable law or agreed to in writing, software
12
 
      distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
 
      WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
 
      License for the specific language governing permissions and limitations
15
 
      under the License.
16
 
 
17
 
==========
18
 
Middleware
19
 
==========
20
 
 
21
 
The Keystone middleware sits in front of an OpenStack service and handles authenticating
22
 
incoming requests. The middleware was designed according to `this spec`.
23
 
 
24
 
The middleware is found in source under Keystone/middleware.
25
 
 
26
 
The middleware supports two interfaces; WSGI and REST/HTTP.
27
 
 
28
 
.. _`this spec`: http://wiki.openstack.org/openstack-authn
29
 
 
30
 
REST & HTTP API
31
 
===============
32
 
 
33
 
If an unauthenticated call comes in, the middleware will respond with a 401 Unauthorized error. As per
34
 
HTTP standards, it will also return a WWW-Authenticate header informing the caller
35
 
of what protocols are supported. For Keystone authentication, the response syntax will be::
36
 
 
37
 
    WWW-Authenticate: Keystone uri="url to Keystone server"
38
 
 
39
 
The client can then make the necessary calls to the Keystone server, obtain a token, and retry the call with the token.
40
 
 
41
 
The token is passed in using ther X-Auth-Token header.
42
 
 
43
 
WSGI API (Headers)
44
 
==================
45
 
 
46
 
Upon successful authentication the middleware sends the following
47
 
headers to the downstream WSGI app:
48
 
 
49
 
X-Identity-Status
50
 
    Provides information on whether the request was authenticated or not.
51
 
 
52
 
X-Tenant
53
 
    Provides the tenant ID (as it appears in the URL in Keystone). This is to support any legacy implementations before Keystone switched to an ID/Name schema for tenants.
54
 
 
55
 
X-Tenant-Id
56
 
    The unique, immutable tenant Id
57
 
 
58
 
X-Tenant-Name
59
 
    The unique, but mutable (it can change) tenant name.
60
 
 
61
 
X-User-Id
62
 
    The user id of the user used to log in
63
 
 
64
 
X-User-Name
65
 
    The username used to log in
66
 
 
67
 
X-User
68
 
    The username used to log in. This is to support any legacy implementations before Keystone switched to an ID/Name schema for tenants.
69
 
 
70
 
X-Roles
71
 
    The roles associated with that user
72
 
 
73
 
 
74
 
Configuration
75
 
=============
76
 
 
77
 
The middleware is configured within the config file of the main application as
78
 
a WSGI component. Example for the auth_token middleware::
79
 
 
80
 
    [app:myService]
81
 
    paste.app_factory = myService:app_factory
82
 
 
83
 
    [pipeline:main]
84
 
    pipeline =
85
 
        tokenauth
86
 
        myService
87
 
 
88
 
    [filter:tokenauth]
89
 
    paste.filter_factory = keystone.middleware.auth_token:filter_factory
90
 
    auth_host = 127.0.0.1
91
 
    auth_port = 35357
92
 
    auth_protocol = http
93
 
    auth_uri = http://127.0.0.1:5000/
94
 
    admin_token = 999888777666
95
 
    ;Uncomment next line and check ip:port to use memcached to cache token requests
96
 
    ;memcache_hosts = 127.0.0.1:11211
97
 
 
98
 
*The required configuration entries are:*
99
 
 
100
 
auth_host
101
 
    The IP address or DNS name of the Keystone server
102
 
 
103
 
auth_port
104
 
    The TCP/IP port of the Keystone server
105
 
 
106
 
auth_protocol
107
 
    The protocol of the Keystone server ('http' or 'https')
108
 
 
109
 
auth_uri
110
 
    The externally accessible URL of the Keystone server. This will be where unauthenticated
111
 
    clients are redirected to. This is in the form of a URL. For example, if they make an
112
 
    unauthenticated call, they get this response::
113
 
 
114
 
        HTTP/1.1 401 Unauthorized
115
 
        Www-Authenticate: Keystone uri='https://auth.example.com/'
116
 
        Content-Length: 381
117
 
 
118
 
    In this case, the auth_uri setting is set to https://auth.example.com/
119
 
 
120
 
admin_token
121
 
    This is the long-lived token issued to the service to authenticate itself when calling
122
 
    Keystone. See :doc:`configuration` for more information on setting this up.
123
 
 
124
 
 
125
 
*Optional parameters are:*
126
 
 
127
 
delay_auth_decision
128
 
    Whether the middleware should reject invalid or unauthenticated calls directly or not. If not,
129
 
    it will send all calls down to the service to decide, but it will set the HTTP-X-IDENTITY-STATUS
130
 
    header appropriately (set to'Confirmed' or 'Indeterminate' based on validation) and the
131
 
    service can then decide if it wants to honor the call or not. This is useful if the service offers
132
 
    some resources publicly, for example.
133
 
 
134
 
auth_timeout
135
 
    The amount of time to wait before timing out a call to Keystone (in seconds)
136
 
 
137
 
memcache_hosts
138
 
    This is used to point to a memcached server (in ip:port format). If supplied,
139
 
    the middleware will cache tokens and data retrieved from Keystone in memcached
140
 
    to minimize calls made to Keystone and optimize performance.
141
 
 
142
 
.. warning::
143
 
    Tokens are cached for the duration of their validity. If they are revoked eariler in Keystone,
144
 
    the service will not know and will continue to honor the token as it has them stored in memcached.
145
 
    Also note that tokens and data stored in memcached are not encrypted. The memcached server must
146
 
    be trusted and on a secure network.
147
 
 
148
 
 
149
 
*Parameters needed in a distributed topology.* In this configuration, the middleware is running
150
 
on a separate machine or cluster than the protected service (not common - see :doc:`middleware_architecture`
151
 
for details on different deployment topologies):
152
 
 
153
 
service_host
154
 
    The IP address or DNS name of the location of the service (since it is remote
155
 
    and not automatically down the WSGI chain)
156
 
 
157
 
service_port
158
 
    The TCP/IP port of the remote service.
159
 
 
160
 
service_protocol
161
 
    The protocol of the service ('http' or 'https')
162
 
 
163
 
service_pass
164
 
    The basic auth password used to authenticate to the service (so the service
165
 
    knows the call is coming from a server that has validated the token and not from
166
 
    an untrusted source or spoofer)
167
 
 
168
 
service_timeout
169
 
    The amount of time to wait for the service to respond before timing out.