Skip to content

Instantly share code, notes, and snippets.

@yanatan16
Created July 16, 2012 02:21
Show Gist options
  • Save yanatan16/3120004 to your computer and use it in GitHub Desktop.
Save yanatan16/3120004 to your computer and use it in GitHub Desktop.
The AuthHandler Interface for goauth2
// These handlers should basically perform like a simple form submission.
// Once complete, notify the client using the redirects.
// As always, see http://tools.ietf.org/html/draft-ietf-oauth-v2-29 for reference.
// AuthHandler performs authentication with the resource owner
// It is important they follow OAuth 2.0 specification. For ease of use,
// A reference to the Store is passed in the OAuthRequest.
type AuthHandler interface {
// Authorize a client using the Authorization Code Grant Flow
// After authorization, the server should redirect using
// oar.AuthCodeRedirect()
Authorize(w http.ResponseWriter, r *http.Request, oar *OAuthRequest)
// Authorize a client using the Implicit Grant Flow
// After authorization, the server should redirect using
// oar.AuthCodeRedirect()
AuthorizeImplicit(w http.ResponseWriter, r *http.Request, oar *OAuthRequest)
}
// Use these two functions to call the redirect
// A nil error means everything is authorized
// A non-nil error will be notified in the spec-compliant way.
func (req *OAuthRequest) ImplicitRedirect(w http.ResponseWriter, r *http.Request, err error);
func (req *OAuthRequest) AuthCodeRedirect(w http.ResponseWriter, r *http.Request, err error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment