@@ -48,7 +48,7 @@ type AuthnRequest struct {
4848 NameIDPolicy * NameIDPolicy `xml:"urn:oasis:names:tc:SAML:2.0:protocol NameIDPolicy"`
4949 Conditions * Conditions
5050 RequestedAuthnContext * RequestedAuthnContext
51- // Scoping *Scoping // TODO
51+ Scoping * Scoping
5252
5353 ForceAuthn * bool `xml:",attr"`
5454 IsPassive * bool `xml:",attr"`
@@ -209,9 +209,9 @@ func (r *AuthnRequest) Element() *etree.Element {
209209 if r .RequestedAuthnContext != nil {
210210 el .AddChild (r .RequestedAuthnContext .Element ())
211211 }
212- // if r.Scoping != nil {
213- // el.AddChild(r.Scoping.Element())
214- // }
212+ if r .Scoping != nil {
213+ el .AddChild (r .Scoping .Element ())
214+ }
215215 if r .ForceAuthn != nil {
216216 el .CreateAttr ("ForceAuthn" , strconv .FormatBool (* r .ForceAuthn ))
217217 }
@@ -321,6 +321,41 @@ func (a *NameIDPolicy) Element() *etree.Element {
321321 return el
322322}
323323
324+ // Scoping represents the SAML object of the same name.
325+ //
326+ // See http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf § 3.4.1.2
327+ type Scoping struct {
328+ XMLName xml.Name `xml:"urn:oasis:names:tc:SAML:2.0:protocol Scoping"`
329+ ProxyCount * int `xml:",attr"`
330+ IDPList []string `xml:"urn:oasis:names:tc:SAML:2.0:protocol IDPList"` // Only supports IDEntry, TODO support GetComplete{uri}
331+ RequesterIDs []string `xml:"urn:oasis:names:tc:SAML:2.0:protocol RequesterID"`
332+ }
333+
334+ // Element returns an etree.Element representing the object in XML form.
335+ func (a * Scoping ) Element () * etree.Element {
336+ el := etree .NewElement ("samlp:Scoping" )
337+ if a .ProxyCount != nil {
338+ el .CreateAttr ("ProxyCount" , strconv .Itoa (* a .ProxyCount ))
339+ }
340+ if len (a .IDPList ) > 0 {
341+ idpList := etree .NewElement ("samlp:IDPList" )
342+ for _ , idp := range a .IDPList {
343+ idpEntry := etree .NewElement ("samlp:IDPEntry" )
344+ idpEntry .CreateAttr ("ProviderID" , idp )
345+ idpList .AddChild (idpEntry )
346+ }
347+ el .AddChild (idpList )
348+ }
349+ if len (a .RequesterIDs ) > 0 {
350+ for _ , requesterID := range a .RequesterIDs {
351+ requesterIDEntry := etree .NewElement ("samlp:RequesterIDEntry" )
352+ requesterIDEntry .CreateAttr ("ProviderID" , requesterID )
353+ el .AddChild (requesterIDEntry )
354+ }
355+ }
356+ return el
357+ }
358+
324359// ArtifactResolve represents the SAML object of the same name.
325360type ArtifactResolve struct {
326361 XMLName xml.Name `xml:"urn:oasis:names:tc:SAML:2.0:protocol ArtifactResolve"`
0 commit comments