Documentation
¶
Index ¶
- type AttributeConsumingService
- type AuthnRequest
- type IDP
- type LogoutRequestIn
- type LogoutRequestOut
- type LogoutResponseIn
- type LogoutResponseOut
- type LogoutStatus
- 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 (response *Response) IssueInstant() (time.Time, error)
- func (msg *Response) Issuer() string
- func (response *Response) IssuerFormat() 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 (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) Version() string
- type SAMLBinding
- type SP
- func (sp *SP) Cert() *x509.Certificate
- func (sp *SP) GetButton(pattern string) string
- func (sp *SP) GetIDP(entityID string) (*IDP, error)
- func (sp *SP) Key() *rsa.PrivateKey
- func (sp *SP) KeyPEM() []byte
- func (sp *SP) LoadIDPFromXMLFile(path string) error
- func (sp *SP) LoadIDPMetadata(dir 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, inResponseTo string) (*LogoutResponseIn, error)
- func (sp *SP) ParseResponse(r *http.Request, inResponseTo string) (*Response, error)
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttributeConsumingService ¶
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 IDP ¶
type IDP struct { XML string EntityID string Cert *x509.Certificate SSOURLs map[SAMLBinding]string SLOReqURLs map[SAMLBinding]string SLOResURLs map[SAMLBinding]string }
IDP represents an Identity Provider.
func NewIDPFromXML ¶
NewIDPFromXML 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 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 (*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) IssueInstant ¶
Version returns the value of the Version attribute.
func (*Response) Issuer ¶
func (msg *Response) Issuer() string
Issuer returns the value of the <Issuer> element.
func (*Response) IssuerFormat ¶
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.
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 { EntityID string OrganizationName string OrganizationDisplayName string OrganizationURL string OrganizationLang string KeyFile string CertFile string AssertionConsumerServices []string SingleLogoutServices map[string]SAMLBinding AttributeConsumingServices []AttributeConsumingService IDP map[string]*IDP // contains filtered or unexported fields }
SP represents our Service Provider
func (*SP) Cert ¶
func (sp *SP) Cert() *x509.Certificate
Cert returns the certificate of this Service Provider.
func (*SP) GetIDP ¶
GetIDP returns an IDP object representing the Identity Provider matching the given entityID.
func (*SP) Key ¶
func (sp *SP) Key() *rsa.PrivateKey
Key returns the private key of this Service Provider
func (*SP) LoadIDPFromXMLFile ¶
LoadIDPFromXMLFile loads an Identity Provider from its XML metadata.
func (*SP) LoadIDPMetadata ¶
LoadIDPMetadata load one or multiple Identity Providers by reading all the XML files in the given directory.
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 ¶
ParseLogoutResponse parses an http.Request and instantiates a LogoutResponseIn.
func (*SP) ParseResponse ¶
ParseResponse parses a Response/Assertion. Validation is performed (see the documentation for the Response::validate() method), so this method may return an error. A second argument can be supplied, containing the C<ID> of the request message; in this case validation will also check the InResponseTo attribute.