Merge "Docs,wadls,samples,initial code to support RAX-KSKEY and OS-KSEC2 extensions. Removed tenant id from being part of endpoints."

This commit is contained in:
Jenkins 2011-09-14 22:07:27 +00:00 committed by Gerrit Code Review
commit a913210194
31 changed files with 720 additions and 25 deletions

View File

@ -64,7 +64,7 @@
<method href="#addUserCredential"/>
<method href="#listCredentials"/>
<resource id="userCredentialsByType" path="{credential-type}">
<param name="credentialType" style="template" type="OS-KSADM:extensibleCredentialsType"/>
<param name="credentialType" style="template" type="OS-KSADM:extensibleCredentialsType" required="true"/>
<method href="#updateUserCredential"/>
<method href="#deleteUserCredential"/>
<method href="#getUserCredential"/>
@ -84,21 +84,22 @@
<resource id="rolesForTenant" path="roles">
<method href="#listRolesForTenant"/>
</resource>
<resource id="usersForTenant" path="users">
<method href="#listUsersForTenant"/>
<method href="#listUsersWithRoleForTenant"/>
<resource id="userForTenant" path="{userId}">
<param name="userId" style="template" type="xsd:string"/>
<resource id="userRolesForTenant" path="roles">
</resource>
<resource id="usersForTenant" path="users">
<method href="#listUsersForTenant"/>
<method href="#listUsersWithRoleForTenant"/>
<resource id="userForTenant" path="{userId}">
<param name="userId" style="template" type="xsd:string"/>
<resource id="userRolesForTenant" path="roles">
<resource id="tenant-user-role-OS-KSADM" path="OS-KSADM">
<resource id="userSpecificRoleForTenant" path="{roleId}">
<method href="#addRolesToUserOnTenant"/>
<method href="#deleteRoleFromUserOnTenant"/>
</resource>
</resource>
</resource>
</resource>
</resource>
</resource>
</resource>
</resource>
</resource>
@ -265,7 +266,7 @@
</method>
<method name="PUT" id="addRolesToUserOnTenant">
<doc xml:lang="EN" title="Add roles on a tenant.">
<doc xml:lang="EN" title="Add roles to a user on a tenant.">
<p xmlns="http://www.w3.org/1999/xhtml">Adds a specific role to a user for a tenant.</p>
<examples xmlns="http://docs.rackspace.com/api" title="Add role to a user for a Tenant Request ">
<example href="../common/samples/norequestbody.txt"/>
@ -278,9 +279,9 @@
</method>
<method name="DELETE" id="deleteRoleFromUserOnTenant">
<doc xml:lang="EN" title="Delete roles on tenant.">
<doc xml:lang="EN" title="Delete roles from a user on tenant.">
<p xmlns="http://www.w3.org/1999/xhtml">Deletes a specific role from a user for a tenant.</p>
<examples xmlns="http://docs.rackspace.com/api" title="Delete Role From User For a Tenant Request">
<examples xmlns="http://docs.rackspace.com/api" title="Delete Role from User for a Tenant Request">
<example href="../common/samples/norequestbody.txt"/>
</examples>
</doc>
@ -742,4 +743,4 @@
&commonFaults;
&getFaults;
</method>
</application>
</application>

Binary file not shown.

View File

@ -0,0 +1,185 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (C) 2011 OpenStack LLC., All Rights Reserved -->
<!--*******************************************************-->
<!-- Import Common XML Entities -->
<!-- -->
<!-- You can resolve the entites with xmllint -->
<!-- -->
<!-- xmllint -noent OS-KSEC2-admin.wadl -->
<!--*******************************************************-->
<!DOCTYPE application [
<!ENTITY % common SYSTEM "../common/common.ent">
%common;
]>
<application xmlns="http://wadl.dev.java.net/2009/02"
xmlns:identity="http://docs.openstack.org/identity/api/v2.0"
xmlns:OS-KSADM="http://docs.openstack.org/identity/api/ext/OS-KSADM/v1.0"
xmlns:capi="http://docs.openstack.org/common/api/v2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://docs.openstack.org/identity/api/v2.0 ../common/xsd/api.xsd
http://docs.openstack.org/common/api/v1.0 ../common/xsd/api-common.xsd
http://wadl.dev.java.net/2009/02 http://www.w3.org/Submission/wadl/wadl.xsd
http://docs.openstack.org/identity/api/ext/OS-KSADM/v1.0 ../common/xsd/OS-KSADM.xsd
">
<grammars>
<include href="../common/xsd/api.xsd"/>
<include href="../common/xsd/api-common.xsd"/>
<include href="../common/xsd/OS-KSADM.xsd" />
</grammars>
<!--*******************************************************-->
<!-- All Resoruces -->
<!--*******************************************************-->
<!-- We should use SSL in production -->
<resources base="http://localhost:5001">
<resource id="version" path="v2.0">
<param name="X-Auth-Token" style="header" type="xsd:string" required="true">
<doc>You need a valid admin token for access.</doc>
</param>
<resource id="users" path="users">
<resource id="userById" path="{userId}">
<resource id="userCredentials" path="credentials">
<method href="#addUserCredential"/>
<method href="#listCredentials"/>
<resource id="userCredentialsByType" path="OS-KSEC2:ec2Credentials">
<method href="#updateUserCredential"/>
<method href="#deleteUserCredential"/>
<method href="#getUserCredential"/>
</resource>
</resource>
</resource>
</resource>
</resource>
</resources>
<!--*******************************************************-->
<!-- All Methods -->
<!--*******************************************************-->
<!-- User Credentials-->
<method name="POST" id="addUserCredential">
<doc xml:lang="EN" title="Add user Credential.">
<p xmlns="http://www.w3.org/1999/xhtml">Adds a credential to a user.</p>
<examples xmlns="http://docs.rackspace.com/api" title="Add Credentials Request">
<example href="../common/samples/ec2Credentials.xml" language="xml"/>
<example href="../common/samples/ec2Credentials.json" language="javascript"/>
</examples>
<examples xmlns="http://docs.rackspace.com/api" title="Add Credential Response">
<example href="../common/samples/ec2Credentials.xml" language="xml"/>
<example href="../common/samples/ec2Credentials.json" language="javascript"/>
</examples>
</doc>
<request>
<representation mediaType="application/xml" element="identity:credentials"/>
<representation mediaType="application/json"/>
</request>
<response status="201">
<representation mediaType="application/xml" element="identity:credentials"/>
<representation mediaType="application/json"/>
</response>
&commonFaults;
&postPutFaults;
&getFaults;
</method>
<method name="GET" id="listCredentials">
<doc xml:lang="EN" title="List Credentials">
<p xmlns="http://www.w3.org/1999/xhtml">List credentials.</p>
<examples xmlns="http://docs.rackspace.com/api" title="List Credentials Response">
<example href="../common/samples/credentialswithec2.xml" language="xml"/>
<example href="../common/samples/credentialswithec2.json" language="javascript"/>
</examples>
</doc>
<request>
<param name="marker" style="query" required="false" type="xsd:string"/>
<param name="limit" style="query" required="false" type="xsd:int"/>
</request>
<response status="200 203">
<representation mediaType="application/xml" element="identity:credentials"/>
<representation mediaType="application/json"/>
</response>
&commonFaults;
&getFaults;
</method>
<method name="GET" id="listCredentialsByType">
<doc xml:lang="EN" title="List Credentials by type">
<p xmlns="http://www.w3.org/1999/xhtml">List credentials by type.</p>
<examples xmlns="http://docs.rackspace.com/api" title="List Credentials Response">
<example href="../common/samples/credentials.xml" language="xml"/>
<example href="../common/samples/credentials.json" language="javascript"/>
</examples>
</doc>
<request>
<param name="marker" style="query" required="false" type="xsd:string"/>
<param name="limit" style="query" required="false" type="xsd:int"/>
</request>
<response status="200 203">
<representation mediaType="application/xml" element="identity:credentials"/>
<representation mediaType="application/json"/>
</response>
&commonFaults;
&getFaults;
</method>
<method name="POST" id="updateUserCredential">
<doc xml:lang="EN" title="Update user credential">
<p xmlns="http://www.w3.org/1999/xhtml">Update credentials.</p>
<examples xmlns="http://docs.rackspace.com/api" title="Update Credential Request">
<example href="../common/samples/apikeyCredentials.xml" language="xml"/>
<example href="../common/samples/apikeyCredentials.json" language="javascript"/>
</examples>
<examples xmlns="http://docs.rackspace.com/api" title="Update Credential Response">
<example href="../common/samples/ec2Credentials.xml" language="xml"/>
<example href="../common/samples/ec2Credentials.json" language="javascript"/>
</examples>
</doc>
<request>
<representation mediaType="application/xml" element="identity:credentials"/>
<representation mediaType="application/json"/>
</request>
<response status="200">
<representation mediaType="application/xml" element="identity:credentials"/>
<representation mediaType="application/json"/>
</response>
&commonFaults;
&postPutFaults;
&getFaults;
</method>
<method name="POST" id="deleteUserCredential">
<doc xml:lang="EN" title="Delete user credential">
<p xmlns="http://www.w3.org/1999/xhtml">Delete User credentials.</p>
<examples xmlns="http://docs.rackspace.com/api" title="Delete User Credentials">
<example href="../common/samples/norequestbody.txt"/>
</examples>
</doc>
<response status="204"/>
&commonFaults;
&postPutFaults;
&getFaults;
</method>
<method name="GET" id="getUserCredential">
<doc xml:lang="EN" title="Get user Credentials">
<p xmlns="http://www.w3.org/1999/xhtml">Get user credentials.</p>
<examples xmlns="http://docs.rackspace.com/api" title="Get User Credential Response">
<example href="../common/samples/ec2Credentials.xml" language="xml"/>
<example href="../common/samples/ec2Credentials.json" language="javascript"/>
</examples>
</doc>
<response status="200 203">
<representation mediaType="application/xml" element="identity:credentials"/>
<representation mediaType="application/json"/>
</response>
&commonFaults;
&getFaults;
</method>
</application>

Binary file not shown.

View File

@ -0,0 +1,185 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- (C) 2011 OpenStack LLC., All Rights Reserved -->
<!--*******************************************************-->
<!-- Import Common XML Entities -->
<!-- -->
<!-- You can resolve the entites with xmllint -->
<!-- -->
<!-- xmllint -noent RAX-KSKEY-admin.wadl -->
<!--*******************************************************-->
<!DOCTYPE application [
<!ENTITY % common SYSTEM "../common/common.ent">
%common;
]>
<application xmlns="http://wadl.dev.java.net/2009/02"
xmlns:identity="http://docs.openstack.org/identity/api/v2.0"
xmlns:OS-KSADM="http://docs.openstack.org/identity/api/ext/OS-KSADM/v1.0"
xmlns:capi="http://docs.openstack.org/common/api/v2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://docs.openstack.org/identity/api/v2.0 ../common/xsd/api.xsd
http://docs.openstack.org/common/api/v1.0 ../common/xsd/api-common.xsd
http://wadl.dev.java.net/2009/02 http://www.w3.org/Submission/wadl/wadl.xsd
http://docs.openstack.org/identity/api/ext/OS-KSADM/v1.0 ../common/xsd/OS-KSADM.xsd
">
<grammars>
<include href="../common/xsd/api.xsd"/>
<include href="../common/xsd/api-common.xsd"/>
<include href="../common/xsd/OS-KSADM.xsd" />
</grammars>
<!--*******************************************************-->
<!-- All Resoruces -->
<!--*******************************************************-->
<!-- We should use SSL in production -->
<resources base="http://localhost:5001">
<resource id="version" path="v2.0">
<param name="X-Auth-Token" style="header" type="xsd:string" required="true">
<doc>You need a valid admin token for access.</doc>
</param>
<resource id="users" path="users">
<resource id="userById" path="{userId}">
<resource id="userCredentials" path="credentials">
<method href="#addUserCredential"/>
<method href="#listCredentials"/>
<resource id="userCredentialsByType" path="RAX-KSKEY:apikeyCredentials">
<method href="#updateUserCredential"/>
<method href="#deleteUserCredential"/>
<method href="#getUserCredential"/>
</resource>
</resource>
</resource>
</resource>
</resource>
</resources>
<!--*******************************************************-->
<!-- All Methods -->
<!--*******************************************************-->
<!-- User Credentials-->
<method name="POST" id="addUserCredential">
<doc xml:lang="EN" title="Add user Credential.">
<p xmlns="http://www.w3.org/1999/xhtml">Adds a credential to a user.</p>
<examples xmlns="http://docs.rackspace.com/api" title="Add Credentials Request">
<example href="../common/samples/apikeyCredentials.xml" language="xml"/>
<example href="../common/samples/apikeyCredentials.json" language="javascript"/>
</examples>
<examples xmlns="http://docs.rackspace.com/api" title="Add Credential Response">
<example href="../common/samples/apikeyCredentials.xml" language="xml"/>
<example href="../common/samples/apikeyCredentials.json" language="javascript"/>
</examples>
</doc>
<request>
<representation mediaType="application/xml" element="identity:credentials"/>
<representation mediaType="application/json"/>
</request>
<response status="201">
<representation mediaType="application/xml" element="identity:credentials"/>
<representation mediaType="application/json"/>
</response>
&commonFaults;
&postPutFaults;
&getFaults;
</method>
<method name="GET" id="listCredentials">
<doc xml:lang="EN" title="List Credentials">
<p xmlns="http://www.w3.org/1999/xhtml">List credentials.</p>
<examples xmlns="http://docs.rackspace.com/api" title="List Credentials Response">
<example href="../common/samples/credentialswithapikey.xml" language="xml"/>
<example href="../common/samples/credentialswithapikey.json" language="javascript"/>
</examples>
</doc>
<request>
<param name="marker" style="query" required="false" type="xsd:string"/>
<param name="limit" style="query" required="false" type="xsd:int"/>
</request>
<response status="200 203">
<representation mediaType="application/xml" element="identity:credentials"/>
<representation mediaType="application/json"/>
</response>
&commonFaults;
&getFaults;
</method>
<method name="GET" id="listCredentialsByType">
<doc xml:lang="EN" title="List Credentials by type">
<p xmlns="http://www.w3.org/1999/xhtml">List credentials by type.</p>
<examples xmlns="http://docs.rackspace.com/api" title="List Credentials Response">
<example href="../common/samples/credentials.xml" language="xml"/>
<example href="../common/samples/credentials.json" language="javascript"/>
</examples>
</doc>
<request>
<param name="marker" style="query" required="false" type="xsd:string"/>
<param name="limit" style="query" required="false" type="xsd:int"/>
</request>
<response status="200 203">
<representation mediaType="application/xml" element="identity:credentials"/>
<representation mediaType="application/json"/>
</response>
&commonFaults;
&getFaults;
</method>
<method name="POST" id="updateUserCredential">
<doc xml:lang="EN" title="Update user credential">
<p xmlns="http://www.w3.org/1999/xhtml">Update credentials.</p>
<examples xmlns="http://docs.rackspace.com/api" title="Update Credential Request">
<example href="../common/samples/apikeyCredentials.xml" language="xml"/>
<example href="../common/samples/apikeyCredentials.json" language="javascript"/>
</examples>
<examples xmlns="http://docs.rackspace.com/api" title="Update Credential Response">
<example href="../common/samples/apikeyCredentials.xml" language="xml"/>
<example href="../common/samples/apikeyCredentials.json" language="javascript"/>
</examples>
</doc>
<request>
<representation mediaType="application/xml" element="identity:credentials"/>
<representation mediaType="application/json"/>
</request>
<response status="200">
<representation mediaType="application/xml" element="identity:credentials"/>
<representation mediaType="application/json"/>
</response>
&commonFaults;
&postPutFaults;
&getFaults;
</method>
<method name="POST" id="deleteUserCredential">
<doc xml:lang="EN" title="Delete user credential">
<p xmlns="http://www.w3.org/1999/xhtml">Delete User credentials.</p>
<examples xmlns="http://docs.rackspace.com/api" title="Delete User Credentials">
<example href="../common/samples/norequestbody.txt"/>
</examples>
</doc>
<response status="204"/>
&commonFaults;
&postPutFaults;
&getFaults;
</method>
<method name="GET" id="getUserCredential">
<doc xml:lang="EN" title="Get user Credentials">
<p xmlns="http://www.w3.org/1999/xhtml">Get user credentials.</p>
<examples xmlns="http://docs.rackspace.com/api" title="Get User Credential Response">
<example href="../common/samples/apikeyCredentials.xml" language="xml"/>
<example href="../common/samples/apikeyCredentials.json" language="javascript"/>
</examples>
</doc>
<response status="200 203">
<representation mediaType="application/xml" element="identity:credentials"/>
<representation mediaType="application/json"/>
</response>
&commonFaults;
&getFaults;
</method>
</application>

View File

@ -0,0 +1,6 @@
{
"RAX-KSKEY:apikeyCredentials":{
"username":"test_user",
"apikey":"aaaaa-bbbbb-ccccc-12345678"
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<apikeyCredentials
xmlns="http://docs.rackspace.com/identity/api/ext/RAX-KSKEY/v1.0"
username="testuser"
apikey="aaaaa-bbbbb-ccccc-12345678"/>

View File

@ -20,7 +20,6 @@
"publicURL":"https://compute.north.host/v1/1234",
"internalURL":"https://compute.north.host/v1/1234",
"region":"North",
"tenantId":"1234",
"versionId":"1.0",
"versionInfo":"https://compute.north.host/v1.0/",
"versionList":"https://compute.north.host/"
@ -29,7 +28,6 @@
"publicURL":"https://compute.north.host/v1.1/3456",
"internalURL":"https://compute.north.host/v1.1/3456",
"region":"North",
"tenantId":"3456",
"versionId":"1.1",
"versionInfo":"https://compute.north.host/v1.1/",
"versionList":"https://compute.north.host/"
@ -44,7 +42,6 @@
"publicURL":"https://compute.north.host/v1/blah-blah",
"internalURL":"https://compute.north.host/v1/blah-blah",
"region":"South",
"tenantId":"1234",
"versionId":"1.0",
"versionInfo":"uri",
"versionList":"uri"
@ -53,7 +50,6 @@
"publicURL":"https://compute.north.host/v1.1/blah-blah",
"internalURL":"https://compute.north.host/v1.1/blah-blah",
"region":"South",
"tenantId":"1234",
"versionId":"1.1",
"versionInfo":"https://compute.north.host/v1.1/",
"versionList":"https://compute.north.host/"
@ -72,4 +68,4 @@
}
]
}
}
}

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<access xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://docs.openstack.org/identity/api/v2.0 ../xsd/api.xsd"
xmlns="http://docs.openstack.org/identity/api/v2.0">
<token expires="2010-11-01T03:32:15-05:00"
id="ab48a9efdfedb23ty3494"/>
@ -13,7 +12,6 @@ xmlns="http://docs.openstack.org/identity/api/v2.0">
<service type="compute" name="Computers in the Cloud">
<endpoint
region="North"
tenantId="1234"
publicURL="https://north.compute.public.com/v2.0/1234"
internalURL="https://north.compute.internal.com/v2.0/1234">
<version
@ -35,7 +33,6 @@ xmlns="http://docs.openstack.org/identity/api/v2.0">
<service type="object-store" name="HTTP Object Store">
<endpoint
region="North"
tenantId="1234"
publicURL="https://north.object-store.public.com/v1/1234"
internalURL="https://north.object-store.internal.com/v1/1234">
<version
@ -45,7 +42,6 @@ xmlns="http://docs.openstack.org/identity/api/v2.0">
</endpoint>
<endpoint
region="South"
tenantId="1234"
publicURL="https://south.object-store.public.com/v2.0/3456"
internalURL="https://south.object-store.internal.com/v2.0/3456">
<version

View File

@ -7,4 +7,4 @@
}
],
"credentials_links":[]
}
}

View File

@ -2,4 +2,4 @@
<credentials xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://docs.openstack.org/identity/api/v2.0">
<passwordCredentials username="test_user" password="test"/>
</credentials>
</credentials>

View File

@ -0,0 +1,16 @@
{
"credentials":[{
"passwordCredentials":{
"username":"test_user",
"password":"mypass"
}
},
{
"RAX-KSKEY:apikeyCredentials":{
"username":"test_user",
"apikey":"aaaaa-bbbbb-ccccc-12345678"
}
}
],
"credentials_links":[]
}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<credentials xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://docs.openstack.org/identity/api/v2.0">
<passwordCredentials username="test_user" password="test"/>
<apikeyCredentials
xmlns="http://docs.rackspace.com/identity/api/ext/RAX-KSKEY/v1.0"
username="testuser"
apikey="aaaaa-bbbbb-ccccc-12345678"/>
</credentials>

View File

@ -0,0 +1,17 @@
{
"credentials":[{
"passwordCredentials":{
"username":"test_user",
"password":"mypass"
}
},
{
"OS-KSEC2-ec2Credentials":{
"username":"test_user",
"secret":"aaaaa",
"signature":"bbb"
}
}
],
"credentials_links":[]
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<credentials xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://docs.openstack.org/identity/api/v2.0">
<passwordCredentials username="test_user" password="test"/>
<ec2Credentials xmlns="http://docs.openstack.org/identity/api/ext/OS-KSEC2/v1.0"
username="testuser" key="aaaaa" signature="bbbbb"/>
</credentials>

View File

@ -0,0 +1,7 @@
{
"OS-KSEC2-ec2Credentials":{
"username":"test_user",
"secret":"aaaaa",
"signature":"bbb"
}
}

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ec2Credentials
xmlns="http://docs.openstack.org/identity/api/ext/OS-KSEC2/v1.0"
username="testuser"
key="aaaaa"
signature="bbbbb"/>

View File

@ -0,0 +1,16 @@
{
"extension":{
"name": "OpenStack EC2 authentication Extension",
"namespace": "http://docs.openstack.org/identity/api/ext/OS-KSEC2/v1.0",
"alias": "OS-KSEC2-admin",
"updated": "2011-08-25T09:50:00-00:00",
"description": "Adds the capability to support EC2 style authentication.",
"links": [
{
"rel": "describedby",
"type": "application/pdf",
"href": "https://github.com/openstack/keystone/raw/master/keystone/content/service/OS-KSEC2-admin-devguide.pdf"
}
]
}
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension
name="OpenStack EC2 authentication Extension"
namespace="http://docs.openstack.org/identity/api/ext/OS-KSEC2/v1.0"
alias="OS-KSEC2-admin"
updated="2011-08-25T09:50:00-00:00">
<description>
Adds the capability to support EC2 style authentication.
</description>
<atom:link rel="describedby"
type="application/pdf"
href="https://github.com/openstack/keystone/raw/master/keystone/content/service/OS-KSEC2-admin-devguide.pdf"/>
</extension>

View File

@ -0,0 +1,99 @@
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright (c) 2010-2011 OpenStack, LLC.
#
# 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.
"""
RACKSPACE API KEY EXTENSION
This WSGI component
- detects calls with extensions in them.
- processes the necessary components
"""
import os
import json
from lxml import etree
from webob.exc import Request, Response
EXTENSION_ALIAS = "OS-KSEC2-admin"
class FrontEndFilter(object):
"""API Key Middleware that handles authentication with API Key"""
def __init__(self, app, conf):
""" Common initialization code """
print "Starting the %s extension" % EXTENSION_ALIAS
self.conf = conf
self.app = app
def __call__(self, env, start_response):
""" Handle incoming request. Transform. And send downstream. """
request = Request(env)
if request.path == "/extensions":
if env['KEYSTONE_API_VERSION'] == '2.0':
request = Request(env)
response = request.get_response(self.app)
if response.status_int == 200:
if response.content_type == 'application/json':
#load json for this extension from file
thisextension = open(os.path.join(
os.path.dirname(__file__),
"extension.json")).read()
thisextensionjson = json.loads(thisextension)
#load json in response
body = json.loads(response.body)
extensionsarray = body["extensions"]["values"]
#add this extension and return the response
extensionsarray.append(thisextensionjson)
newresp = Response(
content_type='application/json',
body=json.dumps(body))
return newresp(env, start_response)
elif response.content_type == 'application/xml':
#load xml for this extension from file
thisextensionxml = etree.parse(os.path.join(
os.path.dirname(__file__),
"extension.xml")).getroot()
#load xml being returned in response
body = etree.fromstring(response.body)
#add this extension and return the response
body.append(thisextensionxml)
newresp = Response(
content_type='application/xml',
body=etree.tostring(body))
return newresp(env, start_response)
# return the response
return response(env, start_response)
#default action, bypass
return self.app(env, start_response)
def filter_factory(global_conf, **local_conf):
"""Returns a WSGI filter app for use with paste.deploy."""
conf = global_conf.copy()
conf.update(local_conf)
def ext_filter(app):
"""Closure to return"""
return FrontEndFilter(app, conf)
return ext_filter

View File

@ -0,0 +1,14 @@
{
"extension":{
"name": "Rackspace API Key Authentication Admin",
"namespace": "http://docs.rackspace.com/identity/api/ext/RAX-KSKEY/v1.0",
"alias": "RAX-KSKEY-admin",
"updated": "2011-07-13T13:25:27-06:00",
"description": "Rackspace extensions to Keystone v2.0 API enabling API Key authentication.",
"links": [{
"rel": "describedby",
"type": "application/pdf",
"href": "https://github.com/openstack/keystone/raw/master/keystone/content/admin/RAX-KSKEY-service-devguide.pdf"
}]
}
}

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension xmlns="http://docs.openstack.org/common/api/v2.0"
xmlns:atom="http://www.w3.org/2005/Atom"
name="Rackspace API Key authentication" namespace="http://docs.rackspace.com/identity/api/ext/RAX-KSKEY/v1.0"
alias="RAX-KSKEY-admin"
updated="2011-08-14T13:25:27-06:00">
<description>
Rackspace extensions to Keystone v2.0 API
enabling API Key authentication.
</description>
<atom:link rel="describedby" type="application/pdf"
href="https://github.com/openstack/keystone/raw/master/keystone/content/service/RAX-KSKEY-admin-devguide.pdf"/>
</extension>

View File

@ -0,0 +1,99 @@
#!/usr/bin/env python
# vim: tabstop=4 shiftwidth=4 softtabstop=4
#
# Copyright (c) 2010-2011 OpenStack, LLC.
#
# 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.
"""
RACKSPACE API KEY EXTENSION
This WSGI component
- detects calls with extensions in them.
- processes the necessary components
"""
import os
import json
from lxml import etree
from webob.exc import Request, Response
EXTENSION_ALIAS = "RAX-KSKEY-admin"
class FrontEndFilter(object):
"""API Key Middleware that handles authentication with API Key"""
def __init__(self, app, conf):
""" Common initialization code """
print "Starting the %s extension" % EXTENSION_ALIAS
self.conf = conf
self.app = app
def __call__(self, env, start_response):
""" Handle incoming request. Transform. And send downstream. """
request = Request(env)
if request.path == "/extensions":
if env['KEYSTONE_API_VERSION'] == '2.0':
request = Request(env)
response = request.get_response(self.app)
if response.status_int == 200:
if response.content_type == 'application/json':
#load json for this extension from file
thisextension = open(os.path.join(
os.path.dirname(__file__),
"extension.json")).read()
thisextensionjson = json.loads(thisextension)
#load json in response
body = json.loads(response.body)
extensionsarray = body["extensions"]["values"]
#add this extension and return the response
extensionsarray.append(thisextensionjson)
newresp = Response(
content_type='application/json',
body=json.dumps(body))
return newresp(env, start_response)
elif response.content_type == 'application/xml':
#load xml for this extension from file
thisextensionxml = etree.parse(os.path.join(
os.path.dirname(__file__),
"extension.xml")).getroot()
#load xml being returned in response
body = etree.fromstring(response.body)
#add this extension and return the response
body.append(thisextensionxml)
newresp = Response(
content_type='application/xml',
body=etree.tostring(body))
return newresp(env, start_response)
# return the response
return response(env, start_response)
#default action, bypass
return self.app(env, start_response)
def filter_factory(global_conf, **local_conf):
"""Returns a WSGI filter app for use with paste.deploy."""
conf = global_conf.copy()
conf.update(local_conf)
def ext_filter(app):
"""Closure to return"""
return FrontEndFilter(app, conf)
return ext_filter