Documentation ¶
Index ¶
- Constants
- Variables
- func Base64ToInt(input []byte) (i *big.Int, err error)
- func DecodeBase64(encoded []byte) (buf []byte, err error)
- func EncodeBase64(input []byte) (b []byte)
- func EncodeXRDS(et *XRDSDocument) ([]byte, error)
- func IntToBase64(i *big.Int) (output []byte)
- type AssocType
- type Association
- func (assoc *Association) GetAssocType() AssocType
- func (assoc *Association) GetExpires() time.Time
- func (assoc *Association) GetHandle() string
- func (assoc *Association) GetSecret() []byte
- func (assoc *Association) IsStateless() bool
- func (assoc *Association) IsValid() bool
- func (assoc *Association) Sign(msg Message, signed []string) (err error)
- type Message
- func (m *Message) AddArg(k MessageKey, v MessageValue)
- func (m *Message) Copy() Message
- func (m *Message) GetArg(k MessageKey) (MessageValue, bool)
- func (m *Message) GetArgs(nsuri NamespaceURI) map[MessageKey]MessageValue
- func (m *Message) GetNamespaceAlias(uri NamespaceURI) (string, bool)
- func (m *Message) GetNamespaceURI(alias string) (NamespaceURI, bool)
- func (m *Message) GetOpenIDNamespace() NamespaceURI
- func (m *Message) Keys() []string
- func (m *Message) SetNamespaceAlias(alias string, uri NamespaceURI)
- func (m *Message) ToKeyValue(order []string) (b []byte, err error)
- func (m *Message) ToQuery() url.Values
- type MessageKey
- type MessageValue
- type NamespaceURI
- type SessionType
- type Store
- type XRDSDocument
- type XRDSServiceElement
- type XRDSXRDElement
Constants ¶
const (
AssociationLifetime = 24 * time.Hour
)
Variables ¶
var ( ErrGeneratingAssociationFailed = errors.New("generating association failed") ErrAssociationNotFound = errors.New("association not found") ErrUnknownSessionType = errors.New("unknown session type") ErrUnknownAssocType = errors.New("unknown association type") AssocHmacSha1 = AssocType{ // contains filtered or unexported fields } AssocHmacSha256 = AssocType{ // contains filtered or unexported fields } SessionDhSha1 = SessionType{ // contains filtered or unexported fields } SessionDhSha256 = SessionType{ // contains filtered or unexported fields } SessionNoEncryption = SessionType{ // contains filtered or unexported fields } DefaultAssoc = AssocHmacSha256 DefaultSession = SessionDhSha256 )
Functions ¶
func DecodeBase64 ¶
func EncodeBase64 ¶
func EncodeXRDS ¶
func EncodeXRDS(et *XRDSDocument) ([]byte, error)
EncodeXRDS returns et as XML document.
func IntToBase64 ¶
Types ¶
type AssocType ¶
type AssocType struct {
// contains filtered or unexported fields
}
func GetAssocTypeByName ¶
func (*AssocType) GetSecretSize ¶
type Association ¶
type Association struct {
// contains filtered or unexported fields
}
func NewAssociation ¶
func (*Association) GetAssocType ¶
func (assoc *Association) GetAssocType() AssocType
func (*Association) GetExpires ¶
func (assoc *Association) GetExpires() time.Time
func (*Association) GetHandle ¶
func (assoc *Association) GetHandle() string
func (*Association) GetSecret ¶
func (assoc *Association) GetSecret() []byte
func (*Association) IsStateless ¶
func (assoc *Association) IsStateless() bool
func (*Association) IsValid ¶
func (assoc *Association) IsValid() bool
type Message ¶
Message represents OpenID protocol message.
func MessageFromQuery ¶
MessageFromQuery returns a new message as a result of parsing the given query.
func NewMessage ¶
func NewMessage(ns NamespaceURI) Message
NewMessage returns a new Message with the given NamespaceURI.
func (*Message) AddArg ¶
func (m *Message) AddArg(k MessageKey, v MessageValue)
AddArg registers given the v as value of k.
func (*Message) GetArg ¶
func (m *Message) GetArg(k MessageKey) (MessageValue, bool)
GetArg returns value of given k. If value does not exist, GetArg returns false as 2nd return value.
func (*Message) GetArgs ¶
func (m *Message) GetArgs(nsuri NamespaceURI) map[MessageKey]MessageValue
GetArgs returns the subset of m as map[MessageKey]MessageValue. Returned subset contains values related to the given NamespaceURI.
func (*Message) GetNamespaceAlias ¶
func (m *Message) GetNamespaceAlias(uri NamespaceURI) (string, bool)
GetNamespaceAlias returns alias is pointing to the given NamespaceURI. If alias does not exist, GetNamespaceURI returns false as 2nd return value.
func (*Message) GetNamespaceURI ¶
func (m *Message) GetNamespaceURI(alias string) (NamespaceURI, bool)
GetNamespaceURI returns NamespaceURI mapped to the given alias. If NamespaceURI does not exist, GetNamespaceURI returns false as 2nd return value.
func (*Message) GetOpenIDNamespace ¶
func (m *Message) GetOpenIDNamespace() NamespaceURI
GetOpenIDNamespace returns NamespaceURI of m.
func (*Message) SetNamespaceAlias ¶
func (m *Message) SetNamespaceAlias(alias string, uri NamespaceURI)
SetNamespaceAlias is a function to register relationship between alias and NamespaceURI.
func (*Message) ToKeyValue ¶
ToKeyValue returns part of m as KeyValue format. Returnd KeyValue follows the given order.
type MessageKey ¶
type MessageKey struct {
// contains filtered or unexported fields
}
MessageKey is a key of Message.
func NewMessageKey ¶
func NewMessageKey(ns NamespaceURI, key string) MessageKey
NewMessageKey returns a new MessageKey given NamespaceURI, and key.
func (*MessageKey) GetNamespace ¶
func (k *MessageKey) GetNamespace() NamespaceURI
GetNamespace returns NamespaceURI of k.
type MessageValue ¶
type MessageValue string
MessageValue is a value of Message.
func GenerateNonce ¶
func GenerateNonce(now time.Time) MessageValue
type NamespaceURI ¶
type NamespaceURI string
NamespaceURI represents URI for Namespace.
const ( NsOpenID10 NamespaceURI = "http://openid.net/signon/1.0" // Namespace for OpenID 1.0 NsOpenID11 NamespaceURI = "http://openid.net/signon/1.1" // Namespace for OpenID 1.1 NsOpenID20 NamespaceURI = "http://specs.openid.net/auth/2.0" // Namespace for OpenID 2.0 NsIdentifierSelect NamespaceURI = "http://specs.openid.net/auth/2.0/identifier_select" )
const ( NsOpenID20Server NamespaceURI = "http://specs.openid.net/auth/2.0/server" // OpenID 2.0 Server. NsOpenID20Signon NamespaceURI = "http://specs.openid.net/auth/2.0/signon" // OpenID 2.0 Signon. NsXRDS NamespaceURI = "xri://$xrds" // Namespace for generic XRDS. NsXRD20 NamespaceURI = "xri://$xrd*($v*2.0)" // Namespace for XRDS version 2.0. )
type SessionType ¶
type SessionType struct {
// contains filtered or unexported fields
}
func GetSessionTypeByName ¶
func GetSessionTypeByName(name string) (sessionType SessionType, err error)
func (*SessionType) Name ¶
func (t *SessionType) Name() string
type Store ¶
type Store interface { StoreAssociation(*Association) GetAssociation(string, bool) (*Association, bool) DeleteAssociation(*Association) IsKnownNonce(string) bool StoreNonce(string) }
Store is a interface of data store.
GopenID users must implement this interface to use.
type XRDSDocument ¶
type XRDSDocument struct { XMLName xml.Name `xml:"xri://$xrds XRDS"` XRD XRDSXRDElement }
XRDSDocument represents XRDS Document.
type XRDSServiceElement ¶
type XRDSServiceElement struct { XMLName xml.Name `xml:"xri://$xrd*($v*2.0) Service"` Priority int `xml:"priority,attr"` Type []string `xml:"Type"` URI string `xml:"URI"` LocalID string `xml:"LocalID,omitempty"` }
XRDSServiceElement represents Service node in XRDS document.
type XRDSXRDElement ¶
type XRDSXRDElement struct { XMLName xml.Name `xml:"xri://$xrd*($v*2.0) XRD"` Services []XRDSServiceElement }
XRDSXRDElement represents XRD node tree in XRDS document.