forked from wavefrontHQ/wavefront-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.go
More file actions
27 lines (23 loc) · 1.05 KB
/
auth.go
File metadata and controls
27 lines (23 loc) · 1.05 KB
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
package senders
import (
"log"
"github.com/wavefronthq/wavefront-sdk-go/internal/auth"
)
func tokenServiceForCfg(cfg *configuration) auth.Service {
switch cfg.Authentication.(type) {
case auth.APIToken:
log.Println("The Wavefront SDK will use Direct Ingestion authenticated using an API Token.")
tokenAuth := cfg.Authentication.(auth.APIToken)
return auth.NewWavefrontTokenService(tokenAuth.Token)
case auth.CSPClientCredentials:
log.Println("The Wavefront SDK will use Direct Ingestion authenticated using CSP client credentials.")
cspAuth := cfg.Authentication.(auth.CSPClientCredentials)
return auth.NewCSPServerToServerService(cspAuth.BaseURL, cspAuth.ClientID, cspAuth.ClientSecret, cspAuth.OrgID)
case auth.CSPAPIToken:
log.Println("The Wavefront SDK will use Direct Ingestion authenticated using CSP API Token.")
cspAuth := cfg.Authentication.(auth.CSPAPIToken)
return auth.NewCSPTokenService(cspAuth.BaseURL, cspAuth.Token)
}
log.Println("The Wavefront SDK will communicate with a Wavefront Proxy.")
return auth.NewNoopTokenService()
}