http

package
v2.2.0-preview.5.4+inc... Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: CC0-1.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const SessionCookieName = "eapp-session-key"

SessionCookieName is the name of the cookie that is used to store the session

Variables

View Source
var (
	// APIName ...
	APIName = "eqip"

	// APIVersion ...
	APIVersion = "v1"
)
View Source
var (
	// TransportLayerSecurity is the TLS configuration settings for a HTTPS server.
	TransportLayerSecurity = &tls.Config{
		MinVersion: tls.VersionTLS12,
		CurvePreferences: []tls.CurveID{
			tls.CurveP521,
			tls.CurveP384,
			tls.CurveP256,
		},
		PreferServerCipherSuites: true,
		CipherSuites: []uint16{
			tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
			tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
			tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
			tls.TLS_RSA_WITH_AES_256_CBC_SHA,
		},
	}
)

Functions

func AccountAndSessionFromRequestContext

func AccountAndSessionFromRequestContext(r *http.Request) (api.Account, api.Session)

AccountAndSessionFromRequestContext gets the reference to the Account stored in the request.Context()

func AddCSRFTokenHeader

func AddCSRFTokenHeader(w http.ResponseWriter, r *http.Request)

AddCSRFTokenHeader adds the current token header to the response

func DecodeJSON

func DecodeJSON(r io.Reader, v interface{}) error

DecodeJSON decodes a request body to the specified interface

func DeleteSessionCookie

func DeleteSessionCookie(w http.ResponseWriter)

DeleteSessionCookie removes the session cookie

func EncodeErrJSON

func EncodeErrJSON(w http.ResponseWriter, errors interface{}) error

EncodeErrJSON will return an error in JSON format.

func EncodeJSON

func EncodeJSON(w http.ResponseWriter, data interface{}) error

EncodeJSON encodes any object and writes it to a response writer

func Error

func Error(w http.ResponseWriter, r *http.Request, err error)

Error renders http error information.

func RespondWithErrors

func RespondWithErrors(w http.ResponseWriter, errors structuredErrors, code int)

RespondWithErrors writes an error code and a json error response from structuredErrors

func RespondWithStructuredError added in v1.0.8

func RespondWithStructuredError(w http.ResponseWriter, errorMessage string, code int)

RespondWithStructuredError writes an error code and a json error response

func SetAccountAndSessionInRequestContext

func SetAccountAndSessionInRequestContext(r *http.Request, account api.Account, session api.Session) context.Context

SetAccountAndSessionInRequestContext modifies the request's Context() to add the Account

Types

type AttachmentDeleteHandler

type AttachmentDeleteHandler struct {
	Env      api.Settings
	Log      api.LogService
	Database api.DatabaseService
	Store    api.StorageService
}

AttachmentDeleteHandler is the handler for deleting attachments.

func (AttachmentDeleteHandler) ServeHTTP

func (service AttachmentDeleteHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves the HTTP response.

type AttachmentGetHandler

type AttachmentGetHandler struct {
	Env      api.Settings
	Log      api.LogService
	Database api.DatabaseService
	Store    api.StorageService
}

AttachmentGetHandler is the handler for getting attachments.

func (AttachmentGetHandler) ServeHTTP

func (service AttachmentGetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves the HTTP response.

type AttachmentListHandler

type AttachmentListHandler struct {
	Env      api.Settings
	Log      api.LogService
	Database api.DatabaseService
	Store    api.StorageService
}

AttachmentListHandler is the handler for listing attachments.

func (AttachmentListHandler) ServeHTTP

func (service AttachmentListHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves the HTTP response.

type AttachmentSaveHandler

type AttachmentSaveHandler struct {
	Env      api.Settings
	Log      api.LogService
	Database api.DatabaseService
	Store    api.StorageService
}

AttachmentSaveHandler is the handler for saving attachments.

func (AttachmentSaveHandler) ServeHTTP

func (service AttachmentSaveHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves the HTTP response.

type BasicAuthHandler

type BasicAuthHandler struct {
	Env      api.Settings
	Log      api.LogService
	Database api.DatabaseService
	Store    api.StorageService
	Session  api.SessionService
	Cookie   SessionCookieService
}

BasicAuthHandler is the handler for basic authentication.

func (BasicAuthHandler) ServeHTTP

func (service BasicAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP processes a users request to login with a Username and Password

type CORSHandler

type CORSHandler struct {
	Log api.LogService
	Env api.Settings
}

CORSHandler is the handler for CORS.

func (CORSHandler) Middleware

func (service CORSHandler) Middleware(next http.Handler) http.Handler

Middleware wraps an http handler with logic to handle cors requests. Specifies the allowed origins, methods and headers.

type CSRFMiddleware

type CSRFMiddleware struct {
	// contains filtered or unexported fields
}

CSRFMiddleware is a middleware that uses gorilla/csrf to protect all state changing operations from CSRF attacks.

func NewCSRFMiddleware

func NewCSRFMiddleware(log api.LogService, authKey []byte, useSecureCookie bool) (*CSRFMiddleware, error)

NewCSRFMiddleware returns a configured CSRFMiddleware

func (CSRFMiddleware) Middleware

func (m CSRFMiddleware) Middleware(next http.Handler) http.Handler

Middleware for verifying the CSRF token

type CacheHandler

type CacheHandler struct {
	Log api.LogService
}

CacheHandler implements the cache settings on web responses.

func (CacheHandler) Middleware

func (service CacheHandler) Middleware(next http.Handler) http.Handler

Middleware applies cache headers to the response.

type FormHandler

type FormHandler struct {
	Env      api.Settings
	Log      api.LogService
	Database api.DatabaseService
	Store    api.StorageService
}

FormHandler is the handler for the form.

func (FormHandler) ServeHTTP

func (service FormHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP will return a JSON object of all currently saved application information specifict to the account.

type LoggingHandler

type LoggingHandler struct {
	Log api.LogService
}

LoggingHandler is the handler for logging.

func (LoggingHandler) Middleware

func (service LoggingHandler) Middleware(next http.Handler) http.Handler

Middleware for standard logging.

type LogoutHandler

type LogoutHandler struct {
	Log     api.LogService
	Session api.SessionService
}

LogoutHandler is the handler for logging out of a session.

func (LogoutHandler) ServeHTTP

func (service LogoutHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP will end the user session.

type RefreshHandler

type RefreshHandler struct {
	Env      api.Settings
	Log      api.LogService
	Database api.DatabaseService
}

RefreshHandler is the handler for refreshing the session

func (RefreshHandler) ServeHTTP

func (service RefreshHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP refreshes a given token.

type RootHandler

type RootHandler struct {
	Env api.Settings
}

RootHandler is the handler for the root endpoint.

func (RootHandler) ServeHTTP

func (service RootHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP accepts GET requests to get all endpoints that the API supports.

type SamlRequestHandler

type SamlRequestHandler struct {
	Env      api.Settings
	Log      api.LogService
	Database api.DatabaseService
	SAML     api.SamlService
}

SamlRequestHandler is the handler for creating a SAML request.

func (SamlRequestHandler) ServeHTTP

func (service SamlRequestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is the initial entry point for authentication.

type SamlResponseHandler

type SamlResponseHandler struct {
	Env      api.Settings
	Log      api.LogService
	Database api.DatabaseService
	SAML     api.SamlService
	Session  api.SessionService
	Cookie   SessionCookieService
}

SamlResponseHandler is the callback handler for both login and logout SAML Responses.

func (SamlResponseHandler) ServeHTTP

func (service SamlResponseHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is the callback handler for both login and logout SAML Responses.

type SamlSLORequestHandler added in v1.0.8

type SamlSLORequestHandler struct {
	Env      api.Settings
	Log      api.LogService
	Database api.DatabaseService
	SAML     api.SamlService
	Session  api.SessionService
}

SamlSLORequestHandler is the handler for creating a SAML Logout request

func (SamlSLORequestHandler) ServeHTTP added in v1.0.8

func (service SamlSLORequestHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP is the initial entry point for authentication.

type SaveHandler

type SaveHandler struct {
	Env      api.Settings
	Log      api.LogService
	Database api.DatabaseService
	Store    api.StorageService
}

SaveHandler is the handler for saving the application.

func (SaveHandler) ServeHTTP

func (service SaveHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP saves a payload of information for the provided account.

type SecurityHandler

type SecurityHandler struct {
	Log api.LogService
	Env api.Settings
}

SecurityHandler implements the security related settings on web responses.

func (SecurityHandler) Middleware

func (service SecurityHandler) Middleware(next http.Handler) http.Handler

Middleware applies security-related headers to the response.

type Server

type Server struct {
	Env api.Settings
	Log api.LogService
}

Server is a HTTP/HTTPS server implementation.

func (Server) ListenAndServe

func (service Server) ListenAndServe(address string, router http.Handler) error

ListenAndServe will bind to the host address and port and serve the content.

type SessionCookieService

type SessionCookieService struct {
	// contains filtered or unexported fields
}

SessionCookieService writes session cookies to a response

func NewSessionCookieService

func NewSessionCookieService(secure bool) SessionCookieService

NewSessionCookieService returns a SessionCookieService

func (SessionCookieService) AddSessionKeyToResponse

func (s SessionCookieService) AddSessionKeyToResponse(w http.ResponseWriter, sessionKey string)

AddSessionKeyToResponse adds the session cookie to a response given a valid sessionKey

type SessionMiddleware

type SessionMiddleware struct {
	// contains filtered or unexported fields
}

SessionMiddleware is the session handler.

func NewSessionMiddleware

func NewSessionMiddleware(log api.LogService, session api.SessionService) *SessionMiddleware

NewSessionMiddleware returns a configured SessionMiddleware

func (SessionMiddleware) Middleware

func (service SessionMiddleware) Middleware(next http.Handler) http.Handler

Middleware for verifying session

type StatusHandler

type StatusHandler struct {
	Env      api.Settings
	Log      api.LogService
	Database api.DatabaseService
	Store    api.StorageService
}

StatusHandler is the handler for the application status.

func (StatusHandler) ServeHTTP

func (service StatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP returns the accounts current state.

type SubmitHandler

type SubmitHandler struct {
	Env       api.Settings
	Log       api.LogService
	Database  api.DatabaseService
	Store     api.StorageService
	Submitter admin.Submitter
}

SubmitHandler is the handler for submitting the application. This handler is not used in production, but is useful in development because it returns the generated XML for a submission.

func (SubmitHandler) ServeHTTP

func (service SubmitHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP submits the application package to the external web service for further processing.

type ValidateHandler

type ValidateHandler struct {
	Log api.LogService
}

ValidateHandler is the handler for validating a payload.

func (ValidateHandler) ServeHTTP

func (service ValidateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP validates if the payload pass validation procedures.

Jump to

Keyboard shortcuts

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