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

Method SignAttributeQuery

service_provider_attribute_query.go:149–170  ·  view source on GitHub ↗

SignAttributeQuery adds an enveloped `Signature` element to the `AttributeQuery`, replacing any it already has. It signs with SignatureMethod or, when that is empty, with SHA-256 for the type of Key.

(req *AttributeQuery)

Source from the content-addressed store, hash-verified

147// `AttributeQuery`, replacing any it already has. It signs with
148// SignatureMethod or, when that is empty, with SHA-256 for the type of Key.
149func (sp *ServiceProvider) SignAttributeQuery(req *AttributeQuery) error {
150 signatureMethod := sp.SignatureMethod
151 if signatureMethod == "" && !signerutil.IsNil(sp.Key) {
152 signatureMethod = defaultSignatureMethod(sp.Key.Public())
153 }
154 signingContext, err := sp.signingContext(signatureMethod)
155 if err != nil {
156 return err
157 }
158
159 req.Signature = nil
160 signedRequestEl, err := signingContext.SignEnveloped(req.Element())
161 if err != nil {
162 return err
163 }
164 sigEl, ok := signedRequestEl.Child[len(signedRequestEl.Child)-1].(*etree.Element)
165 if !ok {
166 return errors.New("cannot sign attribute query: no Signature element")
167 }
168 req.Signature = sigEl
169 return nil
170}
171
172// QueryAttributes asks the IdP's attribute authority for the attributes of
173// the subject identified by nameID, and returns them once the response has

Callers 2

MakeAttributeQueryMethod · 0.95

Calls 6

signingContextMethod · 0.95
IsNilFunction · 0.92
defaultSignatureMethodFunction · 0.85
NewMethod · 0.65
PublicMethod · 0.45
ElementMethod · 0.45

Tested by 1