MCPcopy Create free account
hub / github.com/crewjam/saml / simpleSignForm

Method simpleSignForm

simplesign_binding.go:343–377  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

341// SignatureMethod. el is sent as is: an XML signature it carries is kept,
342// but none is added.
343func (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

Callers 3

SimpleSignWithNonceMethod · 0.80
SimpleSignWithNonceMethod · 0.80
SimpleSignWithNonceMethod · 0.80

Calls 3

signSimpleSignFunction · 0.85
BytesMethod · 0.80

Tested by

no test coverage detected