openid

package module
v0.0.0-...-5021f80 Latest Latest
Warning

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

Go to latest
Published: May 21, 2012 License: BSD-3-Clause Imports: 10 Imported by: 0

README

Go-OpenID

NOTE: THIS IS NOW WORK IN PROGRESS on improving the library, I'm not sure if anything works now, and/or if there are no errors/security issues.

About

Go-OpenID is an implementation of OpenID authentication protocol in Golang.

For now, the implementation does not manage XRI identifier, and can only check authentication with a direct request.

Here are the specifications used:

Install

go get github.com/akavel/go-openid

Usage

url := openid.GetRedirectURL("Identifier", "http://www.realm.com", "/loginCheck")

Now you have to redirect the user to the url returned. The OP will then forward the user back to you, after authenticating him.

To check the identity, do that:

grant, id, err := openid.Verify(URL)

URL is the url the user was redirected to. grant will be true if the user was correctly authenticated, false otherwise. If the user was authenticated, id contains its identifier.

Documentation

Overview

Package openid implements parts of the OpenID 2.0 standard. For more information, see: http://openid.net/specs/openid-authentication-2_0.html

Usage:

query, err := openid.Discover("http://johnsmith.myopenid.com")
if err != nil {
	panic(err)
}
url := query.CreateAuthenticationRequest("http://www.sesame.com", "/loginVerifier")

Now you have to redirect the user to the url returned. The OP (OpenID Provider) will then forward the user back to you (i.e. in example to: "http://www.sesame.com/loginVerifier"), after authenticating him.

To check the user's identity afterwards, run:

grant, id, err := openid.Verify(URL)

URL is the url the user was redirected to, with the full query string. The grant variable will be true if the user was correctly authenticated, false otherwise. If the user was authenticated, id contains his identifier.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRedirectURL

func GetRedirectURL(identifier string, realm string, returnto string) (string, error)

func Verify

func Verify(url_ string) (granted bool, identifier string, err error)

Verify that the url given match a successfull authentication.

Return:

  • true if authenticated, false otherwise
  • the claimed identifier if authenticated
  • eventually an error

func VerifyValues

func VerifyValues(values url.Values) (granted bool, identifier string, err error)

Like Verify on a parsed URL

func YadisRequest

func YadisRequest(url_ string) (*http.Response, error)

Types

type Query

type Query struct {
	ClaimedID     string
	OPEndpointURL string
	*log.Logger
}

func Discover

func Discover(identifier string) (*Query, error)

func DiscoverVerbose

func DiscoverVerbose(identifier string, verbose *log.Logger) (*Query, error)

func (Query) CreateAuthenticationRequest

func (q Query) CreateAuthenticationRequest(Realm, ReturnTo string) string

Jump to

Keyboard shortcuts

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