auth

package
v0.0.0-...-ca671ec Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticate

func Authenticate(h http.Handler) http.Handler

Authenticate decorates "h" with github OAuth authentication.

func AuthenticateFunc

func AuthenticateFunc(h http.HandlerFunc) http.Handler

func CallbackHandler

func CallbackHandler(w http.ResponseWriter, r *http.Request)

CallbackHandler receives callback from github OAuth provider

func Enabled

func Enabled() bool

func Initialize

func Initialize(anynomous User, cookieSecret []byte)

Initialize collects server-side credential from environment variables and prepare for authentication with Github OAuth.

Client authentication is disabled and CurrentUser always returns "anonymous" if any of the environment variables are missing.

func LoginHandler

func LoginHandler(w http.ResponseWriter, r *http.Request)

LoginHandler begins github OAuth2 authentication

Types

type User

type User struct {
	// Name is the name of the user
	Name string
	// Avatar is the URL to the avatar of the user
	Avatar string
}

User is the user who the current request is on behalf of.

func CurrentUser

func CurrentUser(r *http.Request) (User, error)

CurrentUser returns the current login user of the request. It returns the default user if client authentication is disabled in the current context.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL