auth

package
v0.0.0-...-7fe2d08 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2016 License: Apache-2.0 Imports: 19 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 CheckAuthenticationHandler

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

func CheckAuthorizationHandler

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

func GetAuthTeamName

func GetAuthTeamName(r *http.Request) string

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,
	teamDBFactory db.TeamDBFactory,
) http.Handler

func NewOAuthHandler

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

func WrapHandler

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

Types

type AuthDB

type AuthDB interface {
	GetTeam() (db.SavedTeam, bool, error)
}

type AuthorizationResponse

type AuthorizationResponse string
const (
	Authorized   AuthorizationResponse = "authorized"
	Unauthorized AuthorizationResponse = "unauthorized"
	Forbidden    AuthorizationResponse = "forbidden"
)

func IsAuthorized

func IsAuthorized(r *http.Request) (bool, AuthorizationResponse)

type BasicAuthRejector

type BasicAuthRejector struct{}

func (BasicAuthRejector) Forbidden

func (BasicAuthRejector) Unauthorized

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

type BasicAuthValidator

type BasicAuthValidator struct {
	TeamDBFactory db.TeamDBFactory
}

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
	DevelopmentMode bool
}

func (JWTReader) GetSystem

func (jr JWTReader) GetSystem(r *http.Request) (bool, bool)

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"`
	TeamName string `json:"team_name"`
}

type ProviderFactory

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

type RedirectRejector

type RedirectRejector struct {
	Location string
}

func (RedirectRejector) Forbidden

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

func (RedirectRejector) Unauthorized

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

type Rejector

type Rejector interface {
	Unauthorized(http.ResponseWriter, *http.Request)
	Forbidden(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) Forbidden

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)
	GetSystem(r *http.Request) (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
githubfakes
This file was generated by counterfeiter
This file was generated by counterfeiter
providerfakes
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