githubauth: github.com/kr/githubauth Index | Files

package githubauth

import "github.com/kr/githubauth"

Index

Package Files

githubauth.go

type ContextHandler Uses

type ContextHandler interface {
    ServeHTTPContext(context.Context, http.ResponseWriter, *http.Request)
}

A ContextHandler can be used as the HTTP handler in a Handler value in order to obtain information about the logged-in GitHub user through the provided Context. See GetSession.

type Handler Uses

type Handler struct {
    // RequireOrg is a GitHub organization that
    // users will be required to be in.
    // If unset, any user will be permitted.
    RequireOrg string

    // Used to initialize corresponding fields of a session Config.
    // See github.com/kr/session.
    // If Name is empty, "githubauth" is used.
    Name   string
    Path   string
    Domain string
    MaxAge time.Duration
    Keys   []*[32]byte

    // Used to initialize corresponding fields of oauth2.Config.
    // Scopes can be nil, in which case user:email and read:org
    // will be requested.
    ClientID     string
    ClientSecret string
    Scopes       []string

    // Handler is the HTTP handler called
    // once authentication is complete.
    // If nil, http.DefaultServeMux is used.
    // If the value implements ContextHandler,
    // its ServeHTTPContext method will be called
    // instead of ServeHTTP, and a *Session value
    // can be obtained from GetSession.
    Handler http.Handler
}

Handler is an HTTP handler that requires users to log in with GitHub OAuth and requires them to be members of the given org.

func (*Handler) ServeHTTP Uses

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Handler) ServeHTTPContext Uses

func (h *Handler) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, r *http.Request)

type Session Uses

type Session struct {
    // Client is an HTTP client obtained from oauth2.Config.Client.
    // It adds necessary OAuth2 credentials to outgoing requests to
    // perform GitHub API calls.
    *http.Client
}

func GetSession Uses

func GetSession(ctx context.Context) (*Session, bool)

GetSession returns data about the logged-in user given the Context provided to a ContextHandler.

Package githubauth imports 10 packages (graph) and is imported by 1 packages. Updated 2018-05-22. Refresh now. Tools for package owners.