fix speaks for auth
[sfa.git] / sfa / trust / auth.py
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!--\r
3   \r
4   Copyright (c) 2014 Raytheon BBN Technologies\r
5  \r
6   Permission is hereby granted, free of charge, to any person obtaining\r
7   a copy of this software and/or hardware specification (the "Work") to\r
8   deal in the Work without restriction, including without limitation the\r
9   rights to use, copy, modify, merge, publish, distribute, sublicense,\r
10   and/or sell copies of the Work, and to permit persons to whom the Work\r
11   is furnished to do so, subject to the following conditions:\r
12 \r
13   The above copyright notice and this permission notice shall be\r
14   included in all copies or substantial portions of the Work.\r
15  \r
16   THE WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
17   OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
18   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
19   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\r
20   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\r
21   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
22   OUT OF OR IN CONNECTION WITH THE WORK OR THE USE OR OTHER DEALINGS\r
23   IN THE WORK.\r
24 \r
25   Portions have this copyright:\r
26 \r
27   GENIPUBLIC-COPYRIGHT\r
28   Copyright (c) 2008-2009 University of Utah and the Flux Group.\r
29   All rights reserved.\r
30   \r
31 -->\r
32 <!--\r
33   GENI credential and privilege specification. The key points:\r
34   \r
35   * A credential is a set of privileges or a Ticket, each with a flag\r
36     to indicate delegation is permitted. Or an ABAC RT0 statement.\r
37   * A credential is signed and the signature included in the body of the\r
38     document.\r
39   * To support delegation, a credential will include its parent, and that\r
40     blob will be signed. So, there will be multiple signatures in the\r
41     document, each with a reference to the credential it signs.\r
42   \r
43   Default namespace = "http://www.geni.net/resources/credential/2"\r
44 -->\r
45 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns:sig="http://www.w3.org/2000/09/xmldsig#">\r
46   <xs:include schemaLocation="protogeni-rspec-common.xsd"/>\r
47   <xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="sig.xsd"/>\r
48   <xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>\r
49   <xs:group name="anyelementbody">\r
50     <xs:sequence>\r
51       <xs:any minOccurs="0" maxOccurs="unbounded" processContents="skip"/>\r
52     </xs:sequence>\r
53   </xs:group>\r
54   <xs:attributeGroup name="anyelementbody">\r
55     <xs:anyAttribute processContents="skip"/>\r
56   </xs:attributeGroup>\r
57   <!-- This is where we get the definition of RSpec from -->\r
58   <xs:element name="privilege">\r
59     <xs:complexType>\r
60       <xs:sequence>\r
61         <xs:element ref="name"/>\r
62         <xs:element name="can_delegate" type="xs:boolean"/>\r
63       </xs:sequence>\r
64     </xs:complexType>\r
65   </xs:element>\r
66   <xs:element name="name">\r
67     <xs:simpleType>\r
68       <xs:restriction base="xs:string">\r
69         <xs:minLength value="1"/>\r
70       </xs:restriction>\r
71     </xs:simpleType>\r
72   </xs:element>\r
73   <xs:element name="privileges"> <!-- For type 'privilege' only -->\r
74     <xs:complexType>\r
75       <xs:sequence>\r
76         <xs:element minOccurs="0" maxOccurs="unbounded" ref="privilege"/>\r
77       </xs:sequence>\r
78     </xs:complexType>\r
79   </xs:element>\r
80   <xs:element name="capability">\r
81     <xs:complexType>\r
82       <xs:sequence>\r
83         <xs:element ref="name"/>\r
84         <xs:element name="can_delegate">\r
85           <xs:simpleType>\r
86             <xs:restriction base="xs:token">\r
87               <xs:enumeration value="0"/>\r
88               <xs:enumeration value="1"/>\r
89             </xs:restriction>\r
90           </xs:simpleType>\r
91         </xs:element>\r
92       </xs:sequence>\r
93     </xs:complexType>\r
94   </xs:element>\r
95   <xs:element name="capabilities"> <!-- For type 'capability' only -->\r
96     <xs:complexType>\r
97       <xs:sequence>\r
98         <xs:element minOccurs="0" maxOccurs="unbounded" ref="capability"/>\r
99       </xs:sequence>\r
100     </xs:complexType>\r
101   </xs:element>\r
102   <xs:element name="ticket"> <!-- For type 'ticket' only -->\r
103     <xs:complexType mixed="true">\r
104       <xs:sequence>\r
105         <xs:element name="can_delegate" type="xs:boolean">\r
106           <xs:annotation>\r
107             <xs:documentation>Can the ticket be delegated?</xs:documentation>\r
108           </xs:annotation>\r
109         </xs:element>\r
110         <xs:element ref="redeem_before"/>\r
111         <xs:group ref="anyelementbody">\r
112           <xs:annotation>\r
113             <xs:documentation>A desciption of the resources that are being promised</xs:documentation>\r
114           </xs:annotation>\r
115         </xs:group>\r
116       </xs:sequence>\r
117       <xs:attributeGroup ref="anyelementbody"/>\r
118     </xs:complexType>\r
119   </xs:element>\r
120   <xs:element name="redeem_before" type="xs:dateTime">\r
121     <xs:annotation>\r
122       <xs:documentation>The ticket must be "cashed in" by this date </xs:documentation>\r
123     </xs:annotation>\r
124   </xs:element>\r
125 \r
126   <!-- Elements used for type 'abac'. See http://groups.geni.net/geni/wiki/TIEDABACCredential -->\r
127   <xs:element name="ABACprincipal">\r
128     <xs:complexType>\r
129       <xs:sequence>\r
130         <xs:element name="keyid" type="xs:string"/> <!-- SHA1 hash of the principal's public key -->\r
131         <xs:element name="mnemonic" type="xs:string" minOccurs="0" maxOccurs="1"/> <!-- EG principal's URN -->\r
132       </xs:sequence>\r
133     </xs:complexType>\r
134   </xs:element>\r
135   <!-- A single rt0 element is required for creds of type 'abac'. Must have a single 'head'\r
136        and at least one 'tail'. -->\r
137   <xs:element name="rt0">\r
138     <xs:annotation>\r
139       <xs:documentation>An ABAC RT0 statement, used only for type 'abac'.</xs:documentation>\r
140     </xs:annotation>\r
141     <xs:complexType>\r
142       <xs:sequence>\r
143         <xs:element name="version" type="xs:string" /> <!-- 1.1 for this schema -->\r
144         <xs:element name="head">\r
145           <xs:complexType>\r
146             <xs:sequence>\r
147               <xs:element ref="ABACprincipal"/> <!-- Matching the cred signer -->\r
148               <xs:element name="role" type="xs:string"/>\r
149             </xs:sequence>\r
150           </xs:complexType>\r
151         </xs:element>\r
152         <xs:element name="tail" minOccurs="1" maxOccurs="unbounded">\r
153           <xs:complexType>\r
154             <xs:sequence>\r
155               <xs:element ref="ABACprincipal"/>\r
156               <xs:element name="role" type="xs:string" minOccurs="0" maxOccurs="1"/>\r
157               <xs:element name="linking_role" type="xs:string" minOccurs="0" \r
158                           maxOccurs="1"/>\r
159             </xs:sequence>\r
160           </xs:complexType>\r
161         </xs:element>\r
162       </xs:sequence>\r
163     </xs:complexType>\r
164   </xs:element>\r
165   <xs:element name="abac">\r
166     <xs:annotation>\r
167       <xs:documentation>An ABAC assertion containing a single RT0 statement, used only for type 'abac'.</xs:documentation>\r
168     </xs:annotation>\r
169     <xs:complexType>\r
170       <xs:sequence>\r
171         <xs:element minOccurs="1" maxOccurs="1" ref="rt0"/>\r
172       </xs:sequence>\r
173     </xs:complexType>\r
174   </xs:element>\r
175 \r
176   <xs:element name="signatures">\r
177     <xs:complexType>\r
178       <xs:sequence>\r
179         <xs:element maxOccurs="unbounded" ref="sig:Signature"/>\r
180       </xs:sequence>\r
181     </xs:complexType>\r
182   </xs:element>\r
183   <xs:complexType name="credentials">\r
184     <xs:annotation>\r
185       <xs:documentation>A credential granting privileges or a ticket or making an ABAC assertion.</xs:documentation>\r
186     </xs:annotation>\r
187     <xs:sequence>\r
188       <xs:element ref="credential"/>\r
189     </xs:sequence>\r
190   </xs:complexType>\r
191   <xs:element name="credential">\r
192     <xs:complexType>\r
193       <xs:sequence>\r
194         <xs:element ref="type"/>\r
195         <xs:element ref="serial"/>\r
196         <xs:element ref="owner_gid"/>\r
197         <xs:element minOccurs="0" ref="owner_urn"/>\r
198         <xs:element ref="target_gid"/>\r
199         <xs:element minOccurs="0" ref="target_urn"/>\r
200         <xs:element ref="uuid"/>\r
201         <xs:element ref="expires"/>\r
202         <xs:choice>\r
203           <xs:annotation>\r
204             <xs:documentation>Privileges or a ticket or an ABAC assertion</xs:documentation>\r
205           </xs:annotation>\r
206           <xs:element ref="privileges"/>\r
207           <xs:element ref="ticket"/>\r
208           <xs:element ref="capabilities"/>\r
209           <xs:element ref="abac"/>\r
210         </xs:choice>\r
211         <xs:element minOccurs="0" maxOccurs="unbounded" ref="extensions"/>\r
212         <xs:element minOccurs="0" ref="parent"/>\r
213       </xs:sequence>\r
214       <xs:attribute ref="xml:id" use="required"/>\r
215     </xs:complexType>\r
216   </xs:element>\r
217   <xs:element name="type">\r
218     <xs:annotation>\r
219       <xs:documentation>The type of this credential. Currently a Privilege set or a Ticket or ABAC.</xs:documentation>\r
220     </xs:annotation>\r
221     <xs:simpleType>\r
222       <xs:restriction base="xs:token">\r
223         <xs:enumeration value="privilege"/>\r
224         <xs:enumeration value="ticket"/>\r
225         <xs:enumeration value="capability"/>\r
226         <xs:enumeration value="abac"/>\r
227       </xs:restriction>\r
228     </xs:simpleType>\r
229   </xs:element>\r
230   <xs:element name="serial" type="xs:string">\r
231     <xs:annotation>\r
232       <xs:documentation>A serial number.</xs:documentation>\r
233     </xs:annotation>\r
234   </xs:element>\r
235   <xs:element name="owner_gid" type="xs:string">\r
236     <xs:annotation>\r
237       <xs:documentation>GID of the owner of this credential. </xs:documentation>\r
238     </xs:annotation>\r
239   </xs:element>\r
240   <xs:element name="owner_urn" type="xs:string">\r
241     <xs:annotation>\r
242       <xs:documentation>URN of the owner. Not everyone can parse DER</xs:documentation>\r
243     </xs:annotation>\r
244   </xs:element>\r
245   <xs:element name="target_gid" type="xs:string">\r
246     <xs:annotation>\r
247       <xs:documentation>GID of the target of this credential. </xs:documentation>\r
248     </xs:annotation>\r
249   </xs:element>\r
250   <xs:element name="target_urn" type="xs:string">\r
251     <xs:annotation>\r
252       <xs:documentation>URN of the target.</xs:documentation>\r
253     </xs:annotation>\r
254   </xs:element>\r
255   <xs:element name="uuid" type="xs:string">\r
256     <xs:annotation>\r
257       <xs:documentation>UUID of this credential</xs:documentation>\r
258     </xs:annotation>\r
259   </xs:element>\r
260   <xs:element name="expires" type="xs:dateTime">\r
261     <xs:annotation>\r
262       <xs:documentation>Expires on in ISO8601 format but preferably RFC3339</xs:documentation>\r
263     </xs:annotation>\r
264   </xs:element>\r
265   <xs:element name="extensions">\r
266     <xs:annotation>\r
267       <xs:documentation>Optional Extensions</xs:documentation>\r
268     </xs:annotation>\r
269     <xs:complexType mixed="true">\r
270       <xs:group ref="anyelementbody"/>\r
271       <xs:attributeGroup ref="anyelementbody"/>\r
272     </xs:complexType>\r
273   </xs:element>\r
274   <xs:element name="parent" type="credentials">\r
275     <xs:annotation>\r
276       <xs:documentation>Parent that delegated to us</xs:documentation>\r
277     </xs:annotation>\r
278   </xs:element>\r
279   <xs:element name="signed-credential">\r
280     <xs:complexType>\r
281       <xs:complexContent>\r
282         <xs:extension base="credentials">\r
283           <xs:sequence>\r
284             <xs:element minOccurs="0" ref="signatures"/>\r
285           </xs:sequence>\r
286         </xs:extension>\r
287       </xs:complexContent>\r
288     </xs:complexType>\r
289   </xs:element>\r
290 </xs:schema>\r