From 8bb41cff9f47895e00d7773dfd9372a7e17fae59 Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Fri, 31 Jan 2020 12:15:06 -0600 Subject: [refactor] refactor auth files --- pkg/vpn/bonafide/auth_anon.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'pkg/vpn/bonafide/auth_anon.go') diff --git a/pkg/vpn/bonafide/auth_anon.go b/pkg/vpn/bonafide/auth_anon.go index 61916e6..3a666a8 100644 --- a/pkg/vpn/bonafide/auth_anon.go +++ b/pkg/vpn/bonafide/auth_anon.go @@ -16,22 +16,29 @@ package bonafide import ( + "errors" "fmt" "io/ioutil" ) -type AnonymousAuthentication struct { - bonafide *Bonafide +type anonymousAuthentication struct { + client httpClient + authURI string + certURI string } -func (a *AnonymousAuthentication) GetPemCertificate() ([]byte, error) { - resp, err := a.bonafide.client.Post(certAPI, "", nil) +func (a *anonymousAuthentication) needsCredentials() bool { + return true +} + +func (a *anonymousAuthentication) getPemCertificate(cred *credentials) ([]byte, error) { + resp, err := a.client.Post(certAPI, "", nil) if err != nil { return nil, err } defer resp.Body.Close() if resp.StatusCode == 404 { - resp, err = a.bonafide.client.Post(certAPI3, "", nil) + resp, err = a.client.Post(certAPI3, "", nil) if err != nil { return nil, err } @@ -43,3 +50,7 @@ func (a *AnonymousAuthentication) GetPemCertificate() ([]byte, error) { return ioutil.ReadAll(resp.Body) } + +func (a *anonymousAuthentication) getToken(cred *credentials) ([]byte, error) { + return []byte(""), errors.New("anon authentication should not call getToken") +} -- cgit v1.2.3