Documentation
¶
Overview ¶
Package api implements version 3 of the eduVPN api: https://docs.eduvpn.org/server/v3/api.html
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAuthorizeDisabled = errors.New("cannot authorize as re-authorization is disabled")
ErrAuthorizeDisabled is returned when authorization is disabled but is needed to complete
var ErrNoProtocols = errors.New("no protocols supplied")
ErrNoProtocols is returned when a connect call is given with an empty protocol slice
var ErrUnknownProtocol = errors.New("unknown protocol supplied")
ErrUnknownProtocol is returned when the client in a connect gives an unknown protocol
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { // Data is the server data Data ServerData // contains filtered or unexported fields }
API is the top-level struct that each method is defined on
func NewAPI ¶
func NewAPI(ctx context.Context, clientID string, sd ServerData, cb Callbacks, tokens *eduoauth.Token) (*API, error)
NewAPI creates a new API object by creating an OAuth object
func (*API) Connect ¶
func (a *API) Connect(ctx context.Context, prof profiles.Profile, protos []protocol.Protocol, pTCP bool) (*ConnectData, error)
Connect sends a /connect to an eduVPN server `ctx` is the context used for cancellation protos is the list of protocols supported and wanted by the client
func (*API) Disconnect ¶
Disconnect disconnects a client from the server by sending a /disconnect API call This cleans up resources such as WireGuard IP allocation
type Callbacks ¶
type Callbacks interface { // TriggerAuth is called when authorization should be triggered TriggerAuth(context.Context, string, bool) (string, error) // AuthDone is called when authorization has just completed AuthDone(string, server.Type) // TokensUpdates is called when tokens are updated TokensUpdated(string, server.Type, eduoauth.Token) }
Callbacks is the API callback interface It is used to trigger authorization and forward token updates
type ConnectData ¶
type ConnectData struct { // Configuration is the VPN configuration Configuration string // Protocol tells us what protocol it is, OpenVPN or WireGuard (proxied or not) Protocol protocol.Protocol // Expires tells us when this configuration expires Expires time.Time // Proxy is filled when WireGuard is proxied Proxy *wireguard.Proxy }
ConnectData is the data that is returned when the /connect call completes without error
type EndpointCache ¶
type EndpointCache struct {
// contains filtered or unexported fields
}
EndpointCache is a struct that caches well-known API endpoints
func GetEndpointCache ¶
func GetEndpointCache() *EndpointCache
GetEndpointCache returns the global singleton endpoint cache or creates one if it does not exist
type OAuthLogger ¶
type OAuthLogger struct{}
OAuthLogger is defined here to update the internal logger for the eduoauth library
func (*OAuthLogger) Logf ¶
func (ol *OAuthLogger) Logf(msg string, params ...interface{})
Logf logs a message with parameters
type ServerData ¶
type ServerData struct { // ID is the identifier for the server ID string // Type is the type of server Type server.Type // BaseWK is the base well-known endpoint BaseWK string // BaseAuthWK is the base well-known endpoint for authorization. This is only different in case of secure internet BaseAuthWK string // ProcessAuth processes the OAuth authorization ProcessAuth func(context.Context, string) (string, error) // DisableAuthorize indicates whether or not new authorization requests should be disabled DisableAuthorize bool // contains filtered or unexported fields }
ServerData is the data for a server that is passed to the API struct
func (*ServerData) Transport ¶
func (s *ServerData) Transport() http.RoundTripper
Transport returns the transport to be used for the server By default it uses the transport from internal/http DefaultTransport
Directories
¶
Path | Synopsis |
---|---|
Package endpoints defines a wrapper around the various endpoints returned by an eduVPN server in well-known
|
Package endpoints defines a wrapper around the various endpoints returned by an eduVPN server in well-known |
Package profiles defines a wrapper around the various profiles returned by the /info endpoint
|
Package profiles defines a wrapper around the various profiles returned by the /info endpoint |