2019-03-11 16:56:48 +00:00
|
|
|
package api
|
2018-12-06 21:50:17 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
2020-09-02 01:20:01 +00:00
|
|
|
"github.com/go-acme/lego/v4/acme"
|
2018-12-06 21:50:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type AuthorizationService service
|
|
|
|
|
|
|
|
// Get Gets an authorization.
|
|
|
|
func (c *AuthorizationService) Get(authzURL string) (acme.Authorization, error) {
|
2021-03-04 19:16:59 +00:00
|
|
|
if authzURL == "" {
|
2018-12-06 21:50:17 +00:00
|
|
|
return acme.Authorization{}, errors.New("authorization[get]: empty URL")
|
|
|
|
}
|
|
|
|
|
|
|
|
var authz acme.Authorization
|
|
|
|
_, err := c.core.postAsGet(authzURL, &authz)
|
|
|
|
if err != nil {
|
|
|
|
return acme.Authorization{}, err
|
|
|
|
}
|
|
|
|
return authz, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Deactivate Deactivates an authorization.
|
|
|
|
func (c *AuthorizationService) Deactivate(authzURL string) error {
|
2021-03-04 19:16:59 +00:00
|
|
|
if authzURL == "" {
|
2018-12-06 21:50:17 +00:00
|
|
|
return errors.New("authorization[deactivate]: empty URL")
|
|
|
|
}
|
|
|
|
|
|
|
|
var disabledAuth acme.Authorization
|
|
|
|
_, err := c.core.post(authzURL, acme.Authorization{Status: acme.StatusDeactivated}, &disabledAuth)
|
|
|
|
return err
|
|
|
|
}
|