@@ -78,6 +78,13 @@ func (sp *SAMLServiceProvider) buildAuthnRequest(includeSig bool) (*etree.Docume
7878 }
7979 }
8080
81+ for _ , processor := range sp .AuthNRequestProcessors {
82+ err := processor .Process (authnRequest )
83+ if err != nil {
84+ return nil , err
85+ }
86+ }
87+
8188 doc := etree .NewDocument ()
8289
8390 // Only POST binding includes <Signature> in <AuthnRequest> (includeSig)
@@ -254,7 +261,7 @@ func (sp *SAMLServiceProvider) buildAuthBodyPostFromDocument(relayState string,
254261 return rv .Bytes (), nil
255262}
256263
257- //BuildAuthBodyPost builds the POST body to be sent to IDP.
264+ // BuildAuthBodyPost builds the POST body to be sent to IDP.
258265func (sp * SAMLServiceProvider ) BuildAuthBodyPost (relayState string ) ([]byte , error ) {
259266 var doc * etree.Document
260267 var err error
@@ -272,8 +279,8 @@ func (sp *SAMLServiceProvider) BuildAuthBodyPost(relayState string) ([]byte, err
272279 return sp .buildAuthBodyPostFromDocument (relayState , doc )
273280}
274281
275- //BuildAuthBodyPostFromDocument builds the POST body to be sent to IDP.
276- //It takes the AuthnRequest xml as input.
282+ // BuildAuthBodyPostFromDocument builds the POST body to be sent to IDP.
283+ // It takes the AuthnRequest xml as input.
277284func (sp * SAMLServiceProvider ) BuildAuthBodyPostFromDocument (relayState string , doc * etree.Document ) ([]byte , error ) {
278285 return sp .buildAuthBodyPostFromDocument (relayState , doc )
279286}
@@ -382,8 +389,8 @@ func (sp *SAMLServiceProvider) BuildLogoutRequestDocument(nameID string, session
382389 return sp .buildLogoutRequest (true , nameID , sessionIndex )
383390}
384391
385- //BuildLogoutBodyPostFromDocument builds the POST body to be sent to IDP.
386- //It takes the LogoutRequest xml as input.
392+ // BuildLogoutBodyPostFromDocument builds the POST body to be sent to IDP.
393+ // It takes the LogoutRequest xml as input.
387394func (sp * SAMLServiceProvider ) BuildLogoutBodyPostFromDocument (relayState string , doc * etree.Document ) ([]byte , error ) {
388395 return sp .buildLogoutBodyPostFromDocument (relayState , doc )
389396}
@@ -555,3 +562,16 @@ func signatureInputString(samlRequest, relayState, sigAlg string) string {
555562 }
556563 return buf .String ()
557564}
565+
566+ type AddIdpScoping struct {
567+ ProviderId string
568+ Name string
569+ }
570+
571+ func (a * AddIdpScoping ) Process (doc * etree.Element ) error {
572+ idpList := doc .CreateElement ("samlp:Scoping" ).CreateElement ("samlp:IDPList" )
573+ idpEntry := idpList .CreateElement ("samlp:IDPEntry" )
574+ idpEntry .CreateAttr ("ProviderID" , a .ProviderId )
575+ idpEntry .CreateAttr ("Name" , a .Name )
576+ return nil
577+ }
0 commit comments