openid2

package
v0.0.0-...-aeae87e Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const Namespace = "http://specs.openid.net/auth/2.0"

Variables

View Source
var ErrDuplicateAssociation = errors.New("duplicate association")
View Source
var ErrUnauthenticated = errors.New("authentication failed")

Functions

func EncodeHTTP

func EncodeHTTP(v url.Values, p map[string]string)

EncodeHTTP updates v with the encoding of p.

func EncodeKeyValue

func EncodeKeyValue(w io.Writer, p map[string]string) error

func ParseHTTP

func ParseHTTP(v url.Values) map[string]string

ParseHTTP parses openid values from the parameters in a url.Values.

func ParseKeyValue

func ParseKeyValue(body []byte) (map[string]string, error)

ParseKeyValue

func WriteKeyValuePair

func WriteKeyValuePair(w io.Writer, key, value string) error

Types

type Association

type Association struct {
	// Endpoint is the OP Endpoint for which this association is valid. It might be blank.
	Endpoint string

	// Handle is used to identify the association with the OP Endpoint.
	Handle string

	// Secret is the secret established with the OP Endpoint.
	Secret []byte

	// Type is the type of this association.
	Type string

	// Expires holds the expiration time of the association.
	Expires time.Time
}

Association represents an openid association.

type AssociationStore

type AssociationStore interface {
	// Add stores a new Association. If the specified Association is already
	// present in the store then ErrDuplicateAssociation should be returned.
	Add(a *Association) error

	// Get retrieves the Association with the specified endpoint and handle.
	// if there is no matching association in the store then ErrAssociationNotFound
	// should be returned.
	Get(endpoint, handle string) (*Association, error)

	// Find retrieves all Associations for the specified endpoint.
	Find(endpoint string) ([]*Association, error)

	// Delete removes the Association with the specified endpoint and handle.
	Delete(endpoint, handle string) error
}

AssociationStore is used to store associations in both the server and client.

var DefaultAssociationStore AssociationStore = NewMemoryAssociationStore()

DefaultAssociationStore is the AssociationStore that will be used if no AssociationStore is specified.

type Extension

type Extension struct {
	Namespace string
	Prefix    string
	Params    map[string]string
}

type Handler

type Handler struct {
	Login        LoginHandler
	Associations AssociationStore
}

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type LoginHandler

type LoginHandler interface {
	Login(http.ResponseWriter, *http.Request, *LoginRequest) (*LoginResponse, error)
}

LoginHandler provides server-side handling of a LoginRequest.

type LoginRequest

type LoginRequest struct {
	ClaimedID  string
	Identity   string
	ReturnTo   string
	Realm      string
	Extensions []Extension
}

LoginRequest represents an openid login request.

type LoginResponse

type LoginResponse struct {
	ClaimedID  string
	Identity   string
	OPEndpoint string
	Extensions []Extension
}

LoginResponse represents the response to an openid login request.

type MemoryAssociationStore

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

MemoryAssociationStore is an in memory implementation of AssociationStore.

func NewMemoryAssociationStore

func NewMemoryAssociationStore() *MemoryAssociationStore

NewMemoryAssociationStore creates a new in memory AssocationStore.

func (*MemoryAssociationStore) Add

Add implements AssociationStore.Add.

func (*MemoryAssociationStore) Delete

func (s *MemoryAssociationStore) Delete(endpoint, handle string) error

Delete implements AssociationStore.Delete.

func (*MemoryAssociationStore) Find

func (s *MemoryAssociationStore) Find(endpoint string) ([]*Association, error)

Find implements AssociationStore.Find.

func (*MemoryAssociationStore) Get

func (s *MemoryAssociationStore) Get(endpoint, handle string) (*Association, error)

Get implements AssociationStore.Get.

Jump to

Keyboard shortcuts

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