oauthengine

package module
v0.0.0-...-928e3fc Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2013 License: Apache-2.0 Imports: 15 Imported by: 0

README

Oauth 1.0 Service Provider implementation for google Appengine in go

(unfortunately I cannot add travis CI, appengine code is not gogetable)

(still a work in progress)

Documentation

Overview

oauthengine is a google-app-engine-backed oauth service provider implementation.

It relies on github.com/ericaro/oauthprovider as the main implementation of oauth on the server side.

Usage:

creates an OAuthServer instance

this server can be configured, and then it exposes Endpoints as "http.HandlerFunc". It's your job to connect those endpoints to a path on you server.

finally just call CheckOAuthAccessToken(r) whenever you need to check the current OAuthentication, or CurrentUserId whenever you need to know the current authtenticated user.

Index

Constants

This section is empty.

Variables

View Source
var (
	OAuthConsumer_Table = "OAuthConsumer"
	OAuthNonce_Table    = "OAuthNonce"
	OAuthToken_Table    = "OAuthToken"
)

every "entity"'s name is declared here'

Functions

func CheckOAuthAccessToken

func CheckOAuthAccessToken(r *http.Request) (err error)

CheckOAuthAccessToken assert that "r" is a valid token, a valid access token one. Return err otherwise.

func CurrentUserId

func CurrentUserId(r *http.Request) (id string)

CurrentUserId extract from the given request the current user ID.

Types

type BackendStore

type BackendStore struct {
	appengine.Context
	// contains filtered or unexported fields
}

BackendStore implements the oauthprovider BackendStore interface, and add some specific checker

func NewBackendStore

func NewBackendStore(r *http.Request) *BackendStore

func (*BackendStore) Blobget

func (s *BackendStore) Blobget(key string) (content string, err error)

func (*BackendStore) Blobstore

func (s *BackendStore) Blobstore(content string) (key string, err error)

func (*BackendStore) ConsumerSecret

func (f *BackendStore) ConsumerSecret(consumer_key string) (secret string, err error)

func (*BackendStore) CreateCredentials

func (f *BackendStore) CreateCredentials(consumer_key, request_token, verifier string) (token_key, token_secret string)

func (*BackendStore) CreateTemporaryCredentials

func (f *BackendStore) CreateTemporaryCredentials(consumer_key, callback string) (token_key, token_secret string)

func (*BackendStore) DelOAuthToken

func (s *BackendStore) DelOAuthToken(tokenKey string) (err error)

func (*BackendStore) GetOAuthConsumer

func (s *BackendStore) GetOAuthConsumer(id string) (u *OAuthConsumer, err error)

func (*BackendStore) GetOAuthNonce

func (s *BackendStore) GetOAuthNonce(consumerKey, tokenKey, nonce string) (u *OAuthNonce, err error)

func (*BackendStore) GetOAuthToken

func (s *BackendStore) GetOAuthToken(tokenKey string) (u *OAuthToken, err error)

func (*BackendStore) PutOAuthConsumer

func (s *BackendStore) PutOAuthConsumer(u *OAuthConsumer) (err error)

Put

func (*BackendStore) PutOAuthNonce

func (s *BackendStore) PutOAuthNonce(u *OAuthNonce) (err error)

func (*BackendStore) PutOAuthToken

func (s *BackendStore) PutOAuthToken(u *OAuthToken) (err error)

func (*BackendStore) TokenSecret

func (f *BackendStore) TokenSecret(token_key string) (secret string, err error)

func (*BackendStore) Uniqueness

func (f *BackendStore) Uniqueness(nonce, consumer_key, token_key string) bool

func (*BackendStore) ValidateToken

func (f *BackendStore) ValidateToken(token, consumer_key string) bool

type OAuthConsumer

type OAuthConsumer struct {
	Key    string
	Secret string
	Name   string
}

OAuthCOnsumer is the entity representing the Consumer information.

func (*OAuthConsumer) Id

func (o *OAuthConsumer) Id() string

Id computes the Id for this entity

type OAuthNonce

type OAuthNonce struct {
	Nonce                 string
	ConsumerKey, TokenKey string
	Timestamp             time.Time
}

OAuthNonce internal check entity, representing every single Nonce received. for security concern they should not be reused. Nevertheless, it is unpractical to keep nonce forever, so we timestamp every nonce, and old Nonce are pruned. (see pruneNonce function)

type OAuthServer

type OAuthServer struct{}

OauthServer is a module level object used to configure the app. creates a an instance of OAuthServer configure parameters and you are ready

func (*OAuthServer) OAuthAuthorizeToken

func (s *OAuthServer) OAuthAuthorizeToken() http.HandlerFunc

func (*OAuthServer) OAuthGetAccessToken

func (s *OAuthServer) OAuthGetAccessToken() http.HandlerFunc

func (*OAuthServer) OAuthGetRequestToken

func (s *OAuthServer) OAuthGetRequestToken() http.HandlerFunc

note: in go1.1 methods are top level functions too, so I guess this piece of code should be simpler

func (*OAuthServer) OAuthTokenAuthorized

func (s *OAuthServer) OAuthTokenAuthorized() http.HandlerFunc

func (*OAuthServer) PruneObsolete

func (s *OAuthServer) PruneObsolete() http.HandlerFunc

func (*OAuthServer) Render

func (*OAuthServer) Render(w http.ResponseWriter, content interface{}, templates ...string) error

Basic template based renderer

type OAuthToken

type OAuthToken struct {
	Key         string
	ConsumerKey string
	Secret      string
	Verifier    string
	UserID      string
	Callback    string //the callback url
	Access      bool
	Timestamp   time.Time
}

func (*OAuthToken) Id

func (o *OAuthToken) Id() string

Jump to

Keyboard shortcuts

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