controllers

package
v0.0.0-...-b99549b Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2015 License: CC0-1.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitApp

func InitApp(envVars helpers.EnvVars) (*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) *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
}

Context represents the context for all requests that do not need authentication.

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) 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 funciton 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) PrivilegedProxy

func (c *SecureContext) PrivilegedProxy(rw http.ResponseWriter, req *http.Request, url string)

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

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

QueryUser returns select data (id and userName) about all users. Additional information can be asked for by passing it view query string. Also, specific user(s) can be looked for by using the filter attribute. (eg: "?filter=id eq 'the-id'") spaces included More info about these filters can be found here: https://github.com/cloudfoundry/uaa/blob/master/docs/UAA-APIs.rst#query-for-information-get-users This function converts a POST request to a GET Request to prevent this: http://stackoverflow.com/questions/17303940/security-sending-email-address-in-a-url-parameter The payload of the POST request will be the filters to append to GET request. Basic format of payload

{
	filter01: value01,
	filter02, value02,
	..
	filterN, valueN
}

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