web

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2016 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

package web implemented the web interface for usermgr

Index

Constants

This section is empty.

Variables

View Source
var NewContextFunc = func(r *http.Request) context.Context {
	return context.Background()
}

NewContextFunc is invoked to renerate the new context for a request. The default implementation uses context.Background, but when running in appengine this must be replaced with appengine.NewContext(r).

View Source
var TimeNow = time.Now

Functions

func Param

func Param(ctx context.Context, name string) string

Param returns the named URL parameter or an empty string if it is not present

Types

type Auth

type Auth interface {
	RequireUser(ctx context.Context, w http.ResponseWriter, r *http.Request) (string, error)
}

type Config

type Config struct {
	Storage     Storage
	Auth        Auth
	AdminKey    usermgr.AdminKey
	DownloadURL string
}

type FileStorage

type FileStorage struct {
	Path string
}

func (FileStorage) Get

func (fs FileStorage) Get(ctx context.Context, etag string) ([]byte, string, error)

func (FileStorage) Put

func (fs FileStorage) Put(ctx context.Context, data []byte) (string, error)

type NilAuth

type NilAuth struct {
}

func (NilAuth) RequireUser

func (na NilAuth) RequireUser(ctx context.Context, w http.ResponseWriter, r *http.Request) (string, error)

type OauthAuth

type OauthAuth struct {
	Config             oauth2.Config
	UserInfoURL        string
	EmailSuffix        string
	TokenSigningKey    []byte
	ValidateRemoteUser func(usermgr.User) (isAdmin bool, err error)
}

func (OauthAuth) HandleCallback

func (a OauthAuth) HandleCallback(ctx context.Context, w http.ResponseWriter, r *http.Request) error

func (OauthAuth) RequireUser

func (a OauthAuth) RequireUser(ctx context.Context, w http.ResponseWriter, r *http.Request) (string, error)

type OpenIDUserInfo

type OpenIDUserInfo struct {
	// Subject - Identifier for the End-User at the Issuer.
	Sub string `json:"sub"`

	// End-User's full name in displayable form including all name parts,
	// possibly including titles and suffixes, ordered according to the
	// End-User's locale and preferences.
	Name string `json:"name"`

	// End-User's preferred e-mail address. Its value MUST conform to the
	// RFC 5322 [RFC5322] addr-spec syntax. The RP MUST NOT rely upon this
	// value being unique, as discussed in Section 5.7.
	Email string `json:"email"`
}

OpenIDUserInfo is the OpenID connect user information response http://openid.net/specs/openid-connect-core-1_0.html#UserInfoResponse

type RemoteUser

type RemoteUser struct {
	Name    string
	IsAdmin bool
}

type Server

type Server struct {
	Mux         *web.Mux
	Storage     Storage
	Auth        Auth
	ContextFunc func() context.Context
	AdminKey    usermgr.AdminKey
	DownloadURL string
}

func New

func New(config Config) *Server

func (*Server) RequireUser

func (s *Server) RequireUser(ctx context.Context, w http.ResponseWriter, r *http.Request) (*RemoteUser, error)

type Storage

type Storage interface {
	Get(ctx context.Context, etag string) (data []byte, newEtag string, err error)
	Put(ctx context.Context, data []byte) (etag string, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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