Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic thrown when attempting to create SSO request without sufficient configuration #119

Closed
jlucktay opened this issue Jul 30, 2020 · 2 comments
Assignees
Labels

Comments

@jlucktay
Copy link
Contributor

Branch/Environment

  • Branch: master (34d1bf5)
  • Environment: Ara dev environment

Describe the bug
Panics are being thrown in the SSO process when there is some invalid Dashboard config set.

Reproduction steps

  1. Set empty/bogus configuration under TykApi.DashboardConfig
  2. Launch TIB
  3. Hit the /admin/sso endpoint

Actual behaviour
TIB panics.

Expected behaviour
This section should return a clear error if creating the request returns an error:

newRequest, err := http.NewRequest(method, preparedEndpoint, body)
if err != nil {
tykAPILogger.Error("Failed to create request")
tykAPILogger.Error(err)
}

Screenshots/Video

Browser/Os (please complete the following information):

Additional context
Related to an issue occurring in Ara & Tyk Dashboard.

@jlucktay jlucktay added the bug label Jul 30, 2020
@buger buger assigned sredxny and unassigned buger and gernest Jul 30, 2020
@jlucktay
Copy link
Contributor Author

Something like this should cover it off:

diff --git a/tyk-api/tyk_api.go b/tyk-api/tyk_api.go
index c78d87d..8425a96 100644
--- a/tyk-api/tyk_api.go
+++ b/tyk-api/tyk_api.go
@@ -202,10 +202,10 @@ func (t *TykAPI) DispatchDashboardSuper(target Endpoint, method string, body io.
 	preparedEndpoint := t.DashboardConfig.Endpoint + ":" + t.DashboardConfig.Port + string(target)
 
 	tykAPILogger.Debug("Calling: ", preparedEndpoint)
-	newRequest, err := http.NewRequest(method, preparedEndpoint, body)
-	if err != nil {
-		tykAPILogger.Error("Failed to create request")
-		tykAPILogger.Error(err)
+	newRequest, errNewReq := http.NewRequest(method, preparedEndpoint, body)
+	if errNewReq != nil {
+		tykAPILogger.WithError(errNewReq).Error("failed to create request")
+		return []byte{}, http.StatusInternalServerError, errNewReq
 	}
 
 	newRequest.Header.Add("admin-auth", t.DashboardConfig.AdminSecret)

@sredxny
Copy link
Contributor

sredxny commented Mar 23, 2021

Fixed in #120

@sredxny sredxny closed this as completed Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants