Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultSMTPSendEmail(addr string, a smtp.Auth, from string, to []string, msg []byte) error
- func DomainChecker(res http.ResponseWriter, tokens oauth2.Tokens)
- func InitRoutes(m *martini.ClassicMartini, redisConn func() Doer, ...)
- func InitSession(m *martini.ClassicMartini, rc redisCreds)
- type AuthDeleteHandler
- type AuthGetHandler
- type AuthPostHandler
- type AuthPutHandler
- type AuthRequestCreator
- type Controller
- func NewAuthKeyV1(kg KeyGenerator) Controller
- func NewMeController() Controller
- func NewOrgController(get pezdispenser.MongoCollectionGetter, authClient AuthRequestCreator) Controller
- func NewPcfaasController(invClient *integrations.MyInventoryClient) Controller
- func NewSandBoxController() Controller
- func NewValidateV1(kg KeyGenerator) Controller
- type Doer
- type EmailServer
- type GUIDMake
- type GUIDMaker
- type KeyGen
- type KeyGenerator
- type MeGetHandler
- type OrgGetHandler
- type OrgManager
- type OrgPutHandler
- type PcfaasGetInventoryHandler
- type PcfaasPostInventoryHandler
- type PivotOrg
- type Response
- type SMTPData
- type SandBoxPostHandler
- type SendMailFunc
- type Sender
- type UserMatch
- type ValidateGetHandler
Constants ¶
const ( //FailureStatus - failure response status from our unauthenticated rest endpoints FailureStatus = 403 //SuccessStatus - success response status from our authenticated rest endpoints SuccessStatus = 200 //ServerErrorStatus - HTTP 500 - something blew up when servicing the request. ServerErrorStatus = 500 //HMFieldActive - name of metadata hash field containing active status HMFieldActive = "active" //HMFieldDetails - name of metadata hash field containing user and key details HMFieldDetails = "details" //EmailFieldName - fieldname for email EmailFieldName = "email" //GUIDLength - length of valid key GUIDLength = 36 //HeaderKeyName - header keyname for api-key value HeaderKeyName = "X-API-KEY" //ErrInvalidKeyFormatMsg - error msg for invalid key ErrInvalidKeyFormatMsg = "Invalid key format" //DefaultSpaceName - default space name created for each org DefaultSpaceName = "development" //SMTPTemplate template to generate smtp data SMTPTemplate = `From: {{.From}} To: {{.To}} Subject: {{.Subject}} {{.Body}} ` )
Constants to construct my oauth calls
const ( UserParam = "user" APIVersion1 = "v1" AuthGroup = "auth" OrgGroup = "org" APIKeys = "/api-keys" ValidKeyCheck = "/valid-key" StaticPath = "public" InventoryItemParam = "invitem" )
Constants to construct routes with
const BODY = `To whom it may concern:
I am requesting a PEZ Sandbox environment.
My info:
%s
%s
Thank you.
`
BODY - Email body for sandbox request
const SUBJECT = "Pez Request: Sandbox"
SUBJECT - Email subject for sandbox request
Variables ¶
var ( ClientID string ClientSecret string ErrCouldNotGetUserGUID = errors.New("query failed. unable to find matching user guid.") //Vars for my oauth calls Scopes = []string{"https://www.googleapis.com/auth/plus.me", "https://www.googleapis.com/auth/userinfo.email"} AuthFailureResponse = []byte(`{"error": "not logged in as a valid user, or the access token is expired"}`) OauthConfig *goauth2.Config //Authentication Handler vars ErrInvalidCallerEmail = errors.New("Invalid user token for your requested action") //ErrUnparsableHash - an error for a hash that is not formed properly ErrUnparsableHash = errors.New("Could not parse the hash or hash was nil") //ErrEmptyKeyResponse - an error for a invalid or empty key ErrEmptyKeyResponse = errors.New("The key could not be found or was not valid") //ErrCanNotCreateOrg - error when we can not create an org ErrCanNotCreateOrg = errors.New("Could not create a new org") //ErrCantCallAcrossUsers - error when a user is trying to update a user record other than their own ErrCantCallAcrossUsers = errors.New("user calling another users endpoint") //UserMatch exported vars ErrNotValidActionForUser = errors.New("not a valid user to perform this action") )
var ( APIKey = fmt.Sprintf("/api-key/:%s", UserParam) OrgUser = fmt.Sprintf("/user/:%s", UserParam) URLAuthBaseV1 = fmt.Sprintf("/%s/%s", APIVersion1, AuthGroup) URLOrgBaseV1 = fmt.Sprintf("/%s/%s", APIVersion1, OrgGroup) LeaseURL = fmt.Sprintf("/pcfaas/inventory/:%s", InventoryItemParam) )
formatted strings based on constants, to be used in URLs
var DomainCheck = func() martini.Handler { return DomainChecker }()
DomainCheck - a handler to check if we are in a valid domain
var GetUserInfo = func(tokens oauth2.Tokens) (userObject map[string]interface{}) { if userObject = getUserInfoCached(tokens); len(userObject) == 0 { userObject = getUserInfo(tokens) } return }
GetUserInfo - query googleapi for the authenticated users information
var NewOrg = func(username string, log *log.Logger, tokens oauth2.Tokens, store pezdispenser.Persistence, authClient AuthRequestCreator) OrgManager { s := &orgManager{ username: username, log: log, tokens: tokens, store: store, cfClient: cloudfoundryclient.NewCloudFoundryClient(authClient, log), } return s }
NewOrg - creates a new org manager
Functions ¶
func DefaultSMTPSendEmail ¶ added in v0.0.121
DefaultSMTPSendEmail - This is the default SMTP server send email behavior There are some issue with the smtp ssl certificate Reimplementing the http://golang.org/src/net/smtp/smtp.go?s=7610:7688#L263 Will switch back to the default smtp.SendMail function
func DomainChecker ¶
func DomainChecker(res http.ResponseWriter, tokens oauth2.Tokens)
DomainChecker - check the authenticated users domain to see if it is in the whitelist
func InitRoutes ¶
func InitRoutes(m *martini.ClassicMartini, redisConn func() Doer, mongoConn pezdispenser.MongoCollectionGetter, authClient AuthRequestCreator, invClient *integrations.MyInventoryClient)
InitRoutes - initialize the mappings for controllers against valid routes
func InitSession ¶
func InitSession(m *martini.ClassicMartini, rc redisCreds)
InitSession - initializes authentication middleware for controllers
Types ¶
type AuthDeleteHandler ¶
type AuthDeleteHandler func(params martini.Params, log *log.Logger, r render.Render, tokens oauth2.Tokens)
AuthDeleteHandler - auth control handler for delete calls
type AuthGetHandler ¶
type AuthGetHandler func(params martini.Params, log *log.Logger, r render.Render, tokens oauth2.Tokens)
AuthGetHandler - auth control handler for get calls
type AuthPostHandler ¶
type AuthPostHandler func(params martini.Params, log *log.Logger, r render.Render, tokens oauth2.Tokens)
AuthPostHandler - auth control handler for post calls
type AuthPutHandler ¶
type AuthPutHandler func(params martini.Params, log *log.Logger, r render.Render, tokens oauth2.Tokens)
AuthPutHandler - auth control handler for put calls
type AuthRequestCreator ¶ added in v0.0.81
type AuthRequestCreator interface { CreateAuthRequest(verb, requestURL, path string, args interface{}) (*http.Request, error) CCTarget() string HttpClient() ccclient.ClientDoer Login() (*ccclient.Client, error) }
AuthRequestCreator - interface to an object which can decorate a request with auth tokens
type Controller ¶
type Controller interface { Put() interface{} Post() interface{} Get() interface{} Delete() interface{} }
Controller - interface of a base controller
func NewAuthKeyV1 ¶
func NewAuthKeyV1(kg KeyGenerator) Controller
NewAuthKeyV1 - get an instance of a V1 authkey controller
func NewMeController ¶
func NewMeController() Controller
NewMeController - a controller for me requests
func NewOrgController ¶
func NewOrgController(get pezdispenser.MongoCollectionGetter, authClient AuthRequestCreator) Controller
NewOrgController - a controller for me requests
func NewPcfaasController ¶ added in v0.0.141
func NewPcfaasController(invClient *integrations.MyInventoryClient) Controller
NewPcfaasController - a controller for inventory requests
func NewSandBoxController ¶ added in v0.0.121
func NewSandBoxController() Controller
NewSandBoxController - Create a Sandbox controller instance
func NewValidateV1 ¶
func NewValidateV1(kg KeyGenerator) Controller
NewValidateV1 - create a validation controller
type EmailServer ¶ added in v0.0.121
type EmailServer struct {
// contains filtered or unexported fields
}
EmailServer - email server pez auth use to send email
func NewEmailServer ¶ added in v0.0.121
func NewEmailServer(host string, port int, auth smtp.Auth, sendMailFunc SendMailFunc) *EmailServer
NewEmailServer - Create an email server
func NewEmailServerFromService ¶ added in v0.0.121
func NewEmailServerFromService(appEnv *cfenv.App) *EmailServer
NewEmailServerFromService - construct email server from vCap Service
func (*EmailServer) GetSupportEmail ¶ added in v0.0.121
func (emailServer *EmailServer) GetSupportEmail() string
GetSupportEmail - retrieve the support email address
func (*EmailServer) SendEmail ¶ added in v0.0.121
func (emailServer *EmailServer) SendEmail(data *SMTPData) error
SendEmail - send email
type GUIDMaker ¶
type GUIDMaker interface {
Create() string
}
GUIDMaker - interface for a guid maker
type KeyGen ¶
type KeyGen struct {
// contains filtered or unexported fields
}
KeyGen - and implementation of the KeyGenerator interface
type KeyGenerator ¶
type KeyGenerator interface { Get(user string) (string, error) GetByKey(key string) (hash string, val interface{}, err error) Create(user, details string) error Delete(user string) error }
KeyGenerator - interface to work with apikeys
func NewKeyGen ¶
func NewKeyGen(doer func() Doer, guid GUIDMaker) KeyGenerator
NewKeyGen - create a new implementation of a KeyGenerator interface
type MeGetHandler ¶
MeGetHandler - a get control handler for me requests
type OrgGetHandler ¶
type OrgGetHandler func(params martini.Params, log *log.Logger, r render.Render, tokens oauth2.Tokens)
OrgGetHandler - func signature of org get handler
type OrgManager ¶ added in v0.0.81
type OrgManager interface { Show() (result *PivotOrg, err error) SafeCreate() (record *PivotOrg, err error) }
OrgManager - interface to the org creation functionality
type OrgPutHandler ¶
type OrgPutHandler func(params martini.Params, log *log.Logger, r render.Render, tokens oauth2.Tokens)
OrgPutHandler - func signature of org put handler
type PcfaasGetInventoryHandler ¶ added in v0.0.141
PcfaasGetInventoryHandler - a get control handler for pcfaas inventory requests
type PcfaasPostInventoryHandler ¶ added in v0.0.158
type PcfaasPostInventoryHandler func(params martini.Params, log *log.Logger, r render.Render, tokens oauth2.Tokens)
PcfaasPostInventoryHandler - a post control handler for pcaas inventory lease requests
type SandBoxPostHandler ¶ added in v0.0.121
SandBoxPostHandler Post Email send
type SendMailFunc ¶ added in v0.0.121
SendMailFunc - Function to wrap the smtp SendMail behavior
type UserMatch ¶
type UserMatch struct {
// contains filtered or unexported fields
}
UserMatch - an object used to check if a user is updating the records on a user key they are able to access
func NewUserMatch ¶
func NewUserMatch() *UserMatch
NewUserMatch - creates a new usermatch struct pointer