Documentation ¶
Overview ¶
Package github provides Github OAuth2 login and callback handlers.
Index ¶
- Variables
- func CallbackHandler(config *oauth2.Config, success, failure ctxh.ContextHandler) ctxh.ContextHandler
- func LoginHandler(config *oauth2.Config, failure ctxh.ContextHandler) ctxh.ContextHandler
- func StateHandler(config gologin.CookieConfig, success ctxh.ContextHandler) ctxh.ContextHandler
- func UserFromContext(ctx context.Context) (*github.User, error)
- func WithUser(ctx context.Context, user *github.User) context.Context
Constants ¶
This section is empty.
Variables ¶
var (
ErrUnableToGetGithubUser = errors.New("github: unable to get Github User")
)
Github login errors
Functions ¶
func CallbackHandler ¶
func CallbackHandler(config *oauth2.Config, success, failure ctxh.ContextHandler) ctxh.ContextHandler
CallbackHandler 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.
func LoginHandler ¶
func LoginHandler(config *oauth2.Config, failure ctxh.ContextHandler) ctxh.ContextHandler
LoginHandler handles Github login requests by reading the state value from the ctx and redirecting requests to the AuthURL with that state value.
func StateHandler ¶
func StateHandler(config gologin.CookieConfig, success ctxh.ContextHandler) ctxh.ContextHandler
StateHandler 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.
Implements OAuth 2 RFC 6749 10.12 CSRF Protection. If you wish to issue state params differently, write a ContextHandler which sets the ctx state, using oauth2 WithState(ctx, state) since it is required by LoginHandler and CallbackHandler.
func UserFromContext ¶
UserFromContext returns the Github User from the ctx.
Types ¶
This section is empty.