AuthCheck allows the authenticated user to check if they have the given permissions to a set of resources.
(ctx context.Context, req AuthorizationRequest)
| 62 | // AuthCheck allows the authenticated user to check if they have the given permissions |
| 63 | // to a set of resources. |
| 64 | func (c *Client) AuthCheck(ctx context.Context, req AuthorizationRequest) (AuthorizationResponse, error) { |
| 65 | res, err := c.Request(ctx, http.MethodPost, "/api/v2/authcheck", req) |
| 66 | if err != nil { |
| 67 | return nil, err |
| 68 | } |
| 69 | defer res.Body.Close() |
| 70 | if res.StatusCode != http.StatusOK { |
| 71 | return AuthorizationResponse{}, ReadBodyAsError(res) |
| 72 | } |
| 73 | var resp AuthorizationResponse |
| 74 | return resp, json.NewDecoder(res.Body).Decode(&resp) |
| 75 | } |