-
Notifications
You must be signed in to change notification settings - Fork 5
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
Discussion: IAC / Declarative Configuration for tokens and policies #14
Comments
(deSEC hat on)
Yup. That's mainly because there would be several REST requests required (e.g., to list the policies of a token, with each policy having a dropdown for the domain it relates to, and this dropdown in turn listing the domains for selection). This requires holding more complex state; OTOH, we're reluctant to implementing this right now, as our GUI is not extremely up-to-date from a framework perspective and we should first migrate to Vuetify 3. That's a whole other can of worms and that's why not much is happing right now. Long story short, I just wanted to say that the lack of GUI should not be mistaken as a sign that the token policy API isn't stable -- in fact, it is.
That sounds like a fabulous idea, and if there's anything we can help with (especially conceptual or API discussions), happy to engage. |
There certainly is.
For the record: There is also import and export of records as JSON. Same data though, just a different file format.
I'm in on that 🙂 Naming policies and the concept of policy sets seem great for more human-friendly policy management. I don't think the API currently provides any support for this, so they will need to be stored in a local file, such a your proposed I'd appreciate implementing and submitting the small changes first, if that makes any sense to you. Helps making the pull requests more easily reviewable. YAML is the modern go-to for infrastructure as code, so I suppose that's pretty much set. A detail question, though: And finally a note on the time line: Implementing and testing a big change like this takes its time anyway, but I'd like to get a package published to PyPI before that. So that'll be my personal priority for now. However, don't let that stop you from having a go at this. |
Do you think uniqueness should be enforced on token names? |
From the API view point: No. Token names are optional anyway and I always regarded them as kind of comment/annotation. UUIDs are technically sufficient to uniquely identify a token, so why have another unique identifier? From the API consumer view point: Names are a nice alternative to UUIDs when working with tokens. But they are only as reliable as the user's own naming convention. That makes them tricky to use in software, but I'm OK with supporting them only for users who choose to keep (a subset of) their token names unique. |
Oh wow, great to see the enthusiasm here! :)
By that you mean first implementing a config file format and corresponding operations for domains and records? :)
Hmm, I think it wouldn't be too hard to support both. YAML and JSON are quite interoperable.
Yes the tokens
bob:
# Since no name attribute is set, we use the "symbolic" name in the markup
# => token.name = bob
policies: developer
alice:
name: "Personal token of Alice"
# => token.name = "Personal token of Alice"
policies: developer
I think we should just abort if we can't uniquely resolve a name from a config file to a token from the api. What would be nice is the ability to get tokens "by name". Think: I would try to avoid having a local "mapping" that can get out of sync as far as we can.
Yes, I think the first step would be a "spec" for this anyway. |
I suggest adding a prefix (
Mh. That requires an extra database index, but why not. Care to file a PR? ;-) |
Yes, something like a function to roll (or copy) tokens or to resolve a token name to the UUID (assuming no changes in the API).
Technically, yes. But I wonder if it justifies the more complex UI.
That actually moves the "key" that lets us reference the token inside the YAML mapping/dict. Users might get the idea that they can add/remove/change the name and still reference the same "alice" token, just as they can do with policy sets, etc.
Makes sense but also makes me wish I had chosen a better name back when I started this project 😉
I don't have time for a PR and it's easy enough to do downstream. But if anyone else wants to do it, I'd happily make use of it 🙂 |
Hmm, I am either missunderstanding you here or I want to challenge that notion. In any case I think the discussion could benefit from an explicit distinction. There is the name we give resources inside the yaml / config file. In the example we have Finally we have the actual identifiers used by the api, simply called id:
@peterthomassen please correct me if I got any of this wrong! Now, when "applying" (parts of) a config file, we will always undergo these steps:
For now my focus is on step 1 and 2: In principle, any referencing between resources within the config file should always happen by symbolic name. Note that in the current example, all resources that you might want to reference have a symbolic name given by their yaml mapping key. We potentially have concepts in our config file that do not exist in the api, such as Domain and RRSet will still require carefull design of the config language, but for them it is a bit easier since they have "natural" ids. There will not be any touching point between symbolic names and the api. Tokens and policies are different because they have api-side ids. Let's do policies first, because they are easier: Which leaves to tokens which I think that is the only tricky part: But I think a principled solution could be this: Case 1: The token config only has a symbolic name tokens:
alice:
policies:
...
# equivalent:
alice:
name: desec-dns/alice
policies:
... Case 2: The token config has a tokens:
alice:
name: "Alice's personal token"
policies:
... Case 3: The token config has an tokens:
some_legacy_token:
id: 3a6b94b5-d20e-40bd-a7cc-521f5c79fab3
policies:
...
Well, they can change the symbolic name, as long as they set |
Yes, what you describe is basically what I envision, too.
My concern is not about users changing the symbolic name on a whim. It's a YAML key, so I believe it's fairly intuitive to assume that changing it breaks existing references, i.e. the mapping between symbolic name and API name. An example to make my point clear: tokens:
alice:
policies: ... User finds out about the tokens:
alice:
name: "Alice's personal token"
policies: ... On deployment, the user may be surprised when the API name of Alice's existing token does not change but a new token is created instead. Most likely, that surprise comes after deleting the weirdly named old token manually or by using Not implementing case 2 in the first place would prevent this kind of surprise. Unfortunately, it also limits interoperability with other tools (if we enforce a prefix on the API name). |
Now I understand. Two suggestions:
tokens:
alice:
identifier:
id: 3a6b94b5-d20e-40bd-a7cc-521f5c79fab3
policies:
...
alice:
identifier:
name: desec-dns/alice
policies:
...
alice: # Implicitly equivalent to the one above
policies:
...
|
Good ideas, both. I think, I like the second one better. |
You should also be able to PATCH/PUT them.
You could call the attribute |
I would like to discuss whether there is interest for adding "Infrastructure as Code"-Style support for tokens and policies to this project and if yes, how it should look like.
Lets start off with the observation that we already have an IAC feature: Importing / Exporting Zone files. But there is more to desec than just dns records!
The two features of the desec api that are an absolute killer feature to me are tokens and policies. Desec is, to the best of my knowledge, the only DNS provider outside of big pubic cloud providers like AWS and CloudFlare that allows fine grained access control for managing dns records. However the tooling support is rather thin at the moment, not even desecs own web-gui supports setting policies yet.
With desec-dns we have a cli to manage policies but I would like to take it a little further. I am envisioning something like
docker compose
for desec-tokens, that I want to demonstrate based on the snippets below.Imagine having a yaml file like this:
Then, you run
desec
commands in a dir with atokens.yml
or pass one explicitly with some flag.Rolling tokens:
$ desec tokens -c ~/my-tokens.yml roll bob Deleted old token. Creating new token. Setting policies. Created token bob: abcdefgh123
Deleting:
Pruning:
Why not implement that in terraform?
I am sympathetic to that idea as well, especially since there already is a terraform-provider for desec. As far as I understand though, it doesn't have support for managing tokens and policies yet. Also I am really not sure how one would implement features like the proposed
desec tokens roll
and I am not sure how much control providers have over the output of terraform for printing the secret in case one doesn't want to put it in a file.The text was updated successfully, but these errors were encountered: