auth

package
v0.75.0-no-limit Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2016 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OAuthBegin    = "OAuthBegin"
	OAuthCallback = "OAuthCallback"
)
View Source
const CookieAge = 24 * time.Hour
View Source
const CookieName = "ATC-Authorization"
View Source
const OAuthStateCookie = "_concourse_oauth_state"
View Source
const TokenTypeBearer = "Bearer"

Variables

View Source
var ErrUnparsableHeader = errors.New("cannot parse 'Authorization' header")
View Source
var OAuthRoutes = rata.Routes{
	{Path: "/auth/:provider", Method: "GET", Name: OAuthBegin},
	{Path: "/auth/:provider/callback", Method: "GET", Name: OAuthCallback},
}
View Source
var SigningMethod = jwt.SigningMethodRS256

Functions

func CheckAuthHandler

func CheckAuthHandler(
	handler http.Handler,
	rejector Rejector,
) http.Handler

func GetTeam

func GetTeam(r *http.Request) (string, int, bool, bool)

func IsAuthenticated

func IsAuthenticated(r *http.Request) bool

func NewOAuthBeginHandler

func NewOAuthBeginHandler(
	logger lager.Logger,
	providerFactory ProviderFactory,
	privateKey *rsa.PrivateKey,
) http.Handler

func NewOAuthCallbackHandler

func NewOAuthCallbackHandler(
	logger lager.Logger,
	providerFactory ProviderFactory,
	privateKey *rsa.PrivateKey,
	db AuthDB,
) http.Handler

func NewOAuthHandler

func NewOAuthHandler(
	logger lager.Logger,
	providerFactory ProviderFactory,
	signingKey *rsa.PrivateKey,
	db AuthDB,
) (http.Handler, error)

func WrapHandler

func WrapHandler(
	handler http.Handler,
	validator Validator,
	userContextReader UserContextReader,
) http.Handler

Types

type AuthDB

type AuthDB interface {
	GetTeamByName(teamName string) (db.SavedTeam, bool, error)
}

type BasicAuthRejector

type BasicAuthRejector struct{}

func (BasicAuthRejector) Unauthorized

func (BasicAuthRejector) Unauthorized(w http.ResponseWriter, r *http.Request)

type BasicAuthValidator

type BasicAuthValidator struct {
	DB AuthDB
}

func (BasicAuthValidator) IsAuthenticated

func (validator BasicAuthValidator) IsAuthenticated(r *http.Request) bool

IsAuthenticated basic authentication for login

type CookieSetHandler

type CookieSetHandler struct {
	Handler http.Handler
}

func (CookieSetHandler) ServeHTTP

func (handler CookieSetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type JWTReader

type JWTReader struct {
	PublicKey *rsa.PublicKey
}

func (JWTReader) GetTeam

func (jr JWTReader) GetTeam(r *http.Request) (string, int, bool, bool)

type JWTValidator

type JWTValidator struct {
	PublicKey *rsa.PublicKey
}

func (JWTValidator) IsAuthenticated

func (validator JWTValidator) IsAuthenticated(r *http.Request) bool

type NoopValidator

type NoopValidator struct{}

func (NoopValidator) IsAuthenticated

func (NoopValidator) IsAuthenticated(*http.Request) bool

type OAuthBeginHandler

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

func (*OAuthBeginHandler) ServeHTTP

func (handler *OAuthBeginHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type OAuthCallbackHandler

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

func (*OAuthCallbackHandler) ServeHTTP

func (handler *OAuthCallbackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type OAuthState

type OAuthState struct {
	Redirect string `json:"redirect"`
}

type ProviderFactory

type ProviderFactory interface {
	GetProviders(teamName string) (provider.Providers, error)
}

type RedirectRejector

type RedirectRejector struct {
	Location string
}

func (RedirectRejector) Unauthorized

func (rejector RedirectRejector) Unauthorized(w http.ResponseWriter, r *http.Request)

type Rejector

type Rejector interface {
	Unauthorized(http.ResponseWriter, *http.Request)
}

type TokenGenerator

type TokenGenerator interface {
	GenerateToken(expiration time.Time, teamName string, teamID int, isAdmin bool) (TokenType, TokenValue, error)
}

func NewTokenGenerator

func NewTokenGenerator(privateKey *rsa.PrivateKey) TokenGenerator

type TokenType

type TokenType string

type TokenValue

type TokenValue string

type UnauthorizedRejector

type UnauthorizedRejector struct{}

func (UnauthorizedRejector) Unauthorized

func (UnauthorizedRejector) Unauthorized(w http.ResponseWriter, r *http.Request)

type UserContextReader

type UserContextReader interface {
	GetTeam(r *http.Request) (string, int, bool, bool)
}

type Validator

type Validator interface {
	IsAuthenticated(*http.Request) bool
}

type ValidatorBasket

type ValidatorBasket []Validator

func (ValidatorBasket) IsAuthenticated

func (vb ValidatorBasket) IsAuthenticated(r *http.Request) bool

Directories

Path Synopsis
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
fakes
This file was generated by counterfeiter
This file was generated by counterfeiter
fakes
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter
This file was generated by counterfeiter This file was generated by counterfeiter This file was generated by counterfeiter

Jump to

Keyboard shortcuts

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