MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / cbRBACWhoAmI

Function cbRBACWhoAmI

rest/server_context.go:2063–2079  ·  view source on GitHub ↗
(ctx context.Context, httpClient *http.Client, managementEndpoints []string, username, password string)

Source from the content-addressed store, hash-verified

2061}
2062
2063func cbRBACWhoAmI(ctx context.Context, httpClient *http.Client, managementEndpoints []string, username, password string) (response *WhoAmIResponse, statusCode int, err error) {
2064 statusCode, bodyResponse, err := doHTTPAuthRequest(ctx, httpClient, username, password, "GET", "/whoami", managementEndpoints, nil)
2065 if err != nil {
2066 return nil, http.StatusInternalServerError, err
2067 }
2068
2069 if statusCode != http.StatusOK {
2070 return nil, statusCode, nil
2071 }
2072
2073 err = base.JSONUnmarshal(bodyResponse, &response)
2074 if err != nil {
2075 return nil, http.StatusInternalServerError, err
2076 }
2077
2078 return response, statusCode, nil
2079}
2080
2081func CheckRoles(ctx context.Context, httpClient *http.Client, managementEndpoints []string, username, password string, requestedRoles []RouteRole, bucketName string) (statusCode int, err error) {
2082 whoAmIResults, statusCode, err := cbRBACWhoAmI(ctx, httpClient, managementEndpoints, username, password)

Callers 2

getCBUserRolesForAuditFunction · 0.85
CheckRolesFunction · 0.85

Calls 2

JSONUnmarshalFunction · 0.92
doHTTPAuthRequestFunction · 0.85

Tested by

no test coverage detected