/
saml.go
30 lines (25 loc) · 813 Bytes
/
saml.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package saml
type ServiceProvider struct {
PublicCertPath string
PrivateKeyPath string
IDPSSOURL string
IDPSSODescriptorURL string
IDPPublicCert string
AssertionConsumerServiceURL string
SPSignRequest bool
publicCert string
privateKey string
}
// GetSignedAuthnRequest returns a singed XML document that represents a AuthnRequest SAML document
func (s *ServiceProvider) GetAuthnRequest() *AuthnRequest {
r := newAuthnRequest()
r.AssertionConsumerServiceURL = s.AssertionConsumerServiceURL
r.Destination = s.IDPSSOURL
r.Issuer.Url = s.IDPSSODescriptorURL
r.Signature.KeyInfo.X509Data.X509Certificate.Cert = loadCertificate(s.IDPPublicCert)
if !s.SPSignRequest {
r.SAMLSIG = ""
r.Signature = nil
}
return r
}