gopenid

package module
v0.0.0-...-520ca25 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2017 License: MIT Imports: 17 Imported by: 6

README

  _____  ____                   _____ _____
 / ____|/ __ \                 |_   _|  __ \
| |  __| |  | |_ __   ___ _ __   | | | |  | |
| | |_ | |  | | '_ \ / _ \ '_ \  | | | |  | |
| |__| | |__| | |_) |  __/ | | |_| |_| |__| |
 \_____|\____/| .__/ \___|_| |_|_____|_____/
              | |
              |_|

About

GOpenID is a Go implementation of library for serve as OpenID 2.0 Provider developed at Gehirn Inc.

LICENSE

See ./LICENSE.md

Documentation

Index

Constants

View Source
const (
	AssociationLifetime = 24 * time.Hour
)

Variables

View Source
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
)
View Source
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")
)

Functions

func Base64ToInt

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

func DecodeBase64

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

func EncodeBase64

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

func EncodeXRDS

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

EncodeXRDS returns et as XML document.

func IntToBase64

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

Types

type AssocType

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

func GetAssocTypeByName

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

func (*AssocType) GetSecretSize

func (t *AssocType) GetSecretSize() int

func (*AssocType) Hash

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

func (*AssocType) Name

func (t *AssocType) Name() string

type Association

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

func NewAssociation

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

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

func (*Association) Sign

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

type Message

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

Message represents OpenID protocol message.

func MessageFromQuery

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

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

func (m *Message) Copy() Message

Copy returns copy of m.

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

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

Keys returns all of keys m has.

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

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

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

ToQuery returns the m as url.Values.

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

func (k *MessageKey) GetKey() string

GetKey returns key of k.

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

func (MessageValue) Bytes

func (v MessageValue) Bytes() []byte

Bytes returns v as []byte.

func (MessageValue) String

func (v MessageValue) String() string

String returns v as string.

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

func (NamespaceURI) String

func (ns NamespaceURI) String() string

String returns as string.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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