GOpenID: github.com/GehirnInc/GOpenID Index | Files | Directories

package gopenid

import "github.com/GehirnInc/GOpenID"

Index

Package Files

association.go message.go store.go utils.go xrds.go

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{
        name:       "HMAC-SHA1",
        hashFunc:   sha1.New,
        secretSize: sha1.Size,
    }
    AssocHmacSha256 = AssocType{
        name:       "HMAC-SHA256",
        hashFunc:   sha256.New,
        secretSize: sha256.Size,
    }

    SessionDhSha1 = SessionType{
        name: "DH-SHA1",
        assocTypes: []AssocType{
            AssocHmacSha1,
        },
    }
    SessionDhSha256 = SessionType{
        name: "DH-SHA256",
        assocTypes: []AssocType{
            AssocHmacSha256,
        },
    }
    SessionNoEncryption = SessionType{
        name: "no-encryption",
        assocTypes: []AssocType{
            AssocHmacSha1,
            AssocHmacSha256,
        },
    }

    DefaultAssoc   = AssocHmacSha256
    DefaultSession = SessionDhSha256
)
var (
    ErrMalformedMessage   = errors.New("malformed Message")
    ErrUnsupportedVersion = errors.New("unsupported version")
    ErrKeyContainsColon   = errors.New("key contains colon")
    ErrKeyContainsNewLine = errors.New("key contains new line")
    ErrValueNotFound      = errors.New("value not found")
)

func Base64ToInt Uses

func Base64ToInt(input []byte) (i *big.Int, err error)

func DecodeBase64 Uses

func DecodeBase64(encoded []byte) (buf []byte, err error)

func EncodeBase64 Uses

func EncodeBase64(input []byte) (b []byte)

func EncodeXRDS Uses

func EncodeXRDS(et *XRDSDocument) ([]byte, error)

EncodeXRDS returns et as XML document.

func IntToBase64 Uses

func IntToBase64(i *big.Int) (output []byte)

type AssocType Uses

type AssocType struct {
    // contains filtered or unexported fields
}

func GetAssocTypeByName Uses

func GetAssocTypeByName(name string) (assocType AssocType, err error)

func (*AssocType) GetSecretSize Uses

func (t *AssocType) GetSecretSize() int

func (*AssocType) Hash Uses

func (t *AssocType) Hash() hash.Hash

func (*AssocType) Name Uses

func (t *AssocType) Name() string

type Association Uses

type Association struct {
    // contains filtered or unexported fields
}

func NewAssociation Uses

func NewAssociation(assocType AssocType, handle string, secret []byte, expires time.Time, isStateless bool) *Association

func (*Association) GetAssocType Uses

func (assoc *Association) GetAssocType() AssocType

func (*Association) GetExpires Uses

func (assoc *Association) GetExpires() time.Time

func (*Association) GetHandle Uses

func (assoc *Association) GetHandle() string

func (*Association) GetSecret Uses

func (assoc *Association) GetSecret() []byte

func (*Association) IsStateless Uses

func (assoc *Association) IsStateless() bool

func (*Association) IsValid Uses

func (assoc *Association) IsValid() bool

func (*Association) Sign Uses

func (assoc *Association) Sign(msg Message, signed []string) (err error)

type Message Uses

type Message struct {
    sync.Mutex
    // contains filtered or unexported fields
}

Message represents OpenID protocol message.

func MessageFromQuery Uses

func MessageFromQuery(req url.Values) (msg Message, err error)

MessageFromQuery returns a new message as a result of parsing the given query.

func NewMessage Uses

func NewMessage(ns NamespaceURI) Message

NewMessage returns a new Message with the given NamespaceURI.

func (*Message) AddArg Uses

func (m *Message) AddArg(k MessageKey, v MessageValue)

AddArg registers given the v as value of k.

func (*Message) Copy Uses

func (m *Message) Copy() Message

Copy returns copy of m.

func (*Message) GetArg Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (m *Message) GetOpenIDNamespace() NamespaceURI

GetOpenIDNamespace returns NamespaceURI of m.

func (*Message) Keys Uses

func (m *Message) Keys() []string

Keys returns all of keys m has.

func (*Message) SetNamespaceAlias Uses

func (m *Message) SetNamespaceAlias(alias string, uri NamespaceURI)

SetNamespaceAlias is a function to register relationship between alias and NamespaceURI.

func (*Message) ToKeyValue Uses

func (m *Message) ToKeyValue(order []string) (b []byte, err error)

ToKeyValue returns part of m as KeyValue format. Returnd KeyValue follows the given order.

func (*Message) ToQuery Uses

func (m *Message) ToQuery() url.Values

ToQuery returns the m as url.Values.

type MessageKey Uses

type MessageKey struct {
    // contains filtered or unexported fields
}

MessageKey is a key of Message.

func NewMessageKey Uses

func NewMessageKey(ns NamespaceURI, key string) MessageKey

NewMessageKey returns a new MessageKey given NamespaceURI, and key.

func (*MessageKey) GetKey Uses

func (k *MessageKey) GetKey() string

GetKey returns key of k.

func (*MessageKey) GetNamespace Uses

func (k *MessageKey) GetNamespace() NamespaceURI

GetNamespace returns NamespaceURI of k.

type MessageValue Uses

type MessageValue string

MessageValue is a value of Message.

func GenerateNonce Uses

func GenerateNonce(now time.Time) MessageValue

func (MessageValue) Bytes Uses

func (v MessageValue) Bytes() []byte

Bytes returns v as []byte.

func (MessageValue) String Uses

func (v MessageValue) String() string

String returns v as string.

type NamespaceURI Uses

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.
)

func (NamespaceURI) String Uses

func (ns NamespaceURI) String() string

String returns as string.

type SessionType Uses

type SessionType struct {
    // contains filtered or unexported fields
}

func GetSessionTypeByName Uses

func GetSessionTypeByName(name string) (sessionType SessionType, err error)

func (*SessionType) Name Uses

func (t *SessionType) Name() string

type Store Uses

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 Uses

type XRDSDocument struct {
    XMLName xml.Name `xml:"xri://$xrds XRDS"`
    XRD     XRDSXRDElement
}

XRDSDocument represents XRDS Document.

type XRDSServiceElement Uses

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 Uses

type XRDSXRDElement struct {
    XMLName  xml.Name `xml:"xri://$xrd*($v*2.0) XRD"`
    Services []XRDSServiceElement
}

XRDSXRDElement represents XRD node tree in XRDS document.

Directories

PathSynopsis
dh
example
provider

Package gopenid imports 17 packages (graph) and is imported by 4 packages. Updated 2017-11-19. Refresh now. Tools for package owners.