Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update LiveDNS endpoint and the docs URL #2

Merged
merged 3 commits into from
Sep 21, 2022

Conversation

Themimitoof
Copy link
Contributor

Since April 2020 we (Gandi) have deprecated the old LiveDNS endpoint in favor of the new one that is part of our public API project.

This PR update the endpoint but also the link to the new documentation.

cc @grigouze @romuald

@romuald
Copy link

romuald commented Dec 4, 2020

Nicely spotted, however this is not enough ^^

The authentication mechanism did change between the 2 endpoints:
you need to authenticate on api.gandi.net with an Authorization: apikey XXXX header instead of X-API-Key: XXXX

@mholt mholt requested a review from obynio December 4, 2020 16:34
@Themimitoof
Copy link
Contributor Author

Thanks @romuald for the review, I just pushed a commit to update this part 😉.

@obynio
Copy link
Collaborator

obynio commented Dec 5, 2020

@Themimitoof Thank you for your PR, I'll take a look to ensure the endpoints are the same before making the switch. However your new API is still shown as being in beta and this plugin is being used for production systems. Do you believe the new API is mature enough to be used in production ?

The documentation explicitly states Please note that this API is currently in BETA testing, so care should be taken when used in production

Copy link
Collaborator

@obynio obynio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a first glance, it appears the https://api.gandi.net/v5/livedns/domains endpoint has changed and the attribute zone_records_href from the previous API has vanished.

Unfortunately for some silly reason of mine I was using this attribute here and there to make my requests. Could you replace the domain.ZoneRecordsHref currently used to make requests by domain.DomainRecordsHref ?

Copy link
Collaborator

@obynio obynio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the when using the domain_records_href instead of the zone_records_href attribute we can submit both relative and absolute names for this endpoint.

That's good, it means I we may finally ditch that hack I'm not so proud of and use either wiki.gconfs.fr. and wiki to manipulate zones. Can you make this change also ?

@obynio
Copy link
Collaborator

obynio commented Dec 5, 2020

I think I've listed everything that is needed to make the plugin works with the new endpoint.
Feel free to drop me a line if you need help.

@obynio
Copy link
Collaborator

obynio commented Dec 13, 2020

@Themimitoof any news on this ?

@Themimitoof
Copy link
Contributor Author

Hello @obynio, unfortunately, I don't have enough bandwidth lately. I hope to be able to work on it this weekend.

Have you a test procedure to try to test locally before requesting you a new review?

@obynio
Copy link
Collaborator

obynio commented Dec 14, 2020

We are lucky enough to have a very easy way to spin out a dev environment using xcaddy. It allows you to build and run caddy with your development plugin in two commands. https://github.com/caddyserver/xcaddy#for-plugin-development

You can configure a simple Caddyfile like this one. Replace the domain by one you own.

pad.leon.re {
	tls {
		dns gandi {env.GANDI_API_TOKEN}
	}
	respond "Hello, world!"
}

Then in the directory of the plugin you're working on run xcaddy

$ xcaddy run --config Caddyfile

Then xcaddy will fetch the caddy sources, compile it with your plugin and run immediately.
If you need help feel free to reach out to me 👍

Since April 2020 we (Gandi) have deprecated the old LiveDNS endpoint
in favor of the new one that is part of our public API project.

This commit update the endpoint but also the link to the new
documentation.
The new public API now uses `Authentication: Apikey <Apikey>` header to
authenticate requests.
@@ -15,11 +15,10 @@ func (p *Provider) setRecord(ctx context.Context, zone string, record libdns.Rec
p.mutex.Lock()
defer p.mutex.Unlock()

// there is some strange regexp in the api that prevents us from searching names ending with a dot
// so we must ensure the names of the record is relative and does not end with a dot
recRelativeName := strings.TrimRight(strings.TrimSuffix(record.Name, domain.Fqdn), ".")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact no we don't have a strange regexp in the api but this is a normal behavior.

When you specify this record in your BIND zone:

hello.skusku.pw    IN   A    3600    127.0.0.1

The record will be available in hello.skusku.pw.skusku.pw because we wasn't added the point to mark the end of the FQDN (also named absolute record in the RFC1035 (Domain names that end in a dot are called
absolute, and are taken as complete
).

I think you already know that, just as reminder ;)

@@ -7,20 +7,20 @@ This package implements the [libdns interfaces](https://github.com/libdns/libdns

## Authenticating

This package supports **API Key authentication** but does not yet support **Sharing ID authentication**. Refer to the [LiveDNS documentation](https://doc.livedns.gandi.net/) for more information.
This package only supports **API Key authentication**. Refer to the [Gandi's Public API documentation](https://api.gandi.net/docs/reference/#Authentication) for more information.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sharing ids are not an authentication mechanism. In fact a sharing id is the identifier of an organization.

@Themimitoof
Copy link
Contributor Author

Themimitoof commented Dec 20, 2020

Hello @obynio 👋

Here is my modifications to make the module working this the new LiveDNS API. I tested a couple of times and adding/append and deleting records works fine.

It was the first time I played with Go, it was fun to understand how the module works and to contribute to it 😅

The documentation explicitly states Please note that this API is currently in BETA testing, so care should be taken when used in production

Soon it will disappear, don't worry about that 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants