Documentation
¶
Index ¶
- Variables
- func SignXML(xml []byte, sp *SP) ([]byte, error)
- type Attribute
- type AttributeConsumingService
- type AuthnRequest
- type ConfigAttributeConsumingService
- type ConfigFile
- type ConfigServiceDetails
- type ContactPerson
- type IDP
- type LogoutRequestIn
- func (msg *LogoutRequestIn) Destination() string
- func (msg *LogoutRequestIn) ID() string
- func (msg *LogoutRequestIn) InResponseTo() string
- func (msg *LogoutRequestIn) Issuer() string
- func (logoutreq *LogoutRequestIn) SessionIndex() string
- func (msg *LogoutRequestIn) SetXML(xml []byte) error
- func (logoutreq *LogoutRequestIn) Validate(r *http.Request) error
- type LogoutRequestOut
- type LogoutResponseIn
- func (msg *LogoutResponseIn) Destination() string
- func (msg *LogoutResponseIn) ID() string
- func (msg *LogoutResponseIn) InResponseTo() string
- func (msg *LogoutResponseIn) Issuer() string
- func (msg *LogoutResponseIn) SetXML(xml []byte) error
- func (logoutres *LogoutResponseIn) Validate(r *http.Request, inResponseTo string) error
- type LogoutResponseOut
- type LogoutStatus
- type Organization
- type Response
- func (response *Response) AssertionAudience() string
- func (response *Response) AssertionInResponseTo() string
- func (response *Response) AssertionIssuer() string
- func (response *Response) AssertionRecipient() string
- func (response *Response) Attributes() map[string]string
- func (msg *Response) Destination() string
- func (msg *Response) ID() string
- func (msg *Response) InResponseTo() string
- func (msg *Response) Issuer() string
- func (response *Response) Level() int
- func (response *Response) NameID() string
- func (response *Response) NotBefore() (time.Time, error)
- func (response *Response) NotOnOrAfter() (time.Time, error)
- func (response *Response) Session() *Session
- func (response *Response) SessionIndex() string
- func (msg *Response) SetXML(xml []byte) error
- func (response *Response) StatusCode() string
- func (response *Response) StatusCode2() string
- func (response *Response) StatusMessage() string
- func (response *Response) SubjectConfirmationDataNotOnOrAfter() (time.Time, error)
- func (response *Response) Success() bool
- func (response *Response) Validate(inResponseTo string) error
- type SAMLBinding
- type SP
- func (sp *SP) GetCert() *x509.Certificate
- func (sp *SP) GetCertPEM() []byte
- func (sp *SP) GetIDP(entityID string) (*IDP, error)
- func (sp *SP) GetKey() *rsa.PrivateKey
- func (sp *SP) GetKeyPEM() []byte
- func (sp *SP) GetSigningContext() *dsig.SigningContext
- func (sp *SP) LoadIDPMetadata(dir string) error
- func (sp *SP) LoadIDPsFromXMLFile(path string) error
- func (sp *SP) Metadata() string
- func (sp *SP) NewAuthnRequest(idp *IDP) *AuthnRequest
- func (sp *SP) NewLogoutRequest(session *Session) (*LogoutRequestOut, error)
- func (sp *SP) NewLogoutResponse(logoutreq *LogoutRequestIn, status LogoutStatus) (*LogoutResponseOut, error)
- func (sp *SP) ParseLogoutRequest(r *http.Request) (*LogoutRequestIn, error)
- func (sp *SP) ParseLogoutResponse(r *http.Request) (*LogoutResponseIn, error)
- type ServiceName
- type Session
Constants ¶
This section is empty.
Variables ¶
var AttributeMap = map[string]string{
"displayName": "urn:oid:2.16.840.1.113730.3.1.241",
"givenName": "urn:oid:2.5.4.42",
"surname": "urn:oid:2.5.4.4",
"cn": "urn:oid:2.5.4.3",
"sn": "urn:oid:2.5.4.4",
"uid": "urn:oid:0.9.2342.19200300.100.1.1",
"mail": "urn:oid:0.9.2342.19200300.100.1.3",
"schacPersonalUniqueCode": "urn:oid:1.3.6.1.4.1.25178.1.2.14",
"schacHomeOrganization": "urn:oid:1.3.6.1.4.1.25178.1.2.9",
"eduPersonOrcid": "urn:oid:1.3.6.1.4.1.5923.1.1.1.16",
"eduPersonUniqueId": "urn:oid:1.3.6.1.4.1.5923.1.1.1.13",
"eduPersonAssurance": "urn:oid:1.3.6.1.4.1.5923.1.1.1.11",
"eduPersonTargetedID": "urn:oid:1.3.6.1.4.1.5923.1.1.1.10",
"eduPersonScopedAffiliation": "urn:oid:1.3.6.1.4.1.5923.1.1.1.9",
"eduPersonEntitlement": "urn:oid:1.3.6.1.4.1.5923.1.1.1.7",
"eduPersonPrincipalName": "urn:oid:1.3.6.1.4.1.5923.1.1.1.6",
"eduPersonAffiliation": "urn:oid:1.3.6.1.4.1.5923.1.1.1.1",
}
Functions ¶
Types ¶
type AttributeConsumingService ¶
type AttributeConsumingService struct {
ServiceNames []ServiceName
Attributes []Attribute
}
AttributeConsumingService defines, well, an AttributeConsumingService.
type AuthnRequest ¶
type AuthnRequest struct {
AcsURL string
AcsIndex int
AttrIndex int
Level int
Comparison string
// contains filtered or unexported fields
}
AuthnRequest defines an outgoing SPID/SAML AuthnRequest. Do not instantiate it directly but use sp.NewAuthnRequest() instead.
func (*AuthnRequest) IssueInstant ¶
func (*AuthnRequest) IssueInstantString ¶
func (msg *AuthnRequest) IssueInstantString() string
func (*AuthnRequest) PostForm ¶
func (authnreq *AuthnRequest) PostForm() []byte
PostForm returns an HTML page with a JavaScript auto-post command that submits the request to the Identity Provider in order to initiate their Single Sign-On. In SAML words, this implements the HTTP-POST binding.
func (*AuthnRequest) RedirectURL ¶
func (authnreq *AuthnRequest) RedirectURL() string
RedirectURL returns the full URL of the Identity Provider where user should be redirected in order to initiate their Single Sign-On. In SAML words, this implements the HTTP-Redirect binding.
func (*AuthnRequest) XML ¶
func (authnreq *AuthnRequest) XML(binding SAMLBinding) []byte
XML generates the XML representation of this AuthnRequest
type ConfigAttributeConsumingService ¶ added in v1.0.5
type ConfigAttributeConsumingService struct {
Details ConfigServiceDetails `toml:"Details"`
}
type ConfigFile ¶ added in v1.0.5
type ConfigFile struct {
IDPEntityID string `toml:"IDPEntityID"`
IDPdepo string `toml:"IDPdepo"`
EntityID string `toml:"EntityID"`
KeyFile string `toml:"KeyFile"`
CertFile string `toml:"CertFile"`
AcsUrls []string `toml:"AcsUrls"`
SlsUrls []string `toml:"SlsUrls"`
AttributeConsumingServices []ConfigAttributeConsumingService `toml:"AttributeConsumingServices"`
}
type ConfigServiceDetails ¶ added in v1.0.5
type ConfigServiceDetails struct {
ServiceNames []ServiceName `toml:"ServiceNames"`
Attributes []string `toml:"Attributes"`
}
type ContactPerson ¶
type IDP ¶
type IDP struct {
XML string
EntityID string
Certs []*x509.Certificate
SSOURLs map[SAMLBinding]string
SLOReqURLs map[SAMLBinding]string
SLOResURLs map[SAMLBinding]string
}
IDP represents an Identity Provider.
func ParseIDPsFromXML ¶
ParseIDPsFromXML takes XML metadata and returns an IDP object.
type LogoutRequestIn ¶
type LogoutRequestIn struct {
// contains filtered or unexported fields
}
LogoutRequestIn represents an incoming LogoutRequest. You can use this to parse a logout request in case the user initiated a logout procedure elsewhere and an Identity Provider is requesting logout to you. You are not supposed to instantiate this directly; use ParseLogoutRequest() instead.
func (*LogoutRequestIn) Destination ¶
func (msg *LogoutRequestIn) Destination() string
Destination returns the value of the <Destination> element.
func (*LogoutRequestIn) InResponseTo ¶
func (msg *LogoutRequestIn) InResponseTo() string
InResponseTo returns the value of the <InResponseTo> element.
func (*LogoutRequestIn) Issuer ¶
func (msg *LogoutRequestIn) Issuer() string
Issuer returns the value of the <Issuer> element.
func (*LogoutRequestIn) SessionIndex ¶
func (logoutreq *LogoutRequestIn) SessionIndex() string
SessionIndex returns the value of the <SessionIndex> element.
type LogoutRequestOut ¶
type LogoutRequestOut struct {
Session *Session
// contains filtered or unexported fields
}
LogoutRequestOut defines an outgoing SPID/SAML LogoutRequest. You can use it to generate such a request in case you're initiating a logout procedure on behalf of your user. Do not instantiate it directly but use sp.NewLogoutRequest() instead.
func (*LogoutRequestOut) IssueInstant ¶
func (*LogoutRequestOut) IssueInstantString ¶
func (msg *LogoutRequestOut) IssueInstantString() string
func (*LogoutRequestOut) PostForm ¶
func (logoutreq *LogoutRequestOut) PostForm() []byte
PostForm returns an HTML page with a JavaScript auto-post command that submits the request to the Identity Provider in order to initiate their Single Logout. In SAML words, this implements the HTTP-POST binding.
func (*LogoutRequestOut) RedirectURL ¶
func (logoutreq *LogoutRequestOut) RedirectURL() string
RedirectURL returns the full URL of the Identity Provider where user should be redirected in order to initiate their Single Logout. In SAML words, this implements the HTTP-Redirect binding.
func (*LogoutRequestOut) XML ¶
func (logoutreq *LogoutRequestOut) XML(binding SAMLBinding) []byte
XML generates the XML representation of this LogoutRequest
type LogoutResponseIn ¶
type LogoutResponseIn struct {
// contains filtered or unexported fields
}
LogoutResponseIn represents an incoming LogoutResponse. You can use this to parse the response coming from the Identity Provider after you sent a LogoutRequest for a SP-initiated logout. You are not supposed to instantiate this directly; use ParseLogoutResponse() instead.
func (*LogoutResponseIn) Destination ¶
func (msg *LogoutResponseIn) Destination() string
Destination returns the value of the <Destination> element.
func (*LogoutResponseIn) InResponseTo ¶
func (msg *LogoutResponseIn) InResponseTo() string
InResponseTo returns the value of the <InResponseTo> element.
type LogoutResponseOut ¶
type LogoutResponseOut struct {
InResponseTo string
// contains filtered or unexported fields
}
LogoutResponseOut defines an outgoing SPID/SAML LogoutResponse. You need to craft such a response in case you received a LogoutRequest from the Identity Provider, thus during an IdP-initiated logout. Do not instantiate it directly but use sp.NewLogoutResponse() instead.
func (*LogoutResponseOut) IssueInstant ¶
func (*LogoutResponseOut) IssueInstantString ¶
func (msg *LogoutResponseOut) IssueInstantString() string
func (*LogoutResponseOut) PostForm ¶
func (logoutres *LogoutResponseOut) PostForm() []byte
PostForm returns an HTML page with a JavaScript auto-post command that submits the request to the Identity Provider in order to complete their Single Logout. In SAML words, this implements the HTTP-POST binding.
func (*LogoutResponseOut) RedirectURL ¶
func (logoutres *LogoutResponseOut) RedirectURL() string
RedirectURL returns the full URL of the Identity Provider where user should be redirected in order to continue their Single Logout. In SAML words, this implements the HTTP-Redirect binding.
func (*LogoutResponseOut) XML ¶
func (logoutres *LogoutResponseOut) XML(binding SAMLBinding) []byte
XML generates the XML representation of this LogoutResponseOut
type LogoutStatus ¶
type LogoutStatus string
LogoutStatus represent the possible result statuses of Single Logout.
const ( SuccessLogout LogoutStatus = "success" PartialLogout LogoutStatus = "partial" )
LogoutStatus represent the possible result statuses of Single Logout.
type Organization ¶
Organization defines SP Organization data
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response represents an incoming SPID Response/Assertion message. We get such messages after an AuthnRequest (Single Sign-On).
func ParseResponse ¶
ParseResponse parses a Response/Assertion. Validation is performed (see the documentation for the Response::validate() method), so this method may return an error.
func (*Response) AssertionAudience ¶
AssertionAudience returns the value of the <Assertion><Audience> element.
func (*Response) AssertionInResponseTo ¶
AssertionInResponseTo returns the value of the <Assertion> InResponseTo attribute.
func (*Response) AssertionIssuer ¶
AssertionIssuer returns the value of the <Assertion><Issuer> element.
func (*Response) AssertionRecipient ¶
AssertionRecipient returns the value of the <Assertion> Recipient attribute.
func (*Response) Attributes ¶
Attributes returns the attributes carried by the assertion.
func (*Response) Destination ¶
func (msg *Response) Destination() string
Destination returns the value of the <Destination> element.
func (*Response) InResponseTo ¶
func (msg *Response) InResponseTo() string
InResponseTo returns the value of the <InResponseTo> element.
func (*Response) Issuer ¶
func (msg *Response) Issuer() string
Issuer returns the value of the <Issuer> element.
func (*Response) NotOnOrAfter ¶
NotOnOrAfter returns the value of the <Assertion> NotOnOrAfter attribute.
func (*Response) Session ¶
Session returns a Session object populated with useful information from this Response/Assertion. You might want to store this object along with the user session of your application, so that you can use it for generating the LoginRequest
func (*Response) SessionIndex ¶
SessionIndex returns the value of the SessionIndex attribute.
func (*Response) StatusCode ¶
StatusCode returns the value of the <StatusCode> element.
func (*Response) StatusCode2 ¶
StatusCode2 returns the value of the <StatusCode><StatusCode> sub-element.
func (*Response) StatusMessage ¶
StatusMessage returns the value of the <StatusMessage> element.
func (*Response) SubjectConfirmationDataNotOnOrAfter ¶
SubjectConfirmationDataNotOnOrAfter returns the value of the <Assertion><SubjectConfirmationData> NotOnOrAfter attribute.
func (*Response) Success ¶
Success returns true if authentication succeeded (and thus we got an assertion from the Identity Provider). In case of failure, you can call the StatusCode() method for more details.
type SAMLBinding ¶
type SAMLBinding string
SAMLBinding can be either HTTPRedirect or HTTPPost.
const ( HTTPRedirect SAMLBinding = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect" HTTPPost SAMLBinding = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST" )
Constants for SAMLBinding
type SP ¶
type SP struct {
IDPEntityID string
EntityID string
Key []byte
KeyFile string
Cert []byte
CertFile string
//SingleSignOnService string
AssertionConsumerServices []string
SingleLogoutServices map[string]SAMLBinding
AttributeConsumingServices []AttributeConsumingService
IDP map[string]*IDP
Organization Organization
ContactPerson ContactPerson
// contains filtered or unexported fields
}
SP represents our Service Provider
func ConfigureSP ¶ added in v1.0.5
func (*SP) GetCert ¶
func (sp *SP) GetCert() *x509.Certificate
Cert returns the certificate of this Service Provider.
func (*SP) GetCertPEM ¶
CertPEM returns the certificate of this Service Provider in PEM format.
func (*SP) GetIDP ¶
GetIDP returns an IDP object representing the Identity Provider matching the given entityID.
func (*SP) GetKey ¶
func (sp *SP) GetKey() *rsa.PrivateKey
Key returns the private key of this Service Provider
func (*SP) GetSigningContext ¶
func (sp *SP) GetSigningContext() *dsig.SigningContext
func (*SP) LoadIDPMetadata ¶
LoadIDPMetadata load one or multiple Identity Providers by reading all the XML files in the given directory.
func (*SP) LoadIDPsFromXMLFile ¶
LoadIDPsFromXMLFile loads an Identity Provider from its XML metadata.
func (*SP) NewAuthnRequest ¶
func (sp *SP) NewAuthnRequest(idp *IDP) *AuthnRequest
NewAuthnRequest generates an AuthnRequest addressed to this Identity Provider. Note that this method does not perform any network call, it just initializes an object.
func (*SP) NewLogoutRequest ¶
func (sp *SP) NewLogoutRequest(session *Session) (*LogoutRequestOut, error)
NewLogoutRequest generates a LogoutRequest addressed to the Identity Provider. Note that this method does not perform any network call, it just initializes an object.
func (*SP) NewLogoutResponse ¶
func (sp *SP) NewLogoutResponse(logoutreq *LogoutRequestIn, status LogoutStatus) (*LogoutResponseOut, error)
NewLogoutResponse generates a LogoutRequest addressed to the Identity Provider. Note that this method does not perform any network call, it just initializes an object.
func (*SP) ParseLogoutRequest ¶
func (sp *SP) ParseLogoutRequest(r *http.Request) (*LogoutRequestIn, error)
ParseLogoutRequest parses an http.Request and instantiates a LogoutRequestIn.
func (*SP) ParseLogoutResponse ¶
func (sp *SP) ParseLogoutResponse(r *http.Request) (*LogoutResponseIn, error)
ParseLogoutResponse parses an http.Request and instantiates a LogoutResponseIn.