Fixed some more rbac issues, v2022.03.15

This commit is contained in:
2022-03-15 01:39:12 +09:00
parent c2272e3816
commit 4fe54aabf0
5 changed files with 140 additions and 50 deletions
+6 -2
View File
@@ -24,6 +24,7 @@ type FreeDNSOperations interface {
type FreeDNS struct {
AuthCookie *http.Cookie
DomainId string
LoggedOut bool
}
const URI_LOGIN = "https://freedns.afraid.org/zc.php?step=2"
@@ -73,6 +74,8 @@ func _HttpRequest(method string, url string, PostData url.Values, ExCookie *http
return nil, "", err
}
req.Header.Set("User-Agent", "github.com/tgckpg/cert-manager-webhook-freedns (2022.03.15)")
if ExCookie != nil {
req.AddCookie(ExCookie)
}
@@ -112,6 +115,7 @@ func (dnsObj *FreeDNS) Login(Username string, Password string) error {
for _, cookie := range resp.Cookies() {
if cookie.Name == "dns_cookie" {
dnsObj.AuthCookie = cookie
dnsObj.LoggedOut = false
}
}
@@ -119,7 +123,7 @@ func (dnsObj *FreeDNS) Login(Username string, Password string) error {
}
func (dnsObj *FreeDNS) Logout() error {
if dnsObj.AuthCookie == nil {
if dnsObj.LoggedOut {
return nil
}
@@ -128,7 +132,7 @@ func (dnsObj *FreeDNS) Logout() error {
return err
}
dnsObj.AuthCookie = nil
dnsObj.LoggedOut = true
return nil
}