This repository has been archived by the owner on Jan 24, 2023. It is now read-only.
/
portal_proxy.go
57 lines (44 loc) · 2.29 KB
/
portal_proxy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package interfaces
import (
"net/http"
"net/url"
"github.com/gorilla/sessions"
"github.com/labstack/echo"
)
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
}