From d82272ab1d155ebc815f103a67c71a07ca4030b9 Mon Sep 17 00:00:00 2001 From: akshadpai Date: Thu, 1 Jun 2023 15:16:08 -0500 Subject: [PATCH 1/3] Replace ioutil with io and add json Decoder --- core/auth/auth_type_oidc.go | 8 +- core/auth/auth_type_phone.go | 4 +- driven/identitybb/adapter.go | 9 +- driven/profilebb/adapter.go | 9 +- driver/web/apis_admin.go | 161 ++++++----------------------------- driver/web/apis_services.go | 161 ++++++----------------------------- driver/web/apis_system.go | 140 ++++++------------------------ 7 files changed, 89 insertions(+), 403 deletions(-) diff --git a/core/auth/auth_type_oidc.go b/core/auth/auth_type_oidc.go index 7179aabaa..8c7a8d0e0 100644 --- a/core/auth/auth_type_oidc.go +++ b/core/auth/auth_type_oidc.go @@ -21,7 +21,7 @@ import ( "encoding/base64" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "strconv" @@ -401,7 +401,7 @@ func (a *oidcAuthImpl) loadOidcTokenWithParams(params map[string]string, oidcCon } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.WrapErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err) } @@ -410,7 +410,7 @@ func (a *oidcAuthImpl) loadOidcTokenWithParams(params map[string]string, oidcCon } var authToken oidcToken - err = json.Unmarshal(body, &authToken) + err = json.NewDecoder(resp.Body).Decode(&authToken) if err != nil { return nil, errors.WrapErrorAction(logutils.ActionUnmarshal, logutils.TypeToken, nil, err) } @@ -447,7 +447,7 @@ func (a *oidcAuthImpl) loadOidcUserInfo(token *oidcToken, url string) ([]byte, e } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.WrapErrorAction(logutils.ActionRead, logutils.TypeResponse, nil, err) } diff --git a/core/auth/auth_type_phone.go b/core/auth/auth_type_phone.go index 336847397..a89a20f4c 100644 --- a/core/auth/auth_type_phone.go +++ b/core/auth/auth_type_phone.go @@ -34,7 +34,7 @@ import ( "core-building-block/utils" "encoding/base64" "encoding/json" - "io/ioutil" + "io" "net/http" "net/url" "regexp" @@ -275,7 +275,7 @@ func makeRequest(ctx context.Context, method string, pathPart string, data url.V } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.WrapErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err) } diff --git a/driven/identitybb/adapter.go b/driven/identitybb/adapter.go index e43070b09..a1fd2420a 100644 --- a/driven/identitybb/adapter.go +++ b/driven/identitybb/adapter.go @@ -17,7 +17,7 @@ package identitybb import ( "core-building-block/core/model" "encoding/json" - "io/ioutil" + "io" "net/http" "net/url" @@ -63,19 +63,16 @@ func (a *Adapter) GetUserProfile(baseURL string, externalUser model.ExternalSyst } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, errors.WrapErrorAction(logutils.ActionRead, logutils.TypeResponse, nil, err) } if resp.StatusCode != 200 { return nil, errors.ErrorData(logutils.StatusInvalid, logutils.TypeResponse, &logutils.FieldArgs{"status_code": resp.StatusCode, "error": string(body)}) } - if len(body) == 0 { - return nil, errors.ErrorData(logutils.StatusMissing, logutils.TypeResponseBody, nil) - } var profileData map[string]interface{} - err = json.Unmarshal(body, &profileData) + err = json.NewDecoder(resp.Body).Decode(&profileData) if err != nil { return nil, errors.WrapErrorAction(logutils.ActionUnmarshal, logutils.TypeResponseBody, nil, err) } diff --git a/driven/profilebb/adapter.go b/driven/profilebb/adapter.go index e06399d3e..b8d38a6dd 100644 --- a/driven/profilebb/adapter.go +++ b/driven/profilebb/adapter.go @@ -17,7 +17,7 @@ package profilebb import ( "core-building-block/core/model" "encoding/json" - "io/ioutil" + "io" "net/http" "net/url" "time" @@ -146,19 +146,16 @@ func (a *Adapter) GetProfileBBData(queryParams map[string]string, l *logs.Log) ( } defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, nil, errors.WrapErrorAction(logutils.ActionRead, logutils.TypeResponse, nil, err) } if resp.StatusCode != 200 { return nil, nil, errors.ErrorData(logutils.StatusInvalid, logutils.TypeResponse, &logutils.FieldArgs{"status_code": resp.StatusCode, "error": string(body)}) } - if len(body) == 0 { - return nil, nil, errors.ErrorData(logutils.StatusMissing, logutils.TypeResponseBody, nil) - } var profileData profileBBData - err = json.Unmarshal(body, &profileData) + err = json.NewDecoder(resp.Body).Decode(&profileData) if err != nil { return nil, nil, errors.WrapErrorAction(logutils.ActionUnmarshal, logutils.TypeResponseBody, nil, err) } diff --git a/driver/web/apis_admin.go b/driver/web/apis_admin.go index 946e92ad6..77d936f70 100644 --- a/driver/web/apis_admin.go +++ b/driver/web/apis_admin.go @@ -20,7 +20,6 @@ import ( Def "core-building-block/driver/web/docs/gen" "core-building-block/utils" "encoding/json" - "io/ioutil" "net/http" "strconv" "strings" @@ -58,21 +57,13 @@ func (h AdminApisHandler) getTestModel(l *logs.Log, r *http.Request, claims *tok } func (h AdminApisHandler) login(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - //get ip ip := utils.GetIP(l, r) - if err != nil { - return l.HTTPResponseError("Error getting IP", err, http.StatusInternalServerError, true) - } clientVersion := r.Header.Get("CLIENT_VERSION") var requestData Def.SharedReqLogin - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("auth login request"), nil, err, http.StatusBadRequest, true) } @@ -148,13 +139,9 @@ func (h AdminApisHandler) login(l *logs.Log, r *http.Request, claims *tokenauth. } func (h AdminApisHandler) loginMFA(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var mfaData Def.SharedReqLoginMfa - err = json.Unmarshal(data, &mfaData) + err := json.NewDecoder(r.Body).Decode(&mfaData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("login mfa request"), nil, err, http.StatusBadRequest, true) } @@ -172,13 +159,9 @@ func (h AdminApisHandler) loginMFA(l *logs.Log, r *http.Request, claims *tokenau } func (h AdminApisHandler) loginURL(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.SharedReqLoginUrl - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, "auth login url request", nil, err, http.StatusBadRequest, true) } @@ -198,15 +181,11 @@ func (h AdminApisHandler) loginURL(l *logs.Log, r *http.Request, claims *tokenau } func (h AdminApisHandler) refresh(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } clientVersion := r.Header.Get("CLIENT_VERSION") var requestData Def.SharedReqRefresh - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("auth refresh request"), nil, err, http.StatusBadRequest, true) } @@ -241,13 +220,9 @@ func (h AdminApisHandler) refresh(l *logs.Log, r *http.Request, claims *tokenaut } func (h AdminApisHandler) getAppConfigs(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.SharedReqAppConfigs - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("application config request"), nil, err, http.StatusBadRequest, true) } @@ -273,13 +248,9 @@ func (h AdminApisHandler) getAppConfigs(l *logs.Log, r *http.Request, claims *to } func (h AdminApisHandler) getAppConfigsForOrganization(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.SharedReqAppConfigsOrg - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("application org config request"), nil, err, http.StatusBadRequest, true) } @@ -646,15 +617,11 @@ func (h AdminApisHandler) getAccount(l *logs.Log, r *http.Request, claims *token } func (h AdminApisHandler) createAdminAccount(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } clientVersion := r.Header.Get("CLIENT_VERSION") var requestData Def.SharedReqCreateAccount - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("create account request"), nil, err, http.StatusBadRequest, true) } @@ -691,7 +658,7 @@ func (h AdminApisHandler) createAdminAccount(l *logs.Log, r *http.Request, claim respData := partialAccountToDef(*account, params) - data, err = json.Marshal(respData) + data, err := json.Marshal(respData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionMarshal, model.TypeAccount, nil, err, http.StatusInternalServerError, false) } @@ -700,13 +667,9 @@ func (h AdminApisHandler) createAdminAccount(l *logs.Log, r *http.Request, claim } func (h AdminApisHandler) updateAdminAccount(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.SharedReqUpdateAccount - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("update account request"), nil, err, http.StatusBadRequest, true) } @@ -736,7 +699,7 @@ func (h AdminApisHandler) updateAdminAccount(l *logs.Log, r *http.Request, claim respData := partialAccountToDef(*account, params) - data, err = json.Marshal(respData) + data, err := json.Marshal(respData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionMarshal, model.TypeAccount, nil, err, http.StatusInternalServerError, false) } @@ -761,13 +724,9 @@ func (h AdminApisHandler) getMFATypes(l *logs.Log, r *http.Request, claims *toke } func (h AdminApisHandler) addMFAType(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var mfaData Def.SharedReqMfa - err = json.Unmarshal(data, &mfaData) + err := json.NewDecoder(r.Body).Decode(&mfaData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("add mfa request"), nil, err, http.StatusBadRequest, true) } @@ -788,13 +747,9 @@ func (h AdminApisHandler) addMFAType(l *logs.Log, r *http.Request, claims *token } func (h AdminApisHandler) removeMFAType(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var mfaData Def.SharedReqMfa - err = json.Unmarshal(data, &mfaData) + err := json.NewDecoder(r.Body).Decode(&mfaData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("remove mfa request"), nil, err, http.StatusBadRequest, true) } @@ -808,13 +763,9 @@ func (h AdminApisHandler) removeMFAType(l *logs.Log, r *http.Request, claims *to } func (h AdminApisHandler) verifyMFA(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var mfaData Def.SharedReqMfa - err = json.Unmarshal(data, &mfaData) + err := json.NewDecoder(r.Body).Decode(&mfaData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("verify mfa request"), nil, err, http.StatusBadRequest, true) } @@ -844,13 +795,9 @@ func (h AdminApisHandler) verifyMFA(l *logs.Log, r *http.Request, claims *tokena } func (h AdminApisHandler) updateAccountUsername(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var username Def.Username - err = json.Unmarshal(data, &username) + err := json.NewDecoder(r.Body).Decode(&username) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeAccountUsername, nil, err, http.StatusBadRequest, true) } @@ -885,12 +832,8 @@ func (h AdminApisHandler) getAppToken(l *logs.Log, r *http.Request, claims *toke // createApplicationGroup creates an application group func (h AdminApisHandler) createApplicationGroup(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.AdminReqApplicationGroup - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeAppOrgGroup, nil, err, http.StatusBadRequest, true) } @@ -945,12 +888,8 @@ func (h AdminApisHandler) updateApplicationGroup(l *logs.Log, r *http.Request, c return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.AdminReqApplicationGroup - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeAppOrgGroup, nil, err, http.StatusBadRequest, true) } @@ -1020,13 +959,8 @@ func (h AdminApisHandler) addAccountsToGroup(l *logs.Log, r *http.Request, claim return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.AdminReqAddAccountsToGroup - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeAccount, nil, err, http.StatusBadRequest, true) } @@ -1048,13 +982,8 @@ func (h AdminApisHandler) removeAccountsFromGroup(l *logs.Log, r *http.Request, return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.AdminReqRemoveAccountFromGroup - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeAppOrgGroup, nil, err, http.StatusBadRequest, true) } @@ -1070,13 +999,9 @@ func (h AdminApisHandler) removeAccountsFromGroup(l *logs.Log, r *http.Request, // createApplicationRole creates an application role func (h AdminApisHandler) createApplicationRole(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.AdminReqApplicationRole - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeAppOrgRole, nil, err, http.StatusBadRequest, true) } @@ -1113,13 +1038,8 @@ func (h AdminApisHandler) updateApplicationRole(l *logs.Log, r *http.Request, cl return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.AdminReqApplicationRole - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeAppOrgRole, nil, err, http.StatusBadRequest, true) } @@ -1216,13 +1136,8 @@ func (h AdminApisHandler) grantAccountPermissions(l *logs.Log, r *http.Request, return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.AdminReqGrantPermissions - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypePermission, nil, err, http.StatusBadRequest, true) } @@ -1244,12 +1159,8 @@ func (h AdminApisHandler) revokeAccountPermissions(l *logs.Log, r *http.Request, return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.AdminReqRevokePermissions - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypePermission, nil, err, http.StatusBadRequest, true) } @@ -1271,13 +1182,8 @@ func (h AdminApisHandler) grantAccountRoles(l *logs.Log, r *http.Request, claims return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.AdminReqGrantRolesToAccount - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeAppOrgRole, nil, err, http.StatusBadRequest, true) } @@ -1299,13 +1205,8 @@ func (h AdminApisHandler) revokeAccountRoles(l *logs.Log, r *http.Request, claim return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.AdminReqRevokeRolesFromAccount - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeAppOrgRole, nil, err, http.StatusBadRequest, true) } @@ -1360,13 +1261,8 @@ func (h AdminApisHandler) updateAccountSystemConfigs(l *logs.Log, r *http.Reques createAnonymous, _ = strconv.ParseBool(createAnonymousArg) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var configs map[string]interface{} - err = json.Unmarshal(data, &configs) + err := json.NewDecoder(r.Body).Decode(&configs) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, "system configs update request", nil, err, http.StatusBadRequest, true) } @@ -1395,13 +1291,8 @@ func (h AdminApisHandler) grantPermissionsToRole(l *logs.Log, r *http.Request, c return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.AdminReqGrantPermissionsToRole - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeAppOrgRole, nil, err, http.StatusBadRequest, true) } diff --git a/driver/web/apis_services.go b/driver/web/apis_services.go index 668fb8dc6..7ecc49fdc 100644 --- a/driver/web/apis_services.go +++ b/driver/web/apis_services.go @@ -20,7 +20,6 @@ import ( Def "core-building-block/driver/web/docs/gen" "core-building-block/utils" "encoding/json" - "io/ioutil" "net/http" "strconv" "strings" @@ -38,20 +37,13 @@ type ServicesApisHandler struct { } func (h ServicesApisHandler) login(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } ip := utils.GetIP(l, r) - if err != nil { - return l.HTTPResponseError("Error getting IP", err, http.StatusInternalServerError, true) - } clientVersion := r.Header.Get("CLIENT_VERSION") var requestData Def.SharedReqLogin - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("auth login request"), nil, err, http.StatusBadRequest, true) } @@ -127,13 +119,9 @@ func (h ServicesApisHandler) login(l *logs.Log, r *http.Request, claims *tokenau } func (h ServicesApisHandler) loginMFA(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var mfaData Def.SharedReqLoginMfa - err = json.Unmarshal(data, &mfaData) + err := json.NewDecoder(r.Body).Decode(&mfaData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("login mfa request"), nil, err, http.StatusBadRequest, true) } @@ -151,15 +139,11 @@ func (h ServicesApisHandler) loginMFA(l *logs.Log, r *http.Request, claims *toke } func (h ServicesApisHandler) refresh(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } clientVersion := r.Header.Get("CLIENT_VERSION") var requestData Def.SharedReqRefresh - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("auth refresh request"), nil, err, http.StatusBadRequest, true) } @@ -194,13 +178,9 @@ func (h ServicesApisHandler) refresh(l *logs.Log, r *http.Request, claims *token } func (h ServicesApisHandler) loginURL(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.SharedReqLoginUrl - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, "auth login url request", nil, err, http.StatusBadRequest, true) } @@ -220,13 +200,9 @@ func (h ServicesApisHandler) loginURL(l *logs.Log, r *http.Request, claims *toke } func (h ServicesApisHandler) accountExists(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.SharedReqAccountCheck - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.TypeRequest, nil, err, http.StatusBadRequest, true) } @@ -245,13 +221,8 @@ func (h ServicesApisHandler) accountExists(l *logs.Log, r *http.Request, claims } func (h ServicesApisHandler) canSignIn(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.SharedReqAccountCheck - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.TypeRequest, nil, err, http.StatusBadRequest, true) } @@ -270,13 +241,9 @@ func (h ServicesApisHandler) canSignIn(l *logs.Log, r *http.Request, claims *tok } func (h ServicesApisHandler) canLink(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.SharedReqAccountCheck - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.TypeRequest, nil, err, http.StatusBadRequest, true) } @@ -295,13 +262,9 @@ func (h ServicesApisHandler) canLink(l *logs.Log, r *http.Request, claims *token } func (h ServicesApisHandler) linkAccountAuthType(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.ServicesReqAccountAuthTypeLink - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("account auth type link request"), nil, err, http.StatusBadRequest, true) } @@ -339,13 +302,9 @@ func (h ServicesApisHandler) linkAccountAuthType(l *logs.Log, r *http.Request, c } func (h ServicesApisHandler) unlinkAccountAuthType(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.ServicesReqAccountAuthTypeUnlink - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("account auth type unlink request"), nil, err, http.StatusBadRequest, true) } @@ -375,13 +334,9 @@ func (h ServicesApisHandler) unlinkAccountAuthType(l *logs.Log, r *http.Request, } func (h ServicesApisHandler) authorizeService(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.ServicesReqAuthorizeService - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, "auth authorize service request", nil, err, http.StatusBadRequest, true) } @@ -461,15 +416,11 @@ func (h ServicesApisHandler) getAccount(l *logs.Log, r *http.Request, claims *to } func (h ServicesApisHandler) createAdminAccount(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } clientVersion := r.Header.Get("CLIENT_VERSION") var requestData Def.SharedReqCreateAccount - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("create account request"), nil, err, http.StatusBadRequest, true) } @@ -506,7 +457,7 @@ func (h ServicesApisHandler) createAdminAccount(l *logs.Log, r *http.Request, cl respData := partialAccountToDef(*account, params) - data, err = json.Marshal(respData) + data, err := json.Marshal(respData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionMarshal, model.TypeAccount, nil, err, http.StatusInternalServerError, false) } @@ -515,13 +466,9 @@ func (h ServicesApisHandler) createAdminAccount(l *logs.Log, r *http.Request, cl } func (h ServicesApisHandler) updateAdminAccount(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.SharedReqUpdateAccount - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("update account request"), nil, err, http.StatusBadRequest, true) } @@ -551,7 +498,7 @@ func (h ServicesApisHandler) updateAdminAccount(l *logs.Log, r *http.Request, cl respData := partialAccountToDef(*account, params) - data, err = json.Marshal(respData) + data, err := json.Marshal(respData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionMarshal, model.TypeAccount, nil, err, http.StatusInternalServerError, false) } @@ -576,13 +523,9 @@ func (h ServicesApisHandler) getMFATypes(l *logs.Log, r *http.Request, claims *t } func (h ServicesApisHandler) addMFAType(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var mfaData Def.SharedReqMfa - err = json.Unmarshal(data, &mfaData) + err := json.NewDecoder(r.Body).Decode(&mfaData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("add mfa request"), nil, err, http.StatusBadRequest, true) } @@ -603,13 +546,9 @@ func (h ServicesApisHandler) addMFAType(l *logs.Log, r *http.Request, claims *to } func (h ServicesApisHandler) removeMFAType(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var mfaData Def.SharedReqMfa - err = json.Unmarshal(data, &mfaData) + err := json.NewDecoder(r.Body).Decode(&mfaData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("remove mfa request"), nil, err, http.StatusBadRequest, true) } @@ -639,13 +578,9 @@ func (h ServicesApisHandler) getProfile(l *logs.Log, r *http.Request, claims *to } func (h ServicesApisHandler) updateProfile(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.Profile - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, "profile update request", nil, err, http.StatusBadRequest, true) } @@ -661,13 +596,9 @@ func (h ServicesApisHandler) updateProfile(l *logs.Log, r *http.Request, claims } func (h ServicesApisHandler) updateAccountPreferences(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var preferences map[string]interface{} - err = json.Unmarshal(data, &preferences) + err := json.NewDecoder(r.Body).Decode(&preferences) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, "account preferences update request", nil, err, http.StatusBadRequest, true) } @@ -717,13 +648,9 @@ func (h ServicesApisHandler) getAccountSystemConfigs(l *logs.Log, r *http.Reques } func (h ServicesApisHandler) updateAccountUsername(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var username Def.Username - err = json.Unmarshal(data, &username) + err := json.NewDecoder(r.Body).Decode(&username) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeAccountUsername, nil, err, http.StatusBadRequest, true) } @@ -868,13 +795,9 @@ func (h ServicesApisHandler) verifyCredential(l *logs.Log, r *http.Request, clai } func (h ServicesApisHandler) getApplicationConfigs(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.SharedReqAppConfigs - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("application config request"), nil, err, http.StatusBadRequest, true) } @@ -900,13 +823,9 @@ func (h ServicesApisHandler) getApplicationConfigs(l *logs.Log, r *http.Request, } func (h ServicesApisHandler) getApplicationOrgConfigs(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.SharedReqAppConfigsOrg - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("application org config request"), nil, err, http.StatusBadRequest, true) } @@ -934,13 +853,9 @@ func (h ServicesApisHandler) getApplicationOrgConfigs(l *logs.Log, r *http.Reque // Handler for reset password endpoint from client application func (h ServicesApisHandler) updateCredential(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { accountID := claims.Subject - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.ServicesReqCredentialUpdate - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("auth reset password client request"), nil, err, http.StatusBadRequest, true) } @@ -960,13 +875,9 @@ func (h ServicesApisHandler) updateCredential(l *logs.Log, r *http.Request, clai // Handler for reset password endpoint from reset link func (h ServicesApisHandler) forgotCredentialComplete(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.ServicesReqCredentialForgotComplete - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("auth reset password link request"), nil, err, http.StatusBadRequest, true) } @@ -986,13 +897,9 @@ func (h ServicesApisHandler) forgotCredentialComplete(l *logs.Log, r *http.Reque // Handler for forgot credential endpoint func (h ServicesApisHandler) forgotCredentialInitiate(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.ServicesReqCredentialForgotInitiate - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("auth reset password request"), nil, err, http.StatusBadRequest, true) } @@ -1007,13 +914,9 @@ func (h ServicesApisHandler) forgotCredentialInitiate(l *logs.Log, r *http.Reque // Handler for resending verify code func (h ServicesApisHandler) sendVerifyCredential(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.ServicesReqCredentialSendVerify - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("auth resend verify code request"), nil, err, http.StatusBadRequest, true) } @@ -1026,13 +929,9 @@ func (h ServicesApisHandler) sendVerifyCredential(l *logs.Log, r *http.Request, } func (h ServicesApisHandler) verifyMFA(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var mfaData Def.SharedReqMfa - err = json.Unmarshal(data, &mfaData) + err := json.NewDecoder(r.Body).Decode(&mfaData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("verify mfa request"), nil, err, http.StatusBadRequest, true) } @@ -1062,14 +961,8 @@ func (h ServicesApisHandler) verifyMFA(l *logs.Log, r *http.Request, claims *tok } func (h ServicesApisHandler) logout(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestDataData Def.PostServicesAuthLogoutJSONBody - err = json.Unmarshal(data, &requestDataData) + err := json.NewDecoder(r.Body).Decode(&requestDataData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("verify logout request"), nil, err, http.StatusBadRequest, true) } diff --git a/driver/web/apis_system.go b/driver/web/apis_system.go index 597be02ce..466a741fe 100644 --- a/driver/web/apis_system.go +++ b/driver/web/apis_system.go @@ -20,7 +20,6 @@ import ( Def "core-building-block/driver/web/docs/gen" "core-building-block/utils" "encoding/json" - "io/ioutil" "net/http" "strings" @@ -62,13 +61,9 @@ func (h SystemApisHandler) getAppOrgToken(l *logs.Log, r *http.Request, claims * // createGlobalConfig creates a global config func (h SystemApisHandler) createGlobalConfig(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.GlobalConfig - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeGlobalConfig, nil, err, http.StatusBadRequest, true) } @@ -102,13 +97,9 @@ func (h SystemApisHandler) getGlobalConfig(l *logs.Log, r *http.Request, claims // updateGlobalConfig updates global config func (h SystemApisHandler) updateGlobalConfig(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var updateConfig Def.GlobalConfig - err = json.Unmarshal(data, &updateConfig) + err := json.NewDecoder(r.Body).Decode(&updateConfig) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeGlobalConfig, nil, err, http.StatusBadRequest, true) } @@ -173,12 +164,8 @@ func (h SystemApisHandler) getApplicationOrganizations(l *logs.Log, r *http.Requ // createApplicationOrganization creates applicationOrganization func (h SystemApisHandler) createApplicationOrganization(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorData(logutils.StatusInvalid, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.ApplicationOrganization - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeApplicationOrganization, nil, err, http.StatusBadRequest, true) } @@ -201,12 +188,8 @@ func (h SystemApisHandler) updateApplicationOrganization(l *logs.Log, r *http.Re return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorData(logutils.StatusInvalid, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.ApplicationOrganization - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeApplicationOrganization, nil, err, http.StatusBadRequest, true) } @@ -224,13 +207,8 @@ func (h SystemApisHandler) updateApplicationOrganization(l *logs.Log, r *http.Re // createOrganization creates organization func (h SystemApisHandler) createOrganization(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.Organization - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeOrganization, nil, err, http.StatusBadRequest, true) } @@ -259,12 +237,8 @@ func (h SystemApisHandler) updateOrganization(l *logs.Log, r *http.Request, clai return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorData(logutils.StatusInvalid, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.Organization - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeOrganization, nil, err, http.StatusBadRequest, true) } @@ -343,13 +317,9 @@ func (h SystemApisHandler) getServiceRegistrations(l *logs.Log, r *http.Request, } func (h SystemApisHandler) registerService(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.ServiceReg - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeServiceReg, nil, err, http.StatusBadRequest, true) } @@ -368,13 +338,9 @@ func (h SystemApisHandler) registerService(l *logs.Log, r *http.Request, claims } func (h SystemApisHandler) updateServiceRegistration(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorData(logutils.StatusInvalid, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.ServiceReg - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeServiceReg, nil, err, http.StatusBadRequest, true) } @@ -452,13 +418,8 @@ func (h SystemApisHandler) registerServiceAccount(l *logs.Log, r *http.Request, fromAppID := utils.StringOrNil(r.URL.Query().Get("app_id"), "") fromOrgID := utils.StringOrNil(r.URL.Query().Get("org_id"), "") - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorData(logutils.StatusInvalid, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.ServiceAccount - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeServiceAccount, nil, err, http.StatusBadRequest, true) } @@ -485,7 +446,7 @@ func (h SystemApisHandler) registerServiceAccount(l *logs.Log, r *http.Request, serviceAccountResp := serviceAccountToDef(serviceAccount) - data, err = json.Marshal(serviceAccountResp) + data, err := json.Marshal(serviceAccountResp) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionMarshal, model.TypeServiceAccount, nil, err, http.StatusInternalServerError, false) } @@ -554,13 +515,8 @@ func (h SystemApisHandler) updateServiceAccountInstance(l *logs.Log, r *http.Req return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("org_id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorData(logutils.StatusInvalid, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.SystemReqUpdateServiceAccount - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, "service account update request", nil, err, http.StatusBadRequest, true) } @@ -581,7 +537,7 @@ func (h SystemApisHandler) updateServiceAccountInstance(l *logs.Log, r *http.Req serviceAccountResp := serviceAccountToDef(serviceAccount) - data, err = json.Marshal(serviceAccountResp) + data, err := json.Marshal(serviceAccountResp) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionMarshal, model.TypeServiceAccount, nil, err, http.StatusInternalServerError, false) } @@ -620,13 +576,8 @@ func (h SystemApisHandler) addServiceAccountCredential(l *logs.Log, r *http.Requ return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorData(logutils.StatusInvalid, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.ServiceAccountCredential - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeServiceAccountCredential, nil, err, http.StatusBadRequest, true) } @@ -640,7 +591,7 @@ func (h SystemApisHandler) addServiceAccountCredential(l *logs.Log, r *http.Requ credsResp := serviceAccountCredentialToDef(creds) - data, err = json.Marshal(credsResp) + data, err := json.Marshal(credsResp) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionMarshal, model.TypeServiceAccountCredential, nil, err, http.StatusInternalServerError, false) } @@ -721,13 +672,9 @@ func (h SystemApisHandler) getAPIKeys(l *logs.Log, r *http.Request, claims *toke } func (h SystemApisHandler) createAPIKey(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.APIKey - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeAPIKey, nil, err, http.StatusBadRequest, true) } @@ -742,13 +689,9 @@ func (h SystemApisHandler) createAPIKey(l *logs.Log, r *http.Request, claims *to } func (h SystemApisHandler) updateAPIKey(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorData(logutils.StatusInvalid, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.APIKey - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeAPIKey, nil, err, http.StatusBadRequest, true) } @@ -800,13 +743,9 @@ func (h SystemApisHandler) getApplication(l *logs.Log, r *http.Request, claims * // createApplication creates an application func (h SystemApisHandler) createApplication(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.Application - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeApplication, nil, err, http.StatusBadRequest, true) } @@ -831,13 +770,8 @@ func (h SystemApisHandler) updateApplication(l *logs.Log, r *http.Request, claim return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.Application - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeApplication, nil, err, http.StatusBadRequest, true) } @@ -871,13 +805,9 @@ func (h SystemApisHandler) getApplications(l *logs.Log, r *http.Request, claims // createPermission creates an permission func (h SystemApisHandler) createPermission(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.Permission - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypePermission, nil, err, http.StatusBadRequest, true) } @@ -892,13 +822,9 @@ func (h SystemApisHandler) createPermission(l *logs.Log, r *http.Request, claims // updatePermission updates an permission func (h SystemApisHandler) updatePermission(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.Permission - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypePermission, nil, err, http.StatusBadRequest, true) } @@ -970,13 +896,9 @@ func (h SystemApisHandler) getApplicationConfig(l *logs.Log, r *http.Request, cl } func (h SystemApisHandler) createApplicationConfig(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.ApplicationConfig - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("appconfig create request"), nil, err, http.StatusBadRequest, true) } @@ -1008,13 +930,8 @@ func (h SystemApisHandler) updateApplicationConfig(l *logs.Log, r *http.Request, return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.ApplicationConfig - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, logutils.MessageDataType("appconfig update request"), nil, err, http.StatusBadRequest, true) } @@ -1050,13 +967,8 @@ func (h SystemApisHandler) deleteApplicationConfig(l *logs.Log, r *http.Request, // createAuthTypes creates auth-type func (h SystemApisHandler) createAuthTypes(l *logs.Log, r *http.Request, claims *tokenauth.Claims) logs.HTTPResponse { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorAction(logutils.ActionRead, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } - var requestData Def.AuthType - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeOrganization, nil, err, http.StatusBadRequest, true) } @@ -1104,12 +1016,8 @@ func (h SystemApisHandler) updateAuthTypes(l *logs.Log, r *http.Request, claims return l.HTTPResponseErrorData(logutils.StatusMissing, logutils.TypeQueryParam, logutils.StringArgs("id"), nil, http.StatusBadRequest, false) } - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return l.HTTPResponseErrorData(logutils.StatusInvalid, logutils.TypeRequestBody, nil, err, http.StatusBadRequest, false) - } var requestData Def.AuthType - err = json.Unmarshal(data, &requestData) + err := json.NewDecoder(r.Body).Decode(&requestData) if err != nil { return l.HTTPResponseErrorAction(logutils.ActionUnmarshal, model.TypeOrganization, nil, err, http.StatusBadRequest, true) } From c2c31b3a895f55d9d4ff6a732f01d1da7b7fcd8c Mon Sep 17 00:00:00 2001 From: akshadpai Date: Thu, 1 Jun 2023 15:48:29 -0500 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0709588ba..4731809cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased + +## Added +- Replace ioutil.ReadAll usage [#611] (https://github.com/rokwire/core-building-block/issues/611) + ## [1.33.0] - 2023-05-02 - Username and password authentication [#658](https://github.com/rokwire/core-building-block/issues/658) From b451eab4dae17e0e86d5439a12dd96b08b507100 Mon Sep 17 00:00:00 2001 From: akshadpai Date: Thu, 1 Jun 2023 15:59:04 -0500 Subject: [PATCH 3/3] Update secrets --- .secrets.baseline | 95 ++++++++++++++++------------------------------- 1 file changed, 32 insertions(+), 63 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 7a17d3968..b7674ad3f 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -124,8 +124,7 @@ "filename": "README.md", "hashed_secret": "112bb791304791ddcf692e29fd5cf149b35fea37", "is_verified": false, - "line_number": 37, - "is_secret": false + "line_number": 37 } ], "core/app_shared.go": [ @@ -134,8 +133,7 @@ "filename": "core/app_shared.go", "hashed_secret": "44e17306b837162269a410204daaa5ecee4ec22c", "is_verified": false, - "line_number": 41, - "is_secret": false + "line_number": 41 } ], "core/auth/apis.go": [ @@ -144,8 +142,7 @@ "filename": "core/auth/apis.go", "hashed_secret": "394e3412459f79523e12e1fa95a4cf141ccff122", "is_verified": false, - "line_number": 2095, - "is_secret": false + "line_number": 2095 } ], "core/auth/auth.go": [ @@ -154,32 +151,28 @@ "filename": "core/auth/auth.go", "hashed_secret": "417355fe2b66baa6826739a6d8006ab2ddcf5186", "is_verified": false, - "line_number": 151, - "is_secret": false + "line_number": 151 }, { "type": "Secret Keyword", "filename": "core/auth/auth.go", "hashed_secret": "700f93e97a8aaf0664601a8f298ac5ad0ff13c37", "is_verified": false, - "line_number": 153, - "is_secret": false + "line_number": 153 }, { "type": "Secret Keyword", "filename": "core/auth/auth.go", "hashed_secret": "58f3388441fbce0e48aef2bf74413a6f43f6dc70", "is_verified": false, - "line_number": 933, - "is_secret": false + "line_number": 933 }, { "type": "Secret Keyword", "filename": "core/auth/auth.go", "hashed_secret": "94a7f0195bbbd2260c4e4d02b6348fbcd90b2b30", "is_verified": false, - "line_number": 2440, - "is_secret": false + "line_number": 2440 } ], "core/auth/auth_type_email.go": [ @@ -188,56 +181,49 @@ "filename": "core/auth/auth_type_email.go", "hashed_secret": "f3f2fb17a3bf9f307cb6e79b61b9d4baf07dd681", "is_verified": false, - "line_number": 75, - "is_secret": false + "line_number": 75 }, { "type": "Secret Keyword", "filename": "core/auth/auth_type_email.go", "hashed_secret": "fe70d8c51780596c0b3399573122bba943a461da", "is_verified": false, - "line_number": 76, - "is_secret": false + "line_number": 76 }, { "type": "Secret Keyword", "filename": "core/auth/auth_type_email.go", "hashed_secret": "06354d205ab5a3b6c7ad2333c58f1ddc810c97ba", "is_verified": false, - "line_number": 87, - "is_secret": false + "line_number": 87 }, { "type": "Secret Keyword", "filename": "core/auth/auth_type_email.go", "hashed_secret": "7cbe6dcf7274355d223e3174e4d8a7ffb55a9227", "is_verified": false, - "line_number": 156, - "is_secret": false + "line_number": 156 }, { "type": "Secret Keyword", "filename": "core/auth/auth_type_email.go", "hashed_secret": "69411040443be576ce64fc793269d7c26dd0866a", "is_verified": false, - "line_number": 253, - "is_secret": false + "line_number": 253 }, { "type": "Secret Keyword", "filename": "core/auth/auth_type_email.go", "hashed_secret": "cba104f0870345d3ec99d55c06441bdce9fcf584", "is_verified": false, - "line_number": 390, - "is_secret": false + "line_number": 390 }, { "type": "Secret Keyword", "filename": "core/auth/auth_type_email.go", "hashed_secret": "c74f3640d83fd19d941a4f44b28fbd9e57f59eef", "is_verified": false, - "line_number": 391, - "is_secret": false + "line_number": 391 } ], "core/auth/auth_type_oidc.go": [ @@ -246,8 +232,7 @@ "filename": "core/auth/auth_type_oidc.go", "hashed_secret": "0ade4f3edccc8888bef404fe6b3c92c13cdfad6b", "is_verified": false, - "line_number": 376, - "is_secret": false + "line_number": 376 } ], "core/auth/auth_type_username.go": [ @@ -256,48 +241,42 @@ "filename": "core/auth/auth_type_username.go", "hashed_secret": "86f4f81d8dcd41f5f695464a3bba658467957bb3", "is_verified": false, - "line_number": 64, - "is_secret": false + "line_number": 64 }, { "type": "Secret Keyword", "filename": "core/auth/auth_type_username.go", "hashed_secret": "d6f3638bf6ffed24773951f1a48460efa6766362", "is_verified": false, - "line_number": 65, - "is_secret": false + "line_number": 65 }, { "type": "Secret Keyword", "filename": "core/auth/auth_type_username.go", "hashed_secret": "06354d205ab5a3b6c7ad2333c58f1ddc810c97ba", "is_verified": false, - "line_number": 77, - "is_secret": false + "line_number": 77 }, { "type": "Secret Keyword", "filename": "core/auth/auth_type_username.go", "hashed_secret": "7cbe6dcf7274355d223e3174e4d8a7ffb55a9227", "is_verified": false, - "line_number": 179, - "is_secret": false + "line_number": 179 }, { "type": "Secret Keyword", "filename": "core/auth/auth_type_username.go", "hashed_secret": "cba104f0870345d3ec99d55c06441bdce9fcf584", "is_verified": false, - "line_number": 215, - "is_secret": false + "line_number": 215 }, { "type": "Secret Keyword", "filename": "core/auth/auth_type_username.go", "hashed_secret": "c74f3640d83fd19d941a4f44b28fbd9e57f59eef", "is_verified": false, - "line_number": 216, - "is_secret": false + "line_number": 216 } ], "core/auth/service_static_token.go": [ @@ -306,8 +285,7 @@ "filename": "core/auth/service_static_token.go", "hashed_secret": "44e17306b837162269a410204daaa5ecee4ec22c", "is_verified": false, - "line_number": 78, - "is_secret": false + "line_number": 78 } ], "driven/emailer/adapter.go": [ @@ -316,8 +294,7 @@ "filename": "driven/emailer/adapter.go", "hashed_secret": "9df4524d2441f00999342c4541a39932198d4bb4", "is_verified": false, - "line_number": 70, - "is_secret": false + "line_number": 70 } ], "driven/profilebb/adapter.go": [ @@ -326,8 +303,7 @@ "filename": "driven/profilebb/adapter.go", "hashed_secret": "36c48d6ac9d10902792fa78b9c2d7d535971c2cc", "is_verified": false, - "line_number": 224, - "is_secret": false + "line_number": 221 } ], "driven/storage/database.go": [ @@ -336,8 +312,7 @@ "filename": "driven/storage/database.go", "hashed_secret": "6547f385c6d867e20f8217018a4d468a7d67d638", "is_verified": false, - "line_number": 209, - "is_secret": false + "line_number": 209 } ], "driver/web/apis_system.go": [ @@ -346,8 +321,7 @@ "filename": "driver/web/apis_system.go", "hashed_secret": "44e17306b837162269a410204daaa5ecee4ec22c", "is_verified": false, - "line_number": 700, - "is_secret": false + "line_number": 651 } ], "driver/web/docs/gen/def.yaml": [ @@ -356,8 +330,7 @@ "filename": "driver/web/docs/gen/def.yaml", "hashed_secret": "448ed7416fce2cb66c285d182b1ba3df1e90016d", "is_verified": false, - "line_number": 55, - "is_secret": false + "line_number": 55 } ], "driver/web/docs/gen/gen_types.go": [ @@ -366,8 +339,7 @@ "filename": "driver/web/docs/gen/gen_types.go", "hashed_secret": "c9739eab2dfa093cc0e450bf0ea81a43ae67b581", "is_verified": false, - "line_number": 1673, - "is_secret": false + "line_number": 1673 } ], "driver/web/docs/resources/admin/auth/login.yaml": [ @@ -376,8 +348,7 @@ "filename": "driver/web/docs/resources/admin/auth/login.yaml", "hashed_secret": "448ed7416fce2cb66c285d182b1ba3df1e90016d", "is_verified": false, - "line_number": 26, - "is_secret": false + "line_number": 26 } ], "driver/web/docs/resources/services/auth/account/auth-type/link.yaml": [ @@ -386,8 +357,7 @@ "filename": "driver/web/docs/resources/services/auth/account/auth-type/link.yaml", "hashed_secret": "448ed7416fce2cb66c285d182b1ba3df1e90016d", "is_verified": false, - "line_number": 26, - "is_secret": false + "line_number": 26 } ], "driver/web/docs/resources/services/auth/login.yaml": [ @@ -396,10 +366,9 @@ "filename": "driver/web/docs/resources/services/auth/login.yaml", "hashed_secret": "448ed7416fce2cb66c285d182b1ba3df1e90016d", "is_verified": false, - "line_number": 24, - "is_secret": false + "line_number": 24 } ] }, - "generated_at": "2023-05-02T15:15:38Z" + "generated_at": "2023-06-01T20:57:30Z" }