interfaces

package
v2.0.0-beta-001+incomp... Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthTypeOAuth2    = "OAuth2"
	AuthTypeOIDC      = "OIDC"
	AuthTypeHttpBasic = "HttpBasic"
)
View Source
const (
	AuthConnectTypeCreds = "creds"
)

Variables

This section is empty.

Functions

func LogHTTPError

func LogHTTPError(r *http.Response, innerErr error) error

func NewHTTPShadowError

func NewHTTPShadowError(status int, userFacingError string, fmtString string, args ...interface{}) error

func UpgradeToWebSocket

func UpgradeToWebSocket(echoContext echo.Context) (*websocket.Conn, *time.Ticker, error)

Upgrade the HTTP connection to a WebSocket with a Ping ticker

Types

type CFInfo

type CFInfo struct {
	EndpointGUID string
	SpaceGUID    string
	AppGUID      string
}

type CNSIRecord

type CNSIRecord struct {
	GUID                   string   `json:"guid"`
	Name                   string   `json:"name"`
	CNSIType               string   `json:"cnsi_type"`
	APIEndpoint            *url.URL `json:"api_endpoint"`
	AuthorizationEndpoint  string   `json:"authorization_endpoint"`
	TokenEndpoint          string   `json:"token_endpoint"`
	DopplerLoggingEndpoint string   `json:"doppler_logging_endpoint"`
	SkipSSLValidation      bool     `json:"skip_ssl_validation"`
}

TODO this could be moved back to cnsis subpackage, and extensions could import it?

type CNSIRequest

type CNSIRequest struct {
	GUID     string `json:"-"`
	UserGUID string `json:"-"`

	Method      string      `json:"-"`
	Body        []byte      `json:"-"`
	Header      http.Header `json:"-"`
	URL         *url.URL    `json:"-"`
	StatusCode  int         `json:"statusCode"`
	Status      string      `json:"status"`
	PassThrough bool        `json:"-"`

	Response     []byte `json:"-"`
	Error        error  `json:"-"`
	ResponseGUID string `json:"-"`
}

CNSIRequest

type ConnectedEndpoint

type ConnectedEndpoint struct {
	GUID                   string   `json:"guid"`
	Name                   string   `json:"name"`
	CNSIType               string   `json:"cnsi_type"`
	APIEndpoint            *url.URL `json:"api_endpoint"`
	Account                string   `json:"account"`
	TokenExpiry            int64    `json:"token_expiry"`
	DopplerLoggingEndpoint string   `json:"-"`
	SkipSSLValidation      bool     `json:"skip_ssl_validation"`
	TokenMetadata          string   `json:"-"`
}

ConnectedEndpoint

type ConnectedUser

type ConnectedUser struct {
	GUID   string   `json:"guid"`
	Name   string   `json:"name"`
	Admin  bool     `json:"admin"`
	Scopes []string `json:"scopes"`
}

ConnectedUser - details about the user connected to a specific service or UAA

type ConsoleConfig

type ConsoleConfig struct {
	UAAEndpoint         *url.URL `json:"uaa_endpoint"`
	ConsoleAdminScope   string   `json:"console_admin_scope"`
	ConsoleClient       string   `json:"console_client"`
	ConsoleClientSecret string   `json:"console_client_secret"`
	SkipSSLValidation   bool     `json:"skip_ssl_validation"`
	IsSetupComplete     bool     `json:"is_setup_complete"`
}

type EndpointDetail

type EndpointDetail struct {
	*CNSIRecord
	User          *ConnectedUser    `json:"user"`
	Metadata      map[string]string `json:"metadata,omitempty"`
	TokenMetadata string            `json:"-"`
}

Extends CNSI Record and adds the user

type EndpointPlugin

type EndpointPlugin interface {
	Info(apiEndpoint string, skipSSLValidation bool) (CNSIRecord, interface{}, error)
	GetType() string
	GetClientId() string
	Register(echoContext echo.Context) error
	Connect(echoContext echo.Context, cnsiRecord CNSIRecord, userId string) (*TokenRecord, bool, error)
	UpdateMetadata(info *Info, userGUID string, echoContext echo.Context)
}

type EndpointTokenRecord

type EndpointTokenRecord struct {
	*TokenRecord
	EndpointGUID    string
	EndpointType    string
	APIEndpint      string
	LoggingEndpoint string
}

Token record for an endpoint (includes the Endpoint GUID)

type ErrHTTPRequest

type ErrHTTPRequest struct {
	Status     int
	InnerError error
	Response   string
}

func (ErrHTTPRequest) Error

func (e ErrHTTPRequest) Error() string

type ErrHTTPShadow

type ErrHTTPShadow struct {
	HTTPError  *echo.HTTPError
	LogMessage string
}

func (ErrHTTPShadow) Error

func (e ErrHTTPShadow) Error() string

type Info

type Info struct {
	Versions     *Versions                             `json:"version"`
	User         *ConnectedUser                        `json:"user"`
	Endpoints    map[string]map[string]*EndpointDetail `json:"endpoints"`
	CloudFoundry *CFInfo                               `json:"cloud-foundry,omitempty"`
	PluginConfig map[string]string                     `json:"plugin-config,omitempty"`
}

Info - this represents user specific info

type InfoFunc

type InfoFunc func(apiEndpoint string, skipSSLValidation bool) (CNSIRecord, interface{}, error)

type JWTUserTokenInfo

type JWTUserTokenInfo struct {
	UserGUID    string   `json:"user_id"`
	UserName    string   `json:"user_name"`
	TokenExpiry int64    `json:"exp"`
	Scope       []string `json:"scope"`
}

type LoginHookFunc

type LoginHookFunc func(c echo.Context) error

type LoginRes

type LoginRes struct {
	Account     string         `json:"account"`
	TokenExpiry int64          `json:"token_expiry"`
	APIEndpoint *url.URL       `json:"api_endpoint"`
	Admin       bool           `json:"admin"`
	User        *ConnectedUser `json:"user"`
}

type MiddlewarePlugin

type MiddlewarePlugin interface {
	EchoMiddleware(middleware echo.HandlerFunc) echo.HandlerFunc
	SessionEchoMiddleware(middleware echo.HandlerFunc) echo.HandlerFunc
}

type OAuth2Metadata

type OAuth2Metadata struct {
	ClientID     string
	ClientSecret string
	IssuerURL    string
}

Structure for optional metadata for an OAuth2 Token

type PortalConfig

type PortalConfig struct {
	HTTPClientTimeoutInSecs     int64    `configName:"HTTP_CLIENT_TIMEOUT_IN_SECS"`
	HTTPConnectionTimeoutInSecs int64    `configName:"HTTP_CONNECTION_TIMEOUT_IN_SECS"`
	TLSAddress                  string   `configName:"CONSOLE_PROXY_TLS_ADDRESS"`
	TLSCert                     string   `configName:"CONSOLE_PROXY_CERT"`
	TLSCertKey                  string   `configName:"CONSOLE_PROXY_CERT_KEY"`
	TLSCertPath                 string   `configName:"CONSOLE_PROXY_CERT_PATH"`
	TLSCertKeyPath              string   `configName:"CONSOLE_PROXY_CERT_KEY_PATH"`
	CFClient                    string   `configName:"CF_CLIENT"`
	CFClientSecret              string   `configName:"CF_CLIENT_SECRET"`
	AllowedOrigins              []string `configName:"ALLOWED_ORIGINS"`
	SessionStoreSecret          string   `configName:"SESSION_STORE_SECRET"`
	EncryptionKeyVolume         string   `configName:"ENCRYPTION_KEY_VOLUME"`
	EncryptionKeyFilename       string   `configName:"ENCRYPTION_KEY_FILENAME"`
	EncryptionKey               string   `configName:"ENCRYPTION_KEY"`
	AutoRegisterCFUrl           string   `configName:"AUTO_REG_CF_URL"`
	CookieDomain                string   `configName:"COOKIE_DOMAIN"`
	CFAdminIdentifier           string
	CloudFoundryInfo            *CFInfo
	HTTPS                       bool
	EncryptionKeyInBytes        []byte
	ConsoleVersion              string
	IsCloudFoundry              bool
	LoginHook                   LoginHookFunc
	SessionStore                SessionStorer
	ConsoleConfig               *ConsoleConfig
	PluginConfig                map[string]string
}

type PortalProxy

type PortalProxy interface {
	GetHttpClient(skipSSLValidation bool) http.Client
	RegisterEndpoint(c echo.Context, fetchInfo InfoFunc) error

	DoRegisterEndpoint(cnsiName string, apiEndpoint string, skipSSLValidation bool, fetchInfo InfoFunc) (CNSIRecord, error)

	GetEndpointTypeSpec(typeName string) (EndpointPlugin, error)

	// Auth
	ConnectOAuth2(c echo.Context, cnsiRecord CNSIRecord) (*TokenRecord, error)
	InitEndpointTokenRecord(expiry int64, authTok string, refreshTok string, disconnect bool) TokenRecord

	// Session
	GetSession(c echo.Context) (*sessions.Session, error)
	GetSessionValue(c echo.Context, key string) (interface{}, error)
	GetSessionInt64Value(c echo.Context, key string) (int64, error)
	GetSessionStringValue(c echo.Context, key string) (string, error)
	SaveSession(c echo.Context, session *sessions.Session) error

	SaveConsoleConfig(consoleConfig *ConsoleConfig, consoleRepoInterface interface{}) error

	RefreshOAuthToken(skipSSLValidation bool, cnsiGUID, userGUID, client, clientSecret, tokenEndpoint string) (t TokenRecord, err error)
	DoLoginToCNSI(c echo.Context, cnsiGUID string) (*LoginRes, error)
	// Expose internal portal proxy records to extensions
	GetCNSIRecord(guid string) (CNSIRecord, error)
	GetCNSIRecordByEndpoint(endpoint string) (CNSIRecord, error)
	GetCNSITokenRecord(cnsiGUID string, userGUID string) (TokenRecord, bool)
	GetCNSITokenRecordWithDisconnected(cnsiGUID string, userGUID string) (TokenRecord, bool)
	GetCNSIUser(cnsiGUID string, userGUID string) (*ConnectedUser, bool)
	GetConfig() *PortalConfig
	ListEndpointsByUser(userGUID string) ([]*ConnectedEndpoint, error)

	GetClientId(cnsiType string) (string, error)

	// UAA Token
	GetUAATokenRecord(userGUID string) (TokenRecord, error)
	RefreshUAAToken(userGUID string) (TokenRecord, error)

	GetUsername(userid string) (string, error)
	RefreshUAALogin(username, password string, store bool) error
	GetUserTokenInfo(tok string) (u *JWTUserTokenInfo, err error)

	// Proxy API requests
	ProxyRequest(c echo.Context, uri *url.URL) (map[string]*CNSIRequest, error)
	DoProxyRequest(requests []ProxyRequestInfo) (map[string]*CNSIRequest, error)
	SendProxiedResponse(c echo.Context, responses map[string]*CNSIRequest) error
}

type ProxyRequestInfo

type ProxyRequestInfo struct {
	EndpointGUID string
	URI          *url.URL
	UserGUID     string
	ResultGUID   string
	Headers      http.Header
	Body         []byte
	Method       string
}

type RoutePlugin

type RoutePlugin interface {
	AddSessionGroupRoutes(echoContext *echo.Group)
	AddAdminGroupRoutes(echoContext *echo.Group)
}

type SessionStorer

type SessionStorer interface {
	Get(r *http.Request, name string) (*sessions.Session, error)
	Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
}

type StratosPlugin

type StratosPlugin interface {
	Init() error
	GetMiddlewarePlugin() (MiddlewarePlugin, error)
	GetEndpointPlugin() (EndpointPlugin, error)
	GetRoutePlugin() (RoutePlugin, error)
}

type TokenRecord

type TokenRecord struct {
	AuthToken    string
	RefreshToken string
	TokenExpiry  int64
	Disconnected bool
	AuthType     string
	Metadata     string
}

TODO this could be moved back to tokens subpackage, and extensions could import it?

type V2Info

type V2Info struct {
	AuthorizationEndpoint    string `json:"authorization_endpoint"`
	TokenEndpoint            string `json:"token_endpoint"`
	DopplerLoggingEndpoint   string `json:"doppler_logging_endpoint"`
	AppSSHEndpoint           string `json:"app_ssh_endpoint"`
	AppSSHHostKeyFingerprint string `json:"app_ssh_host_key_fingerprint"`
	AppSSHOauthCLient        string `json:"app_ssh_oauth_client"`
}

type VCapApplicationData

type VCapApplicationData struct {
	API           string `json:"cf_api"`
	ApplicationID string `json:"application_id"`
	SpaceID       string `json:"space_id"`
}

type Versions

type Versions struct {
	ProxyVersion    string `json:"proxy_version"`
	DatabaseVersion int64  `json:"database_version"`
}

Versions - response returned to caller from a getVersions action

Jump to

Keyboard shortcuts

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