forked from RobotsAndPencils/go-saml
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtypes.go
350 lines (296 loc) · 10.6 KB
/
types.go
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
package saml
import "encoding/xml"
type AuthnRequest struct {
XMLName xml.Name
SAMLP string `xml:"xmlns:samlp,attr"`
SAML string `xml:"xmlns:saml,attr"`
SAMLSIG string `xml:"xmlns:samlsig,attr,omitempty"`
ID string `xml:"ID,attr"`
Version string `xml:"Version,attr"`
ProtocolBinding string `xml:"ProtocolBinding,attr,omitempty"`
AssertionConsumerServiceURL string `xml:"AssertionConsumerServiceURL,attr"`
IssueInstant string `xml:"IssueInstant,attr"`
Destination string `xml:"Destination,attr,omitempty"`
AssertionConsumerServiceIndex int `xml:"AssertionConsumerServiceIndex,attr,omitempty"`
AttributeConsumingServiceIndex int `xml:"AttributeConsumingServiceIndex,attr,omitempty"`
ForceAuthn string `xml:"ForceAuthn,attr,omitempty"`
Issuer Issuer `xml:"Issuer"`
Signature []Signature `xml:"Signature,omitempty"`
NameIDPolicy *NameIDPolicy `xml:"NameIDPolicy,omitempty"`
RequestedAuthnContext *RequestedAuthnContext `xml:"RequestedAuthnContext,omitempty"`
originalString string
}
type Issuer struct {
XMLName xml.Name
SAML string `xml:"xmlns:saml,attr,omitempty"`
Url string `xml:",innerxml"`
}
type NameIDPolicy struct {
XMLName xml.Name
AllowCreate bool `xml:"AllowCreate,attr,omitempty"`
Format string `xml:"Format,attr"`
}
type RequestedAuthnContext struct {
XMLName xml.Name
SAMLP string `xml:"xmlns:samlp,attr,omitempty"`
Comparison string `xml:"Comparison,attr"`
AuthnContextClassRef AuthnContextClassRef `xml:"AuthnContextClassRef"`
}
type AuthnContextClassRef struct {
XMLName xml.Name
SAML string `xml:"xmlns:saml,attr,omitempty"`
Transport string `xml:",innerxml"`
}
type Signature struct {
XMLName xml.Name
Id string `xml:"Id,attr"`
SignedInfo SignedInfo
SignatureValue SignatureValue
KeyInfo KeyInfo
}
type SignedInfo struct {
XMLName xml.Name
CanonicalizationMethod CanonicalizationMethod `xml:"CanonicalizationMethod"`
SignatureMethod SignatureMethod `xml:"SignatureMethod"`
SamlsigReference SamlsigReference `xml:"Reference"`
}
type SignatureValue struct {
XMLName xml.Name
Value string `xml:",innerxml"`
}
type KeyInfo struct {
XMLName xml.Name
X509Data X509Data `xml:"X509Data"`
}
type CanonicalizationMethod struct {
XMLName xml.Name
Algorithm string `xml:"Algorithm,attr"`
}
type SignatureMethod struct {
XMLName xml.Name
Algorithm string `xml:"Algorithm,attr"`
}
type SamlsigReference struct {
XMLName xml.Name
URI string `xml:"URI,attr"`
Transforms Transforms `xml:",innerxml"`
DigestMethod DigestMethod `xml:",innerxml"`
DigestValue DigestValue `xml:",innerxml"`
}
type X509Data struct {
XMLName xml.Name
X509Certificate X509Certificate `xml:"X509Certificate"`
}
type Transforms struct {
XMLName xml.Name
Transforms []Transform
}
type DigestMethod struct {
XMLName xml.Name
Algorithm string `xml:"Algorithm,attr"`
}
type DigestValue struct {
XMLName xml.Name
}
type X509Certificate struct {
XMLName xml.Name
Cert string `xml:",innerxml"`
}
type Transform struct {
XMLName xml.Name
Algorithm string `xml:"Algorithm,attr"`
}
type EntityDescriptor struct {
XMLName xml.Name
DS string `xml:"xmlns:ds,attr"`
XMLNS string `xml:"xmlns,attr"`
MD string `xml:"xmlns:md,attr"`
EntityId string `xml:"entityID,attr"`
Extensions Extensions `xml:"Extensions"`
SPSSODescriptor SPSSODescriptor `xml:"SPSSODescriptor"`
}
type Extensions struct {
XMLName xml.Name
Alg string `xml:"xmlns:alg,attr"`
MDAttr string `xml:"xmlns:mdattr,attr"`
MDRPI string `xml:"xmlns:mdrpi,attr"`
EntityAttributes string `xml:"EntityAttributes"`
}
type SSODescriptor struct {
//ArtifactResolutionServices []ArtifactResolutionServices `xml:"ArtifactResolutionService"`
SingleLogoutService []SingleLogoutService `xml:"SingleLogoutService"`
//NameIDFormats []NameIdFormat `xml:"NameIDFormat"`
}
type SPSSODescriptor struct {
XMLName xml.Name
ProtocolSupportEnumeration string `xml:"protocolSupportEnumeration,attr"`
SSODescriptor
SigningKeyDescriptor KeyDescriptor
EncryptionKeyDescriptor KeyDescriptor
// SingleLogoutService SingleLogoutService `xml:"SingleLogoutService"`
AssertionConsumerServices []AssertionConsumerService
}
type IDPSSODescriptor struct {
XMLName xml.Name
ProtocolSupportEnumeration string `xml:"protocolSupportEnumeration,attr"`
SSODescriptor
KeyDescriptors []KeyDescriptor
SingleSignOnService []SingleSignOnService `xml:"SingleSignOnService"`
Attributes []Attribute
}
type EntityAttributes struct {
XMLName xml.Name
SAML string `xml:"xmlns:saml,attr"`
EntityAttributes []Attribute `xml:"Attribute"` // should be array??
}
type KeyDescriptor struct {
XMLName xml.Name
Use string `xml:"use,attr"`
KeyInfo KeyInfo `xml:"KeyInfo"`
}
type SingleLogoutService struct {
Binding string `xml:"Binding,attr"`
Location string `xml:"Location,attr"`
}
type SingleSignOnService struct {
Binding string `xml:"Binding,attr"`
Location string `xml:"Location,attr"`
}
type AssertionConsumerService struct {
XMLName xml.Name
Binding string `xml:"Binding,attr"`
Location string `xml:"Location,attr"`
Index string `xml:"index,attr"`
}
type Response struct {
XMLName xml.Name
SAMLP string `xml:"xmlns:samlp,attr"`
SAML string `xml:"xmlns:saml,attr"`
SAMLSIG string `xml:"xmlns:samlsig,attr"`
Destination string `xml:"Destination,attr"`
ID string `xml:"ID,attr"`
Version string `xml:"Version,attr"`
IssueInstant string `xml:"IssueInstant,attr"`
InResponseTo string `xml:"InResponseTo,attr"`
Assertion Assertion `xml:"Assertion"`
EncryptedAssertion EncryptedAssertion `xml:"EncryptedAssertion"`
Signature Signature `xml:"Signature"`
Issuer Issuer `xml:"Issuer"`
Status Status `xml:"Status"`
originalString string
}
type EncryptedData struct {
XMLName xml.Name
Type string `xml:"Type,attr"`
}
type EncryptedAssertion struct {
XMLName xml.Name
EncryptedData *EncryptedData `xml:"EncryptedData"`
// "Assertion" nodes are not valid here according to the SAML assertion schema, but they are implied by the
// XMLEnc standard as an intermediate form, and therefore in the files that 'xmlsec1 --decrypt' returns.
Assertion *Assertion `xml:"Assertion"`
}
type Assertion struct {
XMLName xml.Name
ID string `xml:"ID,attr"`
Version string `xml:"Version,attr"`
XS string `xml:"xmlns:xs,attr"`
XSI string `xml:"xmlns:xsi,attr"`
SAML string `xml:"saml,attr"`
IssueInstant string `xml:"IssueInstant,attr"`
Issuer Issuer `xml:"Issuer"`
Signature Signature `xml:"Signature"`
Subject Subject
Conditions Conditions
AttributeStatement AttributeStatement
AuthnStatement AuthnStatement
}
type AuthnStatement struct {
SessionIndex string `xml:"SessionIndex,attr"`
}
type Conditions struct {
XMLName xml.Name
NotBefore string `xml:",attr"`
NotOnOrAfter string `xml:",attr"`
}
type Subject struct {
XMLName xml.Name
NameID NameID
SubjectConfirmation SubjectConfirmation
}
type SubjectConfirmation struct {
XMLName xml.Name
Method string `xml:",attr"`
SubjectConfirmationData SubjectConfirmationData
}
type Status struct {
XMLName xml.Name
StatusCode StatusCode `xml:"StatusCode"`
}
type SubjectConfirmationData struct {
InResponseTo string `xml:",attr"`
NotOnOrAfter string `xml:",attr"`
Recipient string `xml:",attr"`
}
type NameID struct {
XMLName xml.Name
Format string `xml:",attr,omitempty"`
Value string `xml:",innerxml"`
}
type StatusCode struct {
XMLName xml.Name
Value string `xml:",attr"`
}
type AttributeValue struct {
XMLName xml.Name
Type string `xml:"xsi:type,attr"`
Value string `xml:",innerxml"`
}
type Attribute struct {
XMLName xml.Name
Name string `xml:",attr"`
FriendlyName string `xml:",attr"`
NameFormat string `xml:",attr"`
AttributeValue AttributeValue
}
type AttributeStatement struct {
XMLName xml.Name
Attributes []Attribute `xml:"Attribute"`
}
type LogoutRequest struct {
XMLName xml.Name
SAMLP string `xml:"xmlns:samlp,attr"`
SAML string `xml:"xmlns:saml,attr"`
SAMLSIG string `xml:"xmlns:samlsig,attr,omitempty"`
ID string `xml:"ID,attr"`
Version string `xml:"Version,attr"`
IssueInstant string `xml:"IssueInstant,attr"`
Destination string `xml:"Destination,attr,omitempty"`
Issuer Issuer `xml:"Issuer"`
Signature *Signature `xml:"Signature,omitempty"`
NameID NameID `xml:"NameID"`
SessionIndex []SessionIndex `xml:"SessionIndex"`
}
type SessionIndex struct {
XMLName xml.Name
Value string `xml:",innerxml"`
}
type RoleDescriptor struct {
ValidUntil string `xml:"validUntil,attr,omitempty"`
CacheDuration string `xml:"cacheDuration,attr,omitempty"`
ProtocolSupportEnumeration string `xml:"protocolSupportEnumeration,attr"`
Signature *Signature `xml:"Signature,omitempty"`
KeyDescriptors []KeyDescriptor `xml:"KeyDescriptor,omitempty"`
}
type Metadata struct {
XMLName xml.Name // urn:oasis:names:tc:SAML:2.0:metadata:EntityDescriptor
ID string `xml:"ID,attr,omitempty"`
EntityId string `xml:"entityID,attr"`
ValidUntil string `xml:"validUntil,attr,omitempty"`
CacheDuration string `xml:"cacheDuration,attr,omitempty"`
Signature *Signature `xml:"Signature,omitempty"`
// note: the schema permits these elements to appear in any order an unlimited number of times
RoleDescriptor []RoleDescriptor `xml:"RoleDescriptor,omitempty"`
SPSSODescriptor *SPSSODescriptor `xml:"SPSSODescriptor,omitempty"`
IDPSSODescriptor *IDPSSODescriptor `xml:"IDPSSODescriptor,omitempty"`
}