Created
July 16, 2012 02:21
-
-
Save yanatan16/3120004 to your computer and use it in GitHub Desktop.
The AuthHandler Interface for goauth2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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