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

Add DNS provider for CPanel and WHM #1977

Merged
merged 30 commits into from Feb 4, 2024
Merged

Add DNS provider for CPanel and WHM #1977

merged 30 commits into from Feb 4, 2024

Conversation

ldez
Copy link
Member

@ldez ldez commented Jul 28, 2023

  • add a description to your PR
  • have a homogeneous design with the other providers
  • add tests (units)
  • add tests ("live")
  • add a provider descriptor
  • generate CLI help, documentation, and readme.
  • be able to do: (and put the output of this command to a comment in your PR)
    make build
    rm -rf .lego
    
    CPANEL_USERNAME = "yyyy"
    CPANEL_TOKEN = "xxxx"
    CPANEL_BASE_URL = "https://somecpanel.com:2083" \
    CPANEL_NAMESERVER = "ns1.somecpanel.com:53" \
    ./dist/lego -m your@email.com --dns cpanel -d *.example.com -d example.com -s https://acme-staging-v02.api.letsencrypt.org/directory run
    Note the wildcard domain is important.
  • pass the linter
  • do go mod tidy

Ping @ssipos90, @SirexToo can you run the command (with your domain, email, and credentials)?

#1060 (comment)

Closes #1060

@ssipos90
Copy link

ssipos90 commented Aug 7, 2023

I'm no longer on this, can't help.

@seebeen
Copy link

seebeen commented Sep 25, 2023

This doesn't work on a server which uses DNS clustering.

@ldez
Copy link
Member Author

ldez commented Sep 25, 2023

ok but can you explain what I have to change? (API endpoints, options, etc.)

@seebeen
Copy link

seebeen commented Sep 25, 2023

ok but can you explain what I have to change? (API endpoints, options, etc.)

There are two contexts:

cPanel - User context

Most cPanel providers disable API access for users.
This means that the code you wrote won't work in 99% of the cases, since cPanel users won't be able to access it. 😞

WHM - Admin context (reseller and root).

This is where the server control logic lies.

You need to split the initiation context as a param - whm for root / resellers - cPanel for endusers.

WHM Calls you need are here:
https://api.docs.cpanel.net/openapi/whm/tag/DNS-Zones/

Before doing anything with DNS - serverside related - you need this.
https://api.docs.cpanel.net/openapi/whm/operation/has_local_authority/

Check if the local targeted WHM Server is authoritative for the domain in question, and then use calls from the link above to do your thing.

Source: I'm a hosting provider.

P.S. I stumbled into this convo by chance. I'll be happy to sponsor further development of this, if it means it can be integrated into traefik 😊

@ldez
Copy link
Member Author

ldez commented Sep 27, 2023

The cPanel/WHM documentation is not really clear and the API is a bit weird.

If you are able to test it and be able to provide a real API response for the different cases, I can work on that (and your sponsoring will be welcome).
This provider will be usable inside Traefik.

@seebeen
Copy link

seebeen commented Sep 27, 2023

I can Do you one better. I can give you a cPanel server and a WHM api key to test with :)

Contact me via mail (xxxx) - or discord (seebeen)

@pcastelo
Copy link

pcastelo commented Feb 3, 2024

@ldez what do you need to finish it ? , i can help

@ldez
Copy link
Member Author

ldez commented Feb 3, 2024

feel free to test the PR and suggest changes.

@pcastelo

This comment was marked as outdated.

@pcastelo

This comment was marked as outdated.

@ldez

This comment was marked as outdated.

@pcastelo

This comment was marked as outdated.

@ldez

This comment was marked as outdated.

@ldez

This comment was marked as outdated.

@ldez
Copy link
Member Author

ldez commented Feb 3, 2024

There are 5 APIs:

I don't know what is the difference between cPanel and WHM and why there are 2 completely different APIs (different path, different response format) for mainly the same things.

The comment #1977 (comment) seems to explain the difference (user/admin) but it's not clear why there are 2 contexts/APIs.

I can create 2 API clients, it's not a problem, but the usage of those APIs is cryptic.

@ldez

This comment was marked as outdated.

@pcastelo
Copy link

pcastelo commented Feb 3, 2024

letme try another call and let you know ,

thw whm is the reselle panel it can hand multiple zone from diferent user
cpanel is for end user and is limited in zones thant can handle

@pcastelo

This comment was marked as outdated.

@pcastelo

This comment was marked as outdated.

@ldez

This comment was marked as outdated.

@ldez ldez changed the title Add DNS provider for CPanel Add DNS provider for CPanel an WHM Feb 4, 2024
@ldez ldez removed the state/need-user-tests Need users to test functionality label Feb 4, 2024
@ldez ldez marked this pull request as ready for review February 4, 2024 14:53
@ldez ldez added this to the v4.16 milestone Feb 4, 2024
@ldez
Copy link
Member Author

ldez commented Feb 4, 2024

After several hours of fighting against the API and wrong API documentation, The PR is working 🎉

This PR adds the support for cPanel and WHM 🎉

Huge thanks to @pcastelo ❤️

I would also like to thank @seebeen 👍

@ldez ldez requested a review from dmke February 4, 2024 15:17
@ldez ldez changed the title Add DNS provider for CPanel an WHM Add DNS provider for CPanel and WHM Feb 4, 2024
Copy link
Member

@dmke dmke left a comment

Choose a reason for hiding this comment

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

LGTM, will need to look into the availablity of slices.Contains though.

providers/dns/cpanel/cpanel.go Show resolved Hide resolved
@ldez ldez merged commit 83ff393 into go-acme:master Feb 4, 2024
7 checks passed
@ldez ldez deleted the feat/cpanel branch February 4, 2024 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

CPanel Support
5 participants