mirror of
https://github.com/openziti/zrok.git
synced 2025-02-17 18:50:54 +01:00
normalize some existing log messages
This commit is contained in:
parent
ece79f28d9
commit
7be46bfd40
@ -87,7 +87,7 @@ func (cmd *testWebsocketCommand) run(_ *cobra.Command, args []string) {
|
|||||||
addr = cmd.serviceName
|
addr = cmd.serviceName
|
||||||
} else {
|
} else {
|
||||||
if len(args) == 0 {
|
if len(args) == 0 {
|
||||||
logrus.Error("Address required if not using ziti")
|
logrus.Error("address required if not using ziti")
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
@ -102,13 +102,13 @@ func (cmd *testWebsocketCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
defer c.Close(websocket.StatusInternalError, "the sky is falling")
|
defer c.Close(websocket.StatusInternalError, "the sky is falling")
|
||||||
|
|
||||||
logrus.Info("Writing to server...")
|
logrus.Info("writing to server...")
|
||||||
err = wsjson.Write(ctx, c, "hi")
|
err = wsjson.Write(ctx, c, "hi")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logrus.Info("Reading response...")
|
logrus.Info("reading response...")
|
||||||
typ, dat, err := c.Read(ctx)
|
typ, dat, err := c.Read(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
|
@ -80,7 +80,7 @@ func configureGithubOauth(cfg *OauthConfig, tls bool) error {
|
|||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
host, err := url.QueryUnescape(r.URL.Query().Get("targethost"))
|
host, err := url.QueryUnescape(r.URL.Query().Get("targethost"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("Unable to unescape target host: %v", err)
|
logrus.Errorf("unable to unescape target host: %v", err)
|
||||||
}
|
}
|
||||||
rp.AuthURLHandler(func() string {
|
rp.AuthURLHandler(func() string {
|
||||||
id := uuid.New().String()
|
id := uuid.New().String()
|
||||||
@ -99,7 +99,7 @@ func configureGithubOauth(cfg *OauthConfig, tls bool) error {
|
|||||||
})
|
})
|
||||||
s, err := t.SignedString(key)
|
s, err := t.SignedString(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("Unable to sign intermediate JWT: %v", err)
|
logrus.Errorf("unable to sign intermediate JWT: %v", err)
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}, party, rp.WithURLParam("access_type", "offline"))(w, r)
|
}, party, rp.WithURLParam("access_type", "offline"))(w, r)
|
||||||
@ -121,7 +121,7 @@ func configureGithubOauth(cfg *OauthConfig, tls bool) error {
|
|||||||
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", tokens.AccessToken))
|
req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", tokens.AccessToken))
|
||||||
resp, err := http.DefaultClient.Do(req)
|
resp, err := http.DefaultClient.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("Error getting user info from github: " + err.Error() + "\n")
|
logrus.Errorf("error getting user info from github: %v", err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -130,14 +130,14 @@ func configureGithubOauth(cfg *OauthConfig, tls bool) error {
|
|||||||
}()
|
}()
|
||||||
response, err := io.ReadAll(resp.Body)
|
response, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("Error reading response body: %v", err)
|
logrus.Errorf("error reading response body: %v", err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var rDat []githubUserResp
|
var rDat []githubUserResp
|
||||||
err = json.Unmarshal(response, &rDat)
|
err = json.Unmarshal(response, &rDat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("Error unmarshalling google oauth response: %v", err)
|
logrus.Errorf("error unmarshalling google oauth response: %v", err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ func configureGoogleOauth(cfg *OauthConfig, tls bool) error {
|
|||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
host, err := url.QueryUnescape(r.URL.Query().Get("targethost"))
|
host, err := url.QueryUnescape(r.URL.Query().Get("targethost"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("Unable to unescape target host: %v", err)
|
logrus.Errorf("unable to unescape target host: %v", err)
|
||||||
}
|
}
|
||||||
rp.AuthURLHandler(func() string {
|
rp.AuthURLHandler(func() string {
|
||||||
id := uuid.New().String()
|
id := uuid.New().String()
|
||||||
@ -97,7 +97,7 @@ func configureGoogleOauth(cfg *OauthConfig, tls bool) error {
|
|||||||
})
|
})
|
||||||
s, err := t.SignedString(key)
|
s, err := t.SignedString(key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("Unable to sign intermediate JWT: %v", err)
|
logrus.Errorf("unable to sign intermediate JWT: %v", err)
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}, party, rp.WithURLParam("access_type", "offline"))(w, r)
|
}, party, rp.WithURLParam("access_type", "offline"))(w, r)
|
||||||
@ -108,7 +108,7 @@ func configureGoogleOauth(cfg *OauthConfig, tls bool) error {
|
|||||||
getEmail := func(w http.ResponseWriter, r *http.Request, tokens *oidc.Tokens[*oidc.IDTokenClaims], state string, rp rp.RelyingParty) {
|
getEmail := func(w http.ResponseWriter, r *http.Request, tokens *oidc.Tokens[*oidc.IDTokenClaims], state string, rp rp.RelyingParty) {
|
||||||
resp, err := http.Get("https://www.googleapis.com/oauth2/v2/userinfo?access_token=" + url.QueryEscape(tokens.AccessToken))
|
resp, err := http.Get("https://www.googleapis.com/oauth2/v2/userinfo?access_token=" + url.QueryEscape(tokens.AccessToken))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Error("Error getting user info from google: " + err.Error() + "\n")
|
logrus.Errorf("error getting user info from google: %v", err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -117,15 +117,15 @@ func configureGoogleOauth(cfg *OauthConfig, tls bool) error {
|
|||||||
}()
|
}()
|
||||||
response, err := io.ReadAll(resp.Body)
|
response, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("Error reading response body: %v", err)
|
logrus.Errorf("error reading response body: %v", err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logrus.Infof("Response from google userinfo endpoint: %s", string(response))
|
logrus.Infof("response from google userinfo endpoint: %s", string(response))
|
||||||
rDat := googleOauthEmailResp{}
|
rDat := googleOauthEmailResp{}
|
||||||
err = json.Unmarshal(response, &rDat)
|
err = json.Unmarshal(response, &rDat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("Error unmarshalling google oauth response: %v", err)
|
logrus.Errorf("error unmarshalling google oauth response: %v", err)
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ func authHandler(handler http.Handler, pcfg *Config, key []byte, ctx ziti.Contex
|
|||||||
if provider, found := oauthCfg.(map[string]interface{})["provider"]; found {
|
if provider, found := oauthCfg.(map[string]interface{})["provider"]; found {
|
||||||
var authCheckInterval time.Duration
|
var authCheckInterval time.Duration
|
||||||
if checkInterval, found := oauthCfg.(map[string]interface{})["authorization_check_interval"]; !found {
|
if checkInterval, found := oauthCfg.(map[string]interface{})["authorization_check_interval"]; !found {
|
||||||
logrus.Errorf("Missing authorization check interval in share config. Defaulting to 3 hours")
|
logrus.Errorf("missing authorization check interval in share config. Defaulting to 3 hours")
|
||||||
authCheckInterval = 3 * time.Hour
|
authCheckInterval = 3 * time.Hour
|
||||||
} else {
|
} else {
|
||||||
i, err := time.ParseDuration(checkInterval.(string))
|
i, err := time.ParseDuration(checkInterval.(string))
|
||||||
|
Loading…
Reference in New Issue
Block a user