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

How can I pull local_domains from table.sql_query #731

Open
figassis opened this issue Nov 12, 2024 · 1 comment
Open

How can I pull local_domains from table.sql_query #731

figassis opened this issue Nov 12, 2024 · 1 comment
Labels
new feature New feature.

Comments

@figassis
Copy link

Use case

I am building a systme where I add domains to maddy via api. I have already built the api part (if anyone finds this useful I'm happy to share). Now I'd like to, inatead of passing local_domains via ENV, read them from a postgres table, in a way that I do not need to restart maddy to make these domains visible to the modules.

Note alternatives you considered and why they are not useful.

Your idea for a solution

Tried this

table.sql_query allowed_domains {
    driver postgres
    named_args no
    dsn "postgres dsn"
    lookup "SELECT domain FROM domains where domain = $1"
    list "SELECT domain FROM domains"
}

whatever {
		modify {
                dkim {
                    domains $(primary_domain) $(local_domains) &allowed_domains
                    selector default
                    key_path dkim-keys/{domain}-{selector}.key
                    sig_expiry 120h # 5 days
                    hash sha256
                    newkey_algo rsa2048
                }
            }
}

How your solution would work in general?

Did not, domains are not in the list

  • [x ] I'm willing to help with the implementation
@figassis
Copy link
Author

Thought I'd add a POC. Currently I'm able to generate keys by pulling a list of domains from a database, as well as generate keys on the fly for new domains, on the first time they're needed.

Configuration looks like this:

table.sql_query allowed_domains {
    driver postgres
    named_args no
    dsn "postgres dsn"
    lookup "SELECT domain FROM domains where domain = $1"
    list "SELECT domain FROM domains"
}

whatever {
		modify {
                dkim {
                    domains $(primary_domain) $(local_domains)
                    selector default
                    domain_tbl &allowed_domains
                    key_path dkim-keys/{domain}-{selector}.key
                    sig_expiry 120h # 5 days
                    hash sha256
                    newkey_algo rsa2048
                }
            }
}

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

No branches or pull requests

1 participant