summaryrefslogtreecommitdiff
path: root/internal/oauth
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-07-20 16:07:13 +0200
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-07-20 16:07:13 +0200
commit0c9a300a58d9dacce7b84ff93222eed35eab5721 (patch)
tree423d1f05024f5c050e09f8d239f15b2e8681e640 /internal/oauth
parenta1939a105dc4ddab27489b1bac3b22f674536e41 (diff)
Refactor: Do not log in internal packages
The reason behind this is that we then do not have to pass a lot to each function. Logging inside internal packages is less useful as we want to let them return errors and only log in the 'public' facing API or let the client decide
Diffstat (limited to 'internal/oauth')
-rw-r--r--internal/oauth/oauth.go8
1 files changed, 1 insertions, 7 deletions
diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go
index d828e57..b1569e9 100644
--- a/internal/oauth/oauth.go
+++ b/internal/oauth/oauth.go
@@ -11,7 +11,6 @@ import (
"github.com/jwijenbergh/eduvpn-common/internal/fsm"
httpw "github.com/jwijenbergh/eduvpn-common/internal/http"
- "github.com/jwijenbergh/eduvpn-common/internal/log"
"github.com/jwijenbergh/eduvpn-common/internal/types"
"github.com/jwijenbergh/eduvpn-common/internal/util"
)
@@ -62,7 +61,6 @@ type OAuth struct {
Token OAuthToken `json:"token"`
BaseAuthorizationURL string `json:"base_authorization_url"`
TokenURL string `json:"token_url"`
- Logger *log.FileLogger `json:"-"`
FSM *fsm.FSM `json:"-"`
}
@@ -223,11 +221,10 @@ func (oauth *OAuth) Callback(w http.ResponseWriter, req *http.Request) {
}
}
-func (oauth *OAuth) Init(baseAuthorizationURL string, tokenURL string, fsm *fsm.FSM, logger *log.FileLogger) {
+func (oauth *OAuth) Init(baseAuthorizationURL string, tokenURL string, fsm *fsm.FSM) {
oauth.BaseAuthorizationURL = baseAuthorizationURL
oauth.TokenURL = tokenURL
oauth.FSM = fsm
- oauth.Logger = logger
}
// Starts the OAuth exchange for eduvpn.
@@ -312,7 +309,6 @@ func (oauth *OAuth) Login(name string, postprocessAuth func(string) string) erro
func (oauth *OAuth) NeedsRelogin() bool {
// Access Token or Refresh Tokens empty, definitely needs a relogin
if oauth.Token.Access == "" || oauth.Token.Refresh == "" {
- oauth.Logger.Log(log.LOG_INFO, "OAuth: Tokens are empty")
return true
}
@@ -321,14 +317,12 @@ func (oauth *OAuth) NeedsRelogin() bool {
// The tokens are not expired yet
// No relogin is needed
if !oauth.isTokensExpired() {
- oauth.Logger.Log(log.LOG_INFO, "OAuth: Tokens are not expired, re-login not needed")
return false
}
refreshErr := oauth.getTokensWithRefresh()
// We have obtained new tokens with refresh
if refreshErr == nil {
- oauth.Logger.Log(log.LOG_INFO, "OAuth: Tokens could be re-acquired using the refresh token, re-login not needed")
return false
}