Fix AP group access on API proxy

This commit is contained in:
Paul Tyng
2021-03-07 10:59:52 -05:00
parent c55b43115b
commit 23f4659d36
2 changed files with 10 additions and 4 deletions

View File

@@ -28,7 +28,7 @@ type APGroup struct {
func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error) {
var respBody []APGroup
err := c.do(ctx, "GET", fmt.Sprintf("/v2/api/site/%s/apgroups", site), nil, &respBody)
err := c.do(ctx, "GET", fmt.Sprintf("%s/site/%s/apgroups", c.apiV2Path, site), nil, &respBody)
if err != nil {
return nil, err
}
@@ -66,7 +66,7 @@ func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error
func (c *Client) CreateAPGroup(ctx context.Context, site string, d *APGroup) (*APGroup, error) {
var respBody APGroup
err := c.do(ctx, "POST", fmt.Sprintf("/v2/api/site/%s/apgroups", site), d, &respBody)
err := c.do(ctx, "POST", fmt.Sprintf("%s/site/%s/apgroups", c.apiV2Path, site), d, &respBody)
if err != nil {
return nil, err
}

View File

@@ -17,7 +17,10 @@ import (
const (
apiPath = "/api"
apiV2Path = "/v2/api"
apiPathNew = "/proxy/network/api"
apiV2PathNew = "/proxy/network/v2/api"
loginPath = "/api/login"
loginPathNew = "/api/auth/login"
@@ -49,6 +52,7 @@ type Client struct {
baseURL *url.URL
apiPath string
apiV2Path string
loginPath string
statusPath string
@@ -115,6 +119,7 @@ func (c *Client) setAPIUrlStyle(ctx context.Context) error {
if resp.StatusCode == http.StatusOK {
// the new API returns a 200 for a / request
c.apiPath = apiPathNew
c.apiV2Path = apiV2PathNew
c.loginPath = loginPathNew
c.statusPath = statusPathNew
return nil
@@ -122,6 +127,7 @@ func (c *Client) setAPIUrlStyle(ctx context.Context) error {
// The old version returns a "302" (to /manage) for a / request
c.apiPath = apiPath
c.apiV2Path = apiV2Path
c.loginPath = loginPath
c.statusPath = statusPath
return nil