saml

package module
v0.0.0-...-d2687f3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2016 License: MIT Imports: 21 Imported by: 0

README

go-saml

Build Status

GoDoc

(Work In Progress) Ideas and Tools for SAML

See Also

Credits

Documentation

Index

Constants

View Source
const (
	Bearer                     ConfirmationMethod   = `urn:oasis:names:tc:SAML:2.0:cm:bearer`
	PasswordProtectedTransport AuthenticationMethod = `urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport`
)
View Source
const TimeFormat = "2006-01-02T15:04:05"

TimeFormat is the format defined in xs:dateTime

Variables

View Source
var UUIDURL = "github.com/lestrrat/go-saml"

Functions

This section is empty.

Types

type Assertion

type Assertion struct {
	AuthnStatement     AuthnStatement
	AttributeStatement AttributeStatement
	Conditions         Conditions
	ID                 string
	IssueInstant       time.Time
	Issuer             string
	Subject            Subject
	Version            string
}

func NewAssertion

func NewAssertion() *Assertion

func (*Assertion) AddAttribute

func (a *Assertion) AddAttribute(att Attribute) error

func (Assertion) MakeXMLNode

func (a Assertion) MakeXMLNode(d types.Document) (types.Node, error)

func (Assertion) Serialize

func (a Assertion) Serialize() (string, error)

type AssertionConsumerService

type AssertionConsumerService struct {
	ProtocolBinding string
	Location        string
	Index           int
}

func (AssertionConsumerService) MakeXMLNode

func (s AssertionConsumerService) MakeXMLNode(doc types.Document) (types.Node, error)

type Attribute

type Attribute struct {
	Attrs        map[string]string
	FriendlyName string
	Name         string
	Values       []AttributeValue
}

func (Attribute) MakeXMLNode

func (a Attribute) MakeXMLNode(d types.Document) (types.Node, error)

type AttributeStatement

type AttributeStatement struct {
	Attributes []Attribute // Probably multiple attributes allowed?
}

func (AttributeStatement) MakeXMLNode

func (as AttributeStatement) MakeXMLNode(d types.Document) (types.Node, error)

type AttributeValue

type AttributeValue struct {
	Type  string
	Value string
}

func (AttributeValue) MakeXMLNode

func (av AttributeValue) MakeXMLNode(d types.Document) (types.Node, error)

type AudienceRestriction

type AudienceRestriction struct {
	Audience []string
}

func (AudienceRestriction) MakeXMLNode

func (ar AudienceRestriction) MakeXMLNode(d types.Document) (types.Node, error)

type AuthenticationMethod

type AuthenticationMethod string

func (AuthenticationMethod) String

func (am AuthenticationMethod) String() string

type AuthnContext

type AuthnContext struct {
	AuthnContextClassRef AuthenticationMethod
}

func (AuthnContext) MakeXMLNode

func (ac AuthnContext) MakeXMLNode(d types.Document) (types.Node, error)

type AuthnRequest

type AuthnRequest struct {
	Request
	NameIDPolicy                   *NameIDPolicy
	ForceAuthn                     bool
	IsPassive                      bool
	ProtocolBinding                binding.Protocol
	AssertionConsumerServiceURL    string
	AssertionConsumerServiceIndex  uint8
	AttributeConsumingServiceIndex uint8
	ProviderName                   string
	RequestedAuthnContext          *RequestedAuthnContext
}

func DecodeAuthnRequest

func DecodeAuthnRequest(b []byte, verify bool) (*AuthnRequest, error)

DecodeAuthnRequest takes in a byte buffer, decodes it from base64, inflates it, and then parses the resulting XML. If verify is true, it looks for the signature in the payload and does signature validation using go-xmlsec.

func DecodeAuthnRequestString

func DecodeAuthnRequestString(s string, verify bool) (*AuthnRequest, error)

DecodeAuthnRequestString takes in a byte buffer, decodes it from base64, inflates it, and then parses the resulting XML. If verify is true, it looks for the signature in the payload and does signature validation using go-xmlsec.

func NewAuthnRequest

func NewAuthnRequest() *AuthnRequest

func ParseAuthnRequest

func ParseAuthnRequest(src []byte) (*AuthnRequest, error)

func ParseAuthnRequestString

func ParseAuthnRequestString(src string) (*AuthnRequest, error)

func (AuthnRequest) Encode

func (ar AuthnRequest) Encode(key *crypto.Key) ([]byte, error)

Encode takes the Authentication Request, generates the XML string, deflates it, and base64 encodes it. URL encoding is done in the HTTP protocol. If the key value is not nil, it will attempt to generate a signature using that specified key

func (AuthnRequest) MakeXMLNode

func (ar AuthnRequest) MakeXMLNode(d types.Document) (types.Node, error)

func (*AuthnRequest) PopulateFromXML

func (ar *AuthnRequest) PopulateFromXML(n types.Node) error

func (AuthnRequest) Serialize

func (ar AuthnRequest) Serialize() (string, error)

type AuthnStatement

type AuthnStatement struct {
	AuthnInstant time.Time
	SessionIndex string
	AuthnContext AuthnContext
}

func (AuthnStatement) MakeXMLNode

func (as AuthnStatement) MakeXMLNode(d types.Document) (types.Node, error)

type Conditions

type Conditions struct {
	NotBefore           time.Time
	NotOnOrAfter        time.Time
	AudienceRestriction AudienceRestriction
	Condition           []interface{}
}

func (*Conditions) AddAudience

func (c *Conditions) AddAudience(s string)

func (Conditions) MakeXMLNode

func (c Conditions) MakeXMLNode(d types.Document) (types.Node, error)

func (*Conditions) SetNotBefore

func (c *Conditions) SetNotBefore(t time.Time)

type ConfirmationMethod

type ConfirmationMethod string

func (ConfirmationMethod) String

func (cm ConfirmationMethod) String() string

type Endpoint

type Endpoint struct {
	Name             string
	ProtocolBinding  binding.Protocol
	Location         string
	ResponseLocation string
}

func (Endpoint) MakeXMLNode

func (e Endpoint) MakeXMLNode(doc types.Document) (types.Node, error)

type EntityID

type EntityID string

type IndexedEndpoint

type IndexedEndpoint struct {
	Endpoint
	Index     int
	IsDefault bool
}

type MakeXMLNoder

type MakeXMLNoder interface {
	MakeXMLNode(types.Document) (types.Node, error)
}

MakeXMLNoder defines the interface for things that can marshal itself into libxml2 Nodes

type Message

type Message struct {
	Consent     string
	Destination string
	// ID is an identifier for the request. It is of type xs:ID and
	// MUST follow the requirementsspecified in Section 1.3.4 for
	// identifier uniqueness. The values of the ID attribute in a
	// request and the InResponseTo attribute in the corresponding
	// response MUST match
	ID           string
	IssueInstant time.Time
	Issuer       string
	Version      string
}

func (*Message) Initialize

func (msg *Message) Initialize() *Message

func (Message) MakeXMLNode

func (m Message) MakeXMLNode(d types.Document) (types.Node, error)

type NameID

type NameID struct {
	Format          nameid.Format
	SPNameQualifier string
	Value           string
}

func (NameID) MakeXMLNode

func (n NameID) MakeXMLNode(d types.Document) (types.Node, error)

type NameIDPolicy

type NameIDPolicy struct {
	AllowCreate     bool
	Format          nameid.Format
	SPNameQualifier string
}

func NewNameIDPolicy

func NewNameIDPolicy(f nameid.Format, allowCreate bool) *NameIDPolicy

func (NameIDPolicy) MakeXMLNode

func (nip NameIDPolicy) MakeXMLNode(d types.Document) (types.Node, error)

func (*NameIDPolicy) PopulateFromXML

func (nip *NameIDPolicy) PopulateFromXML(n types.Element) error

type Request

type Request struct {
	Message
}

Request represents the RequestAbstracttype from SAML specification

func (*Request) PopulateFromXML

func (r *Request) PopulateFromXML(n types.Node) error

type RequestedAuthnContext

type RequestedAuthnContext struct {
	Comparison           string
	AuthnContextClassRef string
}

func NewRequestedAuthnContext

func NewRequestedAuthnContext(cmp, classRef string) *RequestedAuthnContext

func (RequestedAuthnContext) MakeXMLNode

func (rac RequestedAuthnContext) MakeXMLNode(d types.Document) (types.Node, error)

type Response

type Response struct {
	Message
	Status       StatusCode
	InResponseTo string
	Assertion    *Assertion
}

func NewResponse

func NewResponse() *Response

func (Response) Encode

func (res Response) Encode(key *crypto.Key) ([]byte, error)

func (Response) MakeXMLNode

func (res Response) MakeXMLNode(d types.Document) (types.Node, error)

func (Response) Serialize

func (r Response) Serialize() (string, error)

type StatusCode

type StatusCode string
const (
	// StatusSuccess means the request succeeded. Additional information MAY
	// be returned in the <StatusMessage> and/or <StatusDetail> elements.
	StatusSuccess StatusCode = "urn:oasis:names:tc:SAML:2.0:status:Success"

	// ErrRequester means that the request could not be performed due to
	// an error on the part of the requester
	ErrRequester StatusCode = "urn:oasis:names:tc:SAML:2.0:status:Requester"

	// ErrResponder means the request could not be performed due to an error
	// on the part of the SAML responder or SAML authority.
	ErrResponder StatusCode = "urn:oasis:names:tc:SAML:2.0:status:Responder"

	// ErrVersionMismatch the SAML responder could not process the request
	// because the version of the request message was incorrect.
	ErrVersionMismatch StatusCode = "urn:oasis:names:tc:SAML:2.0:status:VersionMismatch"
)

Top-level status codes

const (
	// ErrAuthnFailed means the responding provider was unable to
	// successfully authenticate the principal.
	ErrAuthnFailed StatusCode = "urn:oasis:names:tc:SAML:2.0:status:AuthnFailed"

	// ErrInvalidAttrNameOrValue means an unexpected or invalid content
	// was encountered within a <saml:Attribute> or <saml:AttributeValue>
	// element.
	ErrInvalidAttrNameOrValue StatusCode = "urn:oasis:names:tc:SAML:2.0:status:InvalidAttrNameOrValue"

	// ErrInvalidNameIDPolicy means the responding provider cannot or
	// will not support the requested name identifier policy.
	ErrInvalidNameIDPolicy StatusCode = "urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy"

	// ErrNoAuthnContext means the specified authentication context
	// requirements cannot be met by the responder.
	ErrNoAuthnContext StatusCode = "urn:oasis:names:tc:SAML:2.0:status:NoAuthnContext"

	// ErrNoAvailableIDP is used by an intermediary to indicate that
	// none of the supported identity provider <Loc> elements in an
	// <IDPList> can be resolved or that none of the supported identity
	// providers are available.
	ErrNoAvailableIDP StatusCode = "urn:oasis:names:tc:SAML:2.0:status:NoAvailableIDP"

	// ErrNoPassive indicates the responding provider cannot authenticate
	// the principal passively, as has been requested.
	ErrNoPassive StatusCode = "urn:oasis:names:tc:SAML:2.0:status:NoPassive"

	// ErrNoSupportedIDP is used by an intermediary to indicate that none
	// of the identity providers in an <IDPList> are supported by the
	// intermediary.
	ErrNoSupportedIDP StatusCode = "urn:oasis:names:tc:SAML:2.0:status:NoSupportedIDP"

	// ErrPartialLogout is used by a session authority to indicate to
	// a session participant that it was not able to propagate logout
	// to all other session participants.
	ErrPartialLogout StatusCode = "urn:oasis:names:tc:SAML:2.0:status:PartialLogout"

	// ErrProxyCountExceeded indicates that a responding provider cannot
	// authenticate the principal directly and is not permitted to proxy
	// the request further.
	ErrProxyCountExceeded StatusCode = "urn:oasis:names:tc:SAML:2.0:status:ProxyCountExceeded"

	// ErrRequestDenied means the SAML responder or SAML authority is
	// able to process the request but has chosen not to respond. This
	// status code MAY be used when there is concern about the security
	// context of the request message or the sequence of request messages
	// received from a particular requester.
	ErrRequestDenied StatusCode = "urn:oasis:names:tc:SAML:2.0:status:RequestDenied"

	// ErrRequestUnsupported means the SAML responder or SAML authority
	// does not support the request.
	ErrRequestUnsupported StatusCode = "urn:oasis:names:tc:SAML:2.0:status:RequestUnsupported"

	// ErrRequestVersionDeprecated means the SAML responder cannot process
	// any requests with the protocol version specified in the request.
	ErrRequestVersionDeprecated StatusCode = "urn:oasis:names:tc:SAML:2.0:status:RequestVersionDeprecated"

	// ErrRequestVersionTooHigh means the SAML responder cannot process
	// the request because the protocol version specified in the request
	// message is a major upgrade from the highest protocol version supported
	// by the responder.
	ErrRequestVersionTooHigh StatusCode = "urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooHigh"

	// ErrRequestVersionTooLow means the SAML responder cannot process
	// the request because the protocol version specified in the request
	// message is too low.
	ErrRequestVersionTooLow StatusCode = "urn:oasis:names:tc:SAML:2.0:status:RequestVersionTooLow"

	// ErrResourceNotRecognized means the resource value provided in the
	// request message is invalid or unrecognized.
	ErrResourceNotRecognized StatusCode = "urn:oasis:names:tc:SAML:2.0:status:ResourceNotRecognized"

	// ErrTooManyResponses means the response message would contain more
	// elements than the SAML responder is able to return.
	ErrTooManyResponses StatusCode = "urn:oasis:names:tc:SAML:2.0:status:TooManyResponses"

	// ErrUnknownAttrProfile means an entity that has no knowledge of a
	// particular attribute profile has been presented with an attribute
	// drawn from that profile.
	ErrUnknownAttrProfile StatusCode = "urn:oasis:names:tc:SAML:2.0:status:UnknownAttrProfile"

	// ErrUnknownPrincipal means the responding provider does not recognize
	// the principal specified or implied by the request.
	ErrUnknownPrincipal StatusCode = "urn:oasis:names:tc:SAML:2.0:status:UnknownPrincipal"

	// ErrUnsupportedBinding means the SAML responder cannot properly fulfill
	// the request using the protocol binding specified in the request.
	ErrUnsupportedBinding StatusCode = "urn:oasis:names:tc:SAML:2.0:status:UnsupportedBinding"
)

Second-level status codes described in https://www.oasis-open.org/committees/download.php/56777/sstc-saml-core-errata-2.0-wd-07-diff.pdf. Quoth: "System entities are free to define more specific status codes by defining appropriate URI references.

func (StatusCode) Error

func (s StatusCode) Error() string

Error satisfies the "error" interface.

func (StatusCode) String

func (s StatusCode) String() string

type Subject

type Subject struct {
	NameID
	SubjectConfirmation
}

func (Subject) MakeXMLNode

func (s Subject) MakeXMLNode(d types.Document) (types.Node, error)

type SubjectConfirmation

type SubjectConfirmation struct {
	Method       ConfirmationMethod
	InResponseTo string
	Recipient    string
	NotOnOrAfter time.Time
}

func (SubjectConfirmation) MakeXMLNode

func (sc SubjectConfirmation) MakeXMLNode(d types.Document) (types.Node, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL