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 ¶
- Variables
- func CheckOAuthAccessToken(r *http.Request) (err error)
- func CurrentUserId(r *http.Request) (id string)
- type BackendStore
- func (s *BackendStore) Blobget(key string) (content string, err error)
- func (s *BackendStore) Blobstore(content string) (key string, err error)
- func (f *BackendStore) ConsumerSecret(consumer_key string) (secret string, err error)
- func (f *BackendStore) CreateCredentials(consumer_key, request_token, verifier string) (token_key, token_secret string)
- func (f *BackendStore) CreateTemporaryCredentials(consumer_key, callback string) (token_key, token_secret string)
- func (s *BackendStore) DelOAuthToken(tokenKey string) (err error)
- func (s *BackendStore) GetOAuthConsumer(id string) (u *OAuthConsumer, err error)
- func (s *BackendStore) GetOAuthNonce(consumerKey, tokenKey, nonce string) (u *OAuthNonce, err error)
- func (s *BackendStore) GetOAuthToken(tokenKey string) (u *OAuthToken, err error)
- func (s *BackendStore) PutOAuthConsumer(u *OAuthConsumer) (err error)
- func (s *BackendStore) PutOAuthNonce(u *OAuthNonce) (err error)
- func (s *BackendStore) PutOAuthToken(u *OAuthToken) (err error)
- func (f *BackendStore) TokenSecret(token_key string) (secret string, err error)
- func (f *BackendStore) Uniqueness(nonce, consumer_key, token_key string) bool
- func (f *BackendStore) ValidateToken(token, consumer_key string) bool
- type OAuthConsumer
- type OAuthNonce
- type OAuthServer
- func (s *OAuthServer) OAuthAuthorizeToken() http.HandlerFunc
- func (s *OAuthServer) OAuthGetAccessToken() http.HandlerFunc
- func (s *OAuthServer) OAuthGetRequestToken() http.HandlerFunc
- func (s *OAuthServer) OAuthTokenAuthorized() http.HandlerFunc
- func (s *OAuthServer) PruneObsolete() http.HandlerFunc
- func (*OAuthServer) Render(w http.ResponseWriter, content interface{}, templates ...string) error
- type OAuthToken
Constants ¶
This section is empty.
Variables ¶
var ( OAuthConsumer_Table = "OAuthConsumer" OAuthNonce_Table = "OAuthNonce" OAuthToken_Table = "OAuthToken" )
every "entity"'s name is declared here'
Functions ¶
func CheckOAuthAccessToken ¶
CheckOAuthAccessToken assert that "r" is a valid token, a valid access token one. Return err otherwise.
func CurrentUserId ¶
CurrentUserId extract from the given request the current user ID.
Types ¶
type BackendStore ¶
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 ¶
OAuthCOnsumer is the entity representing the Consumer information.
type OAuthNonce ¶
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