controllers

package
v1.13.3 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2017 License: CC0-1.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitApp

func InitApp(envVars helpers.EnvVars, env *cfenv.App) (*web.Router, *helpers.Settings, error)

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 *template.Template) *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.

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) Logout

func (c *APIContext) Logout(rw web.ResponseWriter, req *web.Request)

Logout is a handler that will attempt to clear the session information for the current user.

func (*APIContext) UserProfile

func (c *APIContext) UserProfile(rw web.ResponseWriter, req *web.Request)

UserProfile redirects users to the `/profile` page

type Context

type Context struct {
	Settings *helpers.Settings
	// contains filtered or unexported fields
}

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) LoginRequired

func (c *Context) LoginRequired(rw web.ResponseWriter, r *web.Request, next web.NextMiddlewareFunc)

LoginRequired is a middleware that requires a valid toker or redirects to the handshake page.

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.

func (*Context) Ping

func (c *Context) Ping(rw web.ResponseWriter, req *web.Request)

Ping is just a test endpoint to show that indeed the service is alive. TODO. Remove.

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 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

type SecureContext struct {
	*Context // Required.
	Token    oauth2.Token
}

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) OAuth

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) 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) UserInfo

func (c *UAAContext) UserInfo(rw web.ResponseWriter, req *web.Request)

UserInfo returns the UAA_API/userinfo information for the logged in user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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