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

AliyunDNSFullAccess too wide #16

Open
panhaoyu opened this issue May 7, 2022 · 5 comments
Open

AliyunDNSFullAccess too wide #16

panhaoyu opened this issue May 7, 2022 · 5 comments

Comments

@panhaoyu
Copy link

panhaoyu commented May 7, 2022

Hello, nice work.

A suggestion. AliyunDNSFullAccess is too wide, for I will provide the website access permission to others.
Could you please check the minimum permission required?

I'm trying, and after finish, I will provide my experience here.

@tengattack
Copy link
Owner

tengattack commented Feb 5, 2023

You may need custom RAM policy like:

{
    "Version": "1",
    "Statement": [
        {
            "Action": "*",
            "Resource": "acs:alidns:*:*:domain/example.com",
            "Effect": "Allow"
        }
    ]
}

to limit access only for one domain.

@Igotit
Copy link

Igotit commented May 11, 2023

@tengattack need to add another statement:

{
    "Action": [
        "alidns:DescribeSiteMonitorIspInfos",
        "alidns:DescribeSiteMonitorIspCityInfos",
        "alidns:DescribeSupportLines",
        "alidns:DescribeDomains",
        "alidns:DescribeDomainNs",
        "alidns:DescribeDomainGroups"
    ],
    "Resource": "acs:alidns:*:*:*",
    "Effect": "Allow"
}

ref: https://help.aliyun.com/document_detail/61723.html

@bolyage
Copy link

bolyage commented Mar 7, 2024

It doesn't work for me.

RAM policy

{
    "Version": "1",
    "Statement": [
        {
            "Action": "*",
            "Resource": "acs:alidns:*:*:domain/aaaaaa.com",
            "Effect": "Allow"
        }
    ]
}

log

+ docker run -ti --rm -v /data/services/certbot-dns-aliyun/scripts/credentials:/root/.secrets -v /data/services/certbot-dns-aliyun/scripts/letsencrypt:/etc/letsencrypt -v /data/services/certbot-dns-aliyun/scripts/nginx:/etc/nginx/conf.d certbot/dns-aliyun -c /etc/letsencrypt/cli.ini
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Requesting a certificate for *.aaaaaa.com and *.dev.aaaaaa.com
Encountered exception during recovery: certbot_dns_aliyun.alidns.AliError: User not authorized to operate on the specified resource, or this API doesn't support RAM
An unexpected error occurred:
certbot_dns_aliyun.alidns.AliError: User not authorized to operate on the specified resource, or this API doesn't support RAM
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.

@tengattack
Copy link
Owner

@bolyage Try add another statement in Statement mentioned by @Igotit

@bolyage
Copy link

bolyage commented Apr 7, 2024

@bolyage Try add another statement in Statement mentioned by @Igotit

I have found another way to make it work, using ResourceGroup to isolate resources.

  1. Modify alidns.py : add ResourceGroupId param.
import os
....
    def _find_domain_id(self, domain):
        domain_name_guesses = dns_common.base_domain_name_guesses(domain)

        for domain_name in domain_name_guesses:
            r = self._request('DescribeDomains', {
                'KeyWord': domain_name,
                'ResourceGroupId': os.environ.get('ALIDNS_RESOURCE_GROUP_ID'),
            })
            for d in r['Domains']['Domain']:
                if d['DomainName'] == domain_name:
                    return domain_name

        raise errors.PluginError('Unable to determine zone identifier for {0} using zone names: {1}'
                                 .format(domain, domain_name_guesses))
  1. Modify get cret docker run command: add ALIDNS_RESOURCE_GROUP_ID and mount alidns.py.
docker run -it --rm \
    -e "ALIYUN_AK=xxxxxx" \
    -e "ALIYUN_SK=xxxxxx" \
    -e "EMAIL=xxxxxx" \
    -e "ALIDNS_RESOURCE_GROUP_ID=xxxxx" \
    -v /data/cert/xxxxx:/etc/letsencrypt/ \
    -v /data/certbot-dns-aliyun-docker/alidns.py:/opt/certbot/lib/python3.8/site-packages/certbot_dns_aliyun/alidns.py \
    certbot obtain_cert \
    -d "xxxxx.com" \
    -d "*.xxxx.com"
  1. Modify renew docker run command : add ALIDNS_RESOURCE_GROUP_ID and mount alidns.py.
docker run -it --rm \
    -e "ALIDNS_RESOURCE_GROUP_ID=xxxxxx" \
    -v /data/cert:/etc/letsencrypt/ \
    -v /data/services/certbot-dns-aliyun-docker/alidns.py:/opt/certbot/lib/python3.8/site-packages/certbot_dns_aliyun/alidns.py \
    certbot renew_certs

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

No branches or pull requests

4 participants