simpleSignForm returns an auto-submitting HTML form that sends el to destination with the HTTP-POST-SimpleSign binding, in the messageParam (SAMLRequest or SAMLResponse) control, signed with the SP's key and SignatureMethod. el is sent as is: an XML signature it carries is kept, but none is added.
(destination, messageParam string, el *etree.Element, relayState, nonce, signatureMethod string)
| 341 | // SignatureMethod. el is sent as is: an XML signature it carries is kept, |
| 342 | // but none is added. |
| 343 | func (sp *ServiceProvider) simpleSignForm(destination, messageParam string, el *etree.Element, relayState, nonce, signatureMethod string) ([]byte, error) { |
| 344 | signingContext, err := sp.simpleSignSigningContext(signatureMethod) |
| 345 | if err != nil { |
| 346 | return nil, err |
| 347 | } |
| 348 | |
| 349 | doc := etree.NewDocument() |
| 350 | doc.SetRoot(el) |
| 351 | message, err := doc.WriteToBytes() |
| 352 | if err != nil { |
| 353 | return nil, err |
| 354 | } |
| 355 | |
| 356 | sigAlg, signature, err := signSimpleSign(signingContext, messageParam, message, relayState) |
| 357 | if err != nil { |
| 358 | return nil, err |
| 359 | } |
| 360 | |
| 361 | tmpl := simpleSignRequestFormTemplate |
| 362 | if messageParam == redirectParamSAMLResponse { |
| 363 | tmpl = simpleSignResponseFormTemplate |
| 364 | } |
| 365 | var rv bytes.Buffer |
| 366 | if err := tmpl.Execute(&rv, simpleSignFormData{ |
| 367 | URL: destination, |
| 368 | Message: base64.StdEncoding.EncodeToString(message), |
| 369 | RelayState: relayState, |
| 370 | SigAlg: sigAlg, |
| 371 | Signature: signature, |
| 372 | Nonce: nonce, |
| 373 | }); err != nil { |
| 374 | return nil, err |
| 375 | } |
| 376 | return rv.Bytes(), nil |
| 377 | } |
| 378 | |
| 379 | // MakeSimpleSignAuthenticationRequest creates a SAML authentication request |
| 380 | // for the IDP's HTTP-POST-SimpleSign single sign-on endpoint. It returns an |
no test coverage detected