gitserver

package module
v0.0.0-...-216dd6c Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2016 License: MIT Imports: 9 Imported by: 0

README

gitserver

Build Status codecov

Documentation

Index

Constants

View Source
const (
	CookieName = "gitserver-session"
)

Variables

View Source
var ErrSessionCookieNotFound = errors.New("Session cookie not found")
View Source
var ErrUserNotFound = errors.New("User not found")

Functions

func Setup

func Setup(serveMux *http.ServeMux, config Config, userStore UserStore, ctxProvider ContextProvider, logger ContextAwareLogger)

Types

type Config

type Config struct {
	URLPathToLogin     string
	URLPathToLogout    string
	LoginRedirectURL   string
	LogoutRedirectURL  string
	NewUserRedirectURL string
	Audiences          []string
	SessionDuration    int
	SecureCookies      bool
}

type ContextAwareLogger

type ContextAwareLogger interface {
	//Debug(ctx context.Context, message string)
	Debugf(ctx context.Context, format string, v ...interface{})

	//Info(ctx context.Context, message string)
	Infof(ctx context.Context, format string, v ...interface{})

	//Error(ctx context.Context, message string)
	Errorf(ctx context.Context, format string, v ...interface{})
}

type ContextProvider

type ContextProvider interface {
	ContextFromRequest(req *http.Request) context.Context
}

type GitTokenExtractor

type GitTokenExtractor struct {
}

func (*GitTokenExtractor) ExtractToken

func (*GitTokenExtractor) ExtractToken(req *http.Request, ctx context.Context, audience []string) (*gitkit.Token, error)

type Login

type Login struct {
	// contains filtered or unexported fields
}

func NewLogin

func NewLogin(userStore UserStore, config Config, ctxProvider ContextProvider, logger ContextAwareLogger, tokenExtractor TokenExtractor) *Login

func (*Login) LoginHandler

func (l *Login) LoginHandler(res http.ResponseWriter, req *http.Request)

func (*Login) LogoutHandler

func (l *Login) LogoutHandler(res http.ResponseWriter, req *http.Request)

type Session

type Session struct {
	Value   string
	Expires time.Time
}

type SessionCookie

type SessionCookie struct {
	UserID    string
	SessionID string
}

func SessionCookieFromCookie

func SessionCookieFromCookie(cookie *http.Cookie) (SessionCookie, error)

type TokenExtractor

type TokenExtractor interface {
	ExtractToken(req *http.Request, ctx context.Context, audience []string) (*gitkit.Token, error)
}

type User

type User struct {
	ID    string
	Email string
	//There are some concerns here about thread safety
	Sessions []Session
}

Perhaps this should be an interface instead?

func AuthorizedUser

func AuthorizedUser(req *http.Request) (*User, error)

type UserStore

type UserStore interface {
	UpdateUser(ctx context.Context, user *User) error
	LookupUser(ctx context.Context, id string) (*User, error)
}

type UserStoreErr

type UserStoreErr struct {
	Cause string
}

func NewUserStoreErr

func NewUserStoreErr(cause string) UserStoreErr

func (UserStoreErr) Error

func (err UserStoreErr) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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