Documentation ¶
Index ¶
- func GetClientIP(req *http.Request) (string, error)
- func InitApp(envVars *env.VarSet) (*web.Router, *helpers.Settings, error)
- func InitRouter(settings *helpers.Settings, templates *helpers.Templates, mailer mailer.Mailer) *web.Router
- func StaticMiddleware(path string) func(web.ResponseWriter, *web.Request, web.NextMiddlewareFunc)
- type APIContext
- type Context
- func (c *Context) Index(w web.ResponseWriter, r *web.Request)
- func (c *Context) LoginHandshake(rw web.ResponseWriter, req *web.Request)
- func (c *Context) Logout(rw web.ResponseWriter, req *web.Request)
- func (c *Context) OAuthCallback(rw web.ResponseWriter, req *web.Request)
- func (c *Context) Ping(rw web.ResponseWriter, req *web.Request)
- type GetUAAUserResponse
- type InviteUAAUserResponse
- type InviteUserToOrgRequest
- type ListUAAUserResponse
- type LogContext
- type NewInvite
- type ResponseHandler
- type SecureContext
- func (c *SecureContext) GenericResponseHandler(rw http.ResponseWriter, response *http.Response)
- func (c *SecureContext) LoginRequired(rw web.ResponseWriter, r *web.Request, next web.NextMiddlewareFunc)
- func (c *SecureContext) OAuth(rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc)
- func (c *SecureContext) PrivilegedProxy(rw http.ResponseWriter, req *http.Request, url string, ...)
- func (c *SecureContext) Proxy(rw http.ResponseWriter, req *http.Request, url string, ...)
- type UAAContext
- func (c *UAAContext) CreateCFuser(userInvite NewInvite) (err *UaaError)
- func (c *UAAContext) GetUAAUserByEmail(email string) (userResponse GetUAAUserResponse, err *UaaError)
- func (c *UAAContext) InviteUAAuser(inviteUserToOrgRequest InviteUserToOrgRequest) (inviteResponse InviteUAAUserResponse, err *UaaError)
- func (c *UAAContext) InviteUserToOrg(rw web.ResponseWriter, req *web.Request)
- func (c *UAAContext) ParseInviteUserToOrgReq(req *http.Request) (inviteUserToOrgRequest InviteUserToOrgRequest, err *UaaError)
- func (c *UAAContext) TriggerInvite(inviteReq inviteEmailRequest) *UaaError
- func (c *UAAContext) UaaInfo(rw web.ResponseWriter, req *web.Request)
- func (c *UAAContext) UserInfo(rw web.ResponseWriter, req *web.Request)
- type UaaError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetClientIP ¶
GetClientIP gets a Client IP address from either X-Forwarded-For or RemoteAddr
func InitApp ¶
InitApp takes in envars and sets up the router and settings that will be used for the unstarted server.
func InitRouter ¶
func InitRouter(settings *helpers.Settings, templates *helpers.Templates, mailer mailer.Mailer) *web.Router
InitRouter sets up the router (and subrouters). It also includes the closure middleware where we load the global Settings reference into each request.
func StaticMiddleware ¶
func StaticMiddleware(path string) func(web.ResponseWriter, *web.Request, web.NextMiddlewareFunc)
StaticMiddleware provides simple caching middleware for static assets.
Types ¶
type APIContext ¶
type APIContext struct {
*SecureContext // Required.
}
APIContext stores the session info and access token per user. All routes within APIContext represent the API routes
func (*APIContext) APIProxy ¶
func (c *APIContext) APIProxy(rw web.ResponseWriter, req *web.Request)
APIProxy is a handler that serves as a proxy for all the CF API. Any route that comes in the /v2/* route that has not been specified, will just come here.
func (*APIContext) AuthStatus ¶
func (c *APIContext) AuthStatus(rw web.ResponseWriter, req *web.Request)
AuthStatus simply returns authorized. This endpoint is just a quick endpoint to indicate that if a user can reach here after passing through the OAuth Middleware, they are authorized.
func (*APIContext) UserProfile ¶
func (c *APIContext) UserProfile(rw web.ResponseWriter, req *web.Request)
UserProfile redirects users to the `/profile` page
type Context ¶
Context represents the context for all requests that do not need authentication.
func (*Context) Index ¶
func (c *Context) Index(w web.ResponseWriter, r *web.Request)
Index serves index.html
func (*Context) LoginHandshake ¶
func (c *Context) LoginHandshake(rw web.ResponseWriter, req *web.Request)
LoginHandshake is the handler where we authenticate the user and the user authorizes this application access to information.
func (*Context) Logout ¶
func (c *Context) Logout(rw web.ResponseWriter, req *web.Request)
Logout is a handler that will attempt to clear the session information for the current user.
func (*Context) OAuthCallback ¶
func (c *Context) OAuthCallback(rw web.ResponseWriter, req *web.Request)
OAuthCallback is the function that is called when the UAA provider uses the "redirect_uri" field to call back to this backend. This function will extract the code, get the access token and refresh token and save it into 1) the session and redirect to the frontend dashboard.
type GetUAAUserResponse ¶
type GetUAAUserResponse struct { Active bool `json:"active"` Verified bool `json:"verified"` ID string `json:"id"` ExternalID string `json:"externalId"` }
GetUAAUserResponse is the expected form of a response from querying UAA for a specific user. It is only a partial representation.
type InviteUAAUserResponse ¶
type InviteUAAUserResponse struct {
NewInvites []NewInvite `json:"new_invites"`
}
InviteUAAUserResponse is the expected form of a response from invite users to UAA.
type InviteUserToOrgRequest ¶
type InviteUserToOrgRequest struct {
Email string `json:"email"`
}
InviteUserToOrgRequest contains the JSON structure for the invite users request data.
type ListUAAUserResponse ¶
type ListUAAUserResponse struct {
Resources []GetUAAUserResponse `json:"resources"`
}
ListUAAUserResponse is the response representation of the User list query. https://docs.cloudfoundry.org/api/uaa/#list63
type LogContext ¶
type LogContext struct {
*SecureContext // Required.
}
LogContext stores the session info and access token per user. All routes within LogContext represent the Loggregator routes
func (*LogContext) ParseLogMessages ¶
func (c *LogContext) ParseLogMessages(body *io.ReadCloser, contentType string) (*bytes.Buffer, error)
ParseLogMessages is a modified version of httpRecent. https://github.com/cloudfoundry/loggregator_consumer/blob/89d7fe237afae1e8222554359ec03b72c8466d10/consumer.go#L145 Also, when using their Recent function, we would get unauthorized errors. If we make the request ourselves, it works. TODO eventually figure out the cause of the unauthorized errors
func (*LogContext) RecentLogs ¶
func (c *LogContext) RecentLogs(rw web.ResponseWriter, req *web.Request)
RecentLogs returns a log dump of the given app.
type NewInvite ¶
type NewInvite struct { UserID string `json:"userId"` Email string `json:"email"` InviteLink string `json:"inviteLink"` }
NewInvite is the contains detailed information about an single successful user invite to UAA.
type ResponseHandler ¶
type ResponseHandler func(http.ResponseWriter, *http.Response)
ResponseHandler is a type declaration for the function that will handle the response for the given request.
type SecureContext ¶
SecureContext stores the session info and access token per user.
func (*SecureContext) GenericResponseHandler ¶
func (c *SecureContext) GenericResponseHandler(rw http.ResponseWriter, response *http.Response)
GenericResponseHandler is a normal handler for responses received from the proxy requests.
func (*SecureContext) LoginRequired ¶
func (c *SecureContext) LoginRequired(rw web.ResponseWriter, r *web.Request, next web.NextMiddlewareFunc)
LoginRequired is a middleware that requires a valid token or returns Unauthorized
func (*SecureContext) OAuth ¶
func (c *SecureContext) OAuth(rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc)
OAuth is a middle ware that checks whether or not the user has a valid token. If the token is present and still valid, it just passes it on. If the token is 1) present and expired or 2) not present, it will return unauthorized.
func (*SecureContext) PrivilegedProxy ¶
func (c *SecureContext) PrivilegedProxy(rw http.ResponseWriter, req *http.Request, url string, responseHandler ResponseHandler)
PrivilegedProxy is an internal function that will construct the client using the credentials of the web app itself (not of the user) with the token in the headers and then sends a request.
func (*SecureContext) Proxy ¶
func (c *SecureContext) Proxy(rw http.ResponseWriter, req *http.Request, url string, responseHandler ResponseHandler)
Proxy is an internal function that will construct the client with the token in the headers and then send a request.
type UAAContext ¶
type UAAContext struct {
*SecureContext // Required.
}
UAAContext stores the session info and access token per user. All routes within UAAContext represent the routes to the UAA service.
func (*UAAContext) CreateCFuser ¶
func (c *UAAContext) CreateCFuser(userInvite NewInvite) ( err *UaaError)
CreateCFuser will use the UAA user guid and create the user in the CF database.
func (*UAAContext) GetUAAUserByEmail ¶
func (c *UAAContext) GetUAAUserByEmail(email string) ( userResponse GetUAAUserResponse, err *UaaError)
GetUAAUserByEmail will query UAA for user(s) by e-mail. Only return one user result. Special cases: If multiple are found, an empty response is returned. If none are found, an empty response is returned. Both special cases return no error.
func (*UAAContext) InviteUAAuser ¶
func (c *UAAContext) InviteUAAuser(inviteUserToOrgRequest InviteUserToOrgRequest) (inviteResponse InviteUAAUserResponse, err *UaaError)
InviteUAAuser tries to invite the user e-mail which will create the user in the UAA database.
func (*UAAContext) InviteUserToOrg ¶
func (c *UAAContext) InviteUserToOrg(rw web.ResponseWriter, req *web.Request)
InviteUserToOrg will invite user in both UAA and CF, send an e-mail.
func (*UAAContext) ParseInviteUserToOrgReq ¶
func (c *UAAContext) ParseInviteUserToOrgReq(req *http.Request) ( inviteUserToOrgRequest InviteUserToOrgRequest, err *UaaError)
ParseInviteUserToOrgReq will return InviteUserToOrgRequest based on the data in the request body.
func (*UAAContext) TriggerInvite ¶
func (c *UAAContext) TriggerInvite(inviteReq inviteEmailRequest) *UaaError
TriggerInvite trigger the email.
func (*UAAContext) UaaInfo ¶
func (c *UAAContext) UaaInfo(rw web.ResponseWriter, req *web.Request)
UaaInfo returns the UAA_API/Users/:id information for the logged in user.
func (*UAAContext) UserInfo ¶
func (c *UAAContext) UserInfo(rw web.ResponseWriter, req *web.Request)
UserInfo returns the UAA_API/userinfo information for the logged in user.