Skip to content

Commit

Permalink
Cleanup validation txt entry
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicaj committed Dec 21, 2024
1 parent e97df47 commit b3f3f34
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from middlewared.api.current import TrueNASConnectSchemaArgs
from middlewared.plugins.truenas_connect.mixin import auth_headers
from middlewared.plugins.truenas_connect.urls import LECA_DNS_URL
from middlewared.plugins.truenas_connect.urls import LECA_DNS_URL, LECA_CLEANUP_URL
from middlewared.service import CallError

from .base import Authenticator
Expand Down Expand Up @@ -50,5 +50,13 @@ def _perform_internal(self, domain, validation_name, validation_content):
logger.debug('Successfully performed %r challenge for %r domain', self.NAME, domain)

def _cleanup(self, domain, validation_name, validation_content):
# We don't have any API in place to clean existing TXT records for TNC yet
pass
logger.debug('Cleaning up %r challenge for %r domain', self.NAME, domain)
try:
requests.delete(
LECA_CLEANUP_URL, headers=auth_headers(self.attributes), timeout=30, data=json.dumps({
'hostnames': [validation_name], # We use validation name here instead of domain as Zack advised
})
)
except Exception:
# We do not make this fatal as it does not matter if we fail to clean-up
logger.debug('Failed to cleanup %r challenge for %r domain', self.NAME, domain, exc_info=True)
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
ACCOUNT_SERVICE_URL = urllib.parse.urljoin(ACCOUNT_SERVICE_BASE_URL, 'v1/accounts/{account_id}/systems/{system_id}/')
HOSTNAME_URL = urllib.parse.urljoin(ACCOUNT_SERVICE_URL, 'hostnames/')
LECA_DNS_URL = 'https://leca-server.dev.ixsystems.net/v1/dns-challenge'
LECA_CLEANUP_URL = 'https://leca-server.dev.ixsystems.net/v1/hostnames'
REGISTRATION_URI = urllib.parse.urljoin(BASE_URL, 'system/register')
REGISTRATION_FINALIZATION_URI = urllib.parse.urljoin(ACCOUNT_SERVICE_BASE_URL, 'v1/systems/finalize')

0 comments on commit b3f3f34

Please sign in to comment.