openid

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

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

Go to latest
Published: Nov 8, 2016 License: Apache-2.0 Imports: 10 Imported by: 0

README

openid.go

This is a consumer (Relying party) implementation of OpenId 2.0, written in Go.

go get -u github.com/yohcop/openid-go

Build Status

Github

Be awesome! Feel free to clone and use according to the licence. If you make a useful change that can benefit others, send a pull request! This ensures that one version has all the good stuff and doesn't fall behind.

Code example

See _example/ for a simple webserver using the openID implementation. Also, read the comment about the NonceStore towards the top of that file. The example must be run for the openid-go directory, like so:

go run _example/server.go

App Engine

In order to use this on Google App Engine, you need to create an instance with a custom *http.Client provided by urlfetch.

oid := openid.NewOpenID(urlfetch.Client(appengine.NewContext(r)))
oid.RedirectURL(...)
oid.Verify(...)

License

Distributed under the Apache v2.0 license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRedirectURL

func BuildRedirectURL(item DiscoveryItem, returnTo, realm string) (string, error)

func Normalize

func Normalize(id string) (string, error)

Types

type Client

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

func New

func New(client *http.Client) *Client

func (*Client) Discover

func (oid *Client) Discover(id string) (item DiscoveryItem, err error)

func (*Client) RedirectURL

func (oid *Client) RedirectURL(id, callbackURL, realm string) (string, error)

func (*Client) Verify

func (oid *Client) Verify(uri string, discoveryStore DiscoveryStore, nonceStore NonceStore) (id string, err error)

type DiscoveryItem

type DiscoveryItem struct {
	OpEndpoint string
	OpLocalID  string
	ClaimedID  string
}

type DiscoveryStore

type DiscoveryStore interface {
	Put(id string, info *DiscoveryItem) error
	// Return a discovered info, or nil.
	Get(id string) (*DiscoveryItem, error)
}

type NonceItem

type NonceItem struct {
	Time  time.Time
	Nonce string
}

type NonceStore

type NonceStore interface {
	// Returns nil if accepted, an error otherwise.
	Accept(endpoint string, nonce NonceItem) error
}

type Xrd

type Xrd struct {
	Service []*XrdsIdentifier `xml:"Service"`
}

type XrdsDocument

type XrdsDocument struct {
	XMLName xml.Name `xml:"XRDS"`
	Xrd     *Xrd     `xml:"XRD"`
}

type XrdsIdentifier

type XrdsIdentifier struct {
	Type     []string `xml:"Type"`
	URI      string   `xml:"URI"`
	LocalID  string   `xml:"LocalID"`
	Priority int      `xml:"priority,attr"`
}

TODO: As per 11.2 in openid 2 specs, a service may have multiple

URIs. We don't care for discovery really, but we do care for
verification though.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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