{"modulePath":"github.com/sourcegraph/gologin","version":"v2.0.0+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package github\n\nPackage github provides Github OAuth2 login and callback handlers.\n\n## Variables\n\n```go\nvar (\n\tErrUnableToGetGithubUser = errors.New(\"github: unable to get Github User\")\n)\n```\nGithub login errors\n\n## Functions\n\n```go\nfunc CallbackHandler(config *oauth2.Config, success, failure http.Handler) http.Handler\n```\nCallbackHandler handles Github redirection URI requests and adds the Github access token and User to the ctx. If authentication succeeds, handling delegates to the success handler, otherwise to the failure handler.\n\n```go\nfunc LoginHandler(config *oauth2.Config, failure http.Handler) http.Handler\n```\nLoginHandler handles Github login requests by reading the state value from the ctx and redirecting requests to the AuthURL with that state value.\n\n```go\nfunc StateHandler(config gologin.CookieConfig, success http.Handler) http.Handler\n```\nStateHandler checks for a state cookie. If found, the state value is read and added to the ctx. Otherwise, a non-guessable value is added to the ctx and to a (short-lived) state cookie issued to the requester.\n\nImplements OAuth 2 RFC 6749 10.12 CSRF Protection. If you wish to issue state params differently, write a http.Handler which sets the ctx state, using oauth2 WithState(ctx, state) since it is required by LoginHandler and CallbackHandler.\n\n```go\nfunc UserFromContext(ctx context.Context) (*github.User, error)\n```\nUserFromContext returns the Github User from the ctx.\n\n```go\nfunc WithUser(ctx context.Context, user *github.User) context.Context\n```\nWithUser returns a copy of ctx that stores the Github User.\n\n","path":"github.com/sourcegraph/gologin/github","name":"github","synopsis":"Package github provides Github OAuth2 login and callback handlers.","isRedistributable":true}
