proxy

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IAM

type IAM interface {
	GetGroup(input *iam.GetGroupInput) (*iam.GetGroupOutput, error)
}

IAM interface holds required method signatures of IAM for easier test mocking

type Server

type Server struct {
	Addr              string
	AllowedGroups     []string
	IAM               *iam.IAM
	SecretKey         []byte
	SessionCookieName string
	Upstream          *url.URL

	GroupCachePeriod time.Duration
	// contains filtered or unexported fields
}

Server implements a simple reverse proxy server authenticating on AWS IAM

func New

func New(addr string, secretKey []byte, upstream *url.URL) *Server

New instantiates a default server

func (*Server) Health

func (s *Server) Health(w http.ResponseWriter, r *http.Request)

Health returns a successful health check

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServer starts the HTTP server. This server respects SIGINT and will gracefully shutdown.

func (*Server) Login

func (s *Server) Login(w http.ResponseWriter, r *http.Request)

login validates basic auth of username and secret+mfa on AWS IAM and sets cookie with session jwt

func (*Server) Logout

func (s *Server) Logout(w http.ResponseWriter, r *http.Request)

logout kills cookie and redirect to /

func (*Server) Proxy

func (s *Server) Proxy(w http.ResponseWriter, r *http.Request)

proxy request to upstream with net/http/httputil.SingleHostReverseProxy

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

write mainServeHTTP that validates token and route to appropriate serve method valid token: proxy to upstream. invalid token redirect to login

Jump to

Keyboard shortcuts

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