util

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CfClient = cfclient.Client{}
)

Functions

func BasicAuth

func BasicAuth(w http.ResponseWriter, r *http.Request, username, password string) bool

BasicAuth validate if user/pass in the http request match the configured service broker user/pass

func Contains

func Contains(elems []interface{}, v string) bool

func DumpRequest

func DumpRequest(r *http.Request)

func GenerateGUID

func GenerateGUID() string

func GetAccessTokenFromRequest

func GetAccessTokenFromRequest(r *http.Request) (string, error)

GetAccessTokenFromRequest - get the JWT from the request

func GetCFClient

func GetCFClient() *cfclient.Client

func GetServiceById

func GetServiceById(serviceId string) model.Service

func IsAppBoundToSchedulerService

func IsAppBoundToSchedulerService(appguid string) bool

func IsUserAuthorisedForSpace

func IsUserAuthorisedForSpace(token jwt.Token, spaceGuid string) bool

IsUserAuthorisedForSpace - It takes the jwt, extracts the userId from it,

then queries cf (/v3/roles) to check if that user has at least developer or manager role for the give space

func IsValidJKU

func IsValidJKU(jkuURL string) bool

IsValidJKU - We compare the jku with the api hostname, only the first part should be different: like uaa.sys.cfd04.aws.rabo.cloud versus api.sys.cfd04.aws.rabo.cloud

func LastXChars

func LastXChars(victim string, maxLen int) string

func PrintIfDebug

func PrintIfDebug(msg string)

func PrintfIfDebug

func PrintfIfDebug(msg string, args ...interface{})

func ProvisionObjectFromRequest

func ProvisionObjectFromRequest(r *http.Request, object interface{}) error

func WriteHttpResponse

func WriteHttpResponse(w http.ResponseWriter, code int, object interface{})

Types

This section is empty.

Jump to

Keyboard shortcuts

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