Fix usage of URL in generateAdminToken

This commit is contained in:
Herman Slatman 2022-04-18 21:59:06 +02:00
parent abcad679ff
commit ff8cb19b78
No known key found for this signature in database
GPG key ID: F4D8A44EA0A75A4F

View file

@ -684,7 +684,7 @@ retry:
func (c *AdminClient) GetAuthorityPolicy() (*linkedca.Policy, error) { func (c *AdminClient) GetAuthorityPolicy() (*linkedca.Policy, error) {
var retried bool var retried bool
u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "policy")}) u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "policy")})
tok, err := c.generateAdminToken(u.Path) tok, err := c.generateAdminToken(u)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating admin token: %w", err) return nil, fmt.Errorf("error generating admin token: %w", err)
} }
@ -719,7 +719,7 @@ func (c *AdminClient) CreateAuthorityPolicy(p *linkedca.Policy) (*linkedca.Polic
return nil, fmt.Errorf("error marshaling request: %w", err) return nil, fmt.Errorf("error marshaling request: %w", err)
} }
u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "policy")}) u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "policy")})
tok, err := c.generateAdminToken(u.Path) tok, err := c.generateAdminToken(u)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating admin token: %w", err) return nil, fmt.Errorf("error generating admin token: %w", err)
} }
@ -754,7 +754,7 @@ func (c *AdminClient) UpdateAuthorityPolicy(p *linkedca.Policy) (*linkedca.Polic
return nil, fmt.Errorf("error marshaling request: %w", err) return nil, fmt.Errorf("error marshaling request: %w", err)
} }
u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "policy")}) u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "policy")})
tok, err := c.generateAdminToken(u.Path) tok, err := c.generateAdminToken(u)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating admin token: %w", err) return nil, fmt.Errorf("error generating admin token: %w", err)
} }
@ -785,7 +785,7 @@ retry:
func (c *AdminClient) RemoveAuthorityPolicy() error { func (c *AdminClient) RemoveAuthorityPolicy() error {
var retried bool var retried bool
u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "policy")}) u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "policy")})
tok, err := c.generateAdminToken(u.Path) tok, err := c.generateAdminToken(u)
if err != nil { if err != nil {
return fmt.Errorf("error generating admin token: %w", err) return fmt.Errorf("error generating admin token: %w", err)
} }
@ -812,7 +812,7 @@ retry:
func (c *AdminClient) GetProvisionerPolicy(provisionerName string) (*linkedca.Policy, error) { func (c *AdminClient) GetProvisionerPolicy(provisionerName string) (*linkedca.Policy, error) {
var retried bool var retried bool
u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "provisioner", provisionerName, "policy")}) u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "provisioner", provisionerName, "policy")})
tok, err := c.generateAdminToken(u.Path) tok, err := c.generateAdminToken(u)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating admin token: %w", err) return nil, fmt.Errorf("error generating admin token: %w", err)
} }
@ -847,7 +847,7 @@ func (c *AdminClient) CreateProvisionerPolicy(provisionerName string, p *linkedc
return nil, fmt.Errorf("error marshaling request: %w", err) return nil, fmt.Errorf("error marshaling request: %w", err)
} }
u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "provisioner", provisionerName, "policy")}) u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "provisioner", provisionerName, "policy")})
tok, err := c.generateAdminToken(u.Path) tok, err := c.generateAdminToken(u)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating admin token: %w", err) return nil, fmt.Errorf("error generating admin token: %w", err)
} }
@ -882,7 +882,7 @@ func (c *AdminClient) UpdateProvisionerPolicy(provisionerName string, p *linkedc
return nil, fmt.Errorf("error marshaling request: %w", err) return nil, fmt.Errorf("error marshaling request: %w", err)
} }
u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "provisioner", provisionerName, "policy")}) u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "provisioner", provisionerName, "policy")})
tok, err := c.generateAdminToken(u.Path) tok, err := c.generateAdminToken(u)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating admin token: %w", err) return nil, fmt.Errorf("error generating admin token: %w", err)
} }
@ -913,7 +913,7 @@ retry:
func (c *AdminClient) RemoveProvisionerPolicy(provisionerName string) error { func (c *AdminClient) RemoveProvisionerPolicy(provisionerName string) error {
var retried bool var retried bool
u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "provisioner", provisionerName, "policy")}) u := c.endpoint.ResolveReference(&url.URL{Path: path.Join(adminURLPrefix, "provisioner", provisionerName, "policy")})
tok, err := c.generateAdminToken(u.Path) tok, err := c.generateAdminToken(u)
if err != nil { if err != nil {
return fmt.Errorf("error generating admin token: %w", err) return fmt.Errorf("error generating admin token: %w", err)
} }
@ -947,7 +947,7 @@ func (c *AdminClient) GetACMEPolicy(provisionerName, reference, keyID string) (*
urlPath = path.Join(adminURLPrefix, "acme", "policy", provisionerName, "reference", reference) urlPath = path.Join(adminURLPrefix, "acme", "policy", provisionerName, "reference", reference)
} }
u := c.endpoint.ResolveReference(&url.URL{Path: urlPath}) u := c.endpoint.ResolveReference(&url.URL{Path: urlPath})
tok, err := c.generateAdminToken(u.Path) tok, err := c.generateAdminToken(u)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating admin token: %w", err) return nil, fmt.Errorf("error generating admin token: %w", err)
} }
@ -989,7 +989,7 @@ func (c *AdminClient) CreateACMEPolicy(provisionerName, reference, keyID string,
urlPath = path.Join(adminURLPrefix, "acme", "policy", provisionerName, "reference", reference) urlPath = path.Join(adminURLPrefix, "acme", "policy", provisionerName, "reference", reference)
} }
u := c.endpoint.ResolveReference(&url.URL{Path: urlPath}) u := c.endpoint.ResolveReference(&url.URL{Path: urlPath})
tok, err := c.generateAdminToken(u.Path) tok, err := c.generateAdminToken(u)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating admin token: %w", err) return nil, fmt.Errorf("error generating admin token: %w", err)
} }
@ -1031,7 +1031,7 @@ func (c *AdminClient) UpdateACMEPolicy(provisionerName, reference, keyID string,
urlPath = path.Join(adminURLPrefix, "acme", "policy", provisionerName, "reference", reference) urlPath = path.Join(adminURLPrefix, "acme", "policy", provisionerName, "reference", reference)
} }
u := c.endpoint.ResolveReference(&url.URL{Path: urlPath}) u := c.endpoint.ResolveReference(&url.URL{Path: urlPath})
tok, err := c.generateAdminToken(u.Path) tok, err := c.generateAdminToken(u)
if err != nil { if err != nil {
return nil, fmt.Errorf("error generating admin token: %w", err) return nil, fmt.Errorf("error generating admin token: %w", err)
} }
@ -1069,7 +1069,7 @@ func (c *AdminClient) RemoveACMEPolicy(provisionerName, reference, keyID string)
urlPath = path.Join(adminURLPrefix, "acme", "policy", provisionerName, "reference", reference) urlPath = path.Join(adminURLPrefix, "acme", "policy", provisionerName, "reference", reference)
} }
u := c.endpoint.ResolveReference(&url.URL{Path: urlPath}) u := c.endpoint.ResolveReference(&url.URL{Path: urlPath})
tok, err := c.generateAdminToken(u.Path) tok, err := c.generateAdminToken(u)
if err != nil { if err != nil {
return fmt.Errorf("error generating admin token: %w", err) return fmt.Errorf("error generating admin token: %w", err)
} }