-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Feature request: Token policies for subtrees #1007
Comments
A closely related use case would be to have a token restricted to ACME challenges only. As they are located at |
The question is how to efficiently select the correct policy in the database, matching the subname of the RRset that is being modified. We don't want to pull all potential policies from the database with filtering done in Python. Currently, we have a single database query that, given Just brainstorming, one way would be to use Postgres' Further, if we went this route, the question is then how to apply the LIKE operator in Django. Django does have support via lookups like Finally, more complications arise if multiple wildcards match, e.g., when a policy for And how about multiple wildcards, such as Questions over questions. Input appreciated! |
Makes sense. I already had a brief look at the code and wondered how to approach this without resorting to filtering in Python.
There's also POSIX regex matching, which does seem to not treat
Django has a regex lookup. Implementing a generic But
Tricky, indeed. It's a bit of an edge case though, so it's probably OK to implement it in any way that seems feasible and document it.
An easy way out would be to forbid multiple wildcards. I think a single wildcard (or even only "wildcard-labels") would be useful enough to have, if it simplifies implementation or eliminates some corner cases. |
We'd prefer not to go full-scale regex, due to DoS risk from exponential backtracking and other things, including perhaps ways that haven't been identified yet.
True, and it's simple enough.
The pattern is on the right hand side of the Thinking about this more, I am now realizing that this kind of query probably won't be able to use indexes (at least not the default type), so it may not scale well. Hmm, we have to think harder. I'll look into the possibility of specialized indexes a bit.
Sure; OTOH, it's always best to think it over a few more times to see if there isn't a generalized solution (which often also is simpler in code). So, I'd like to let this particular point sit for a bit, to be decided later. Exchanges like this are helpful, thanks! (For example, I only realized the indexes problem just now. Who knows what else will come to mind as we discuss further.) |
I've given the user-visible design some more thought (leaving implementation challenge aside) and the following seems clean to me: Proving full wildcard-support to the user leads to the questions about precedence that you raised and for which there does not seem to be a obvious and intuitive answer.
If only a single wildcard-label is allowed, precedence of policies seems straightforward: Non-wildcard policies first, otherwise prefer most specific one, i.e. left-most wildcard. Single-label wildcards (
Allowing multiple wildcard-label (e.g. Implementation-wise, this looks rather tricky, unfortunately. With these simplified rules, you could translate between "user-rules" and "database-rules" (i.e. patterns or regexes, whichever you prefer) on input and translate back when returning the policies to the user. Regex-escaping is readily available, Using regex matching seems rather safe in this context since you don't have to deal with untrusted regexes (assuming the regex-escaping works as advertised). So you could use them if PostgreSQL has support for left-hand-side matching and if they provide any benefit over the simpler I do not think the distinction between I don't have any idea how to get the precedence rules into a database query, as you currently have it. The more I think about this idea, the more I realize how difficult this gets. But I still think I'd be awesome to have it :) |
I would like to automate DKIM key rotation and create a suitably restricted token for this purpose, i.e. allow writing TXT records under any subname like
<selector>._domainkey
but nothing else. Unfortunately, token policies currently do not allow that.Setting a policy for subname
_domainkey
does not allow writing to its "children".Setting a policy for
*._domainkey
only allows writing the wildcard record.Setting a policy for every selector I need in advance would work but is infeasible (DKIM selectors are commonly dates or random strings).
Setting a policy without a subname works, but obviously also allows writing unrelated TXT records (e.g. DMARC policy, SPF, site verifications, ACME and whatnot). I can block some other subnames with additional policies, but that seems error-prone.
I'd be great if token policies could be extended to have a "and children"-bit. That way I could set up a policy that allows writing to
_domainkey
"and children".Given the hierarchical structure of DNS, I believe this might have sensible applications beside DKIM key rotation.
The text was updated successfully, but these errors were encountered: