Macro support for PowerDNS on Rails

Posted by Kenneth Kalmer on January 04, 2009

PowerDNS, and PowerDNS on Rails forms a critical part of our infrastructure here at inX, and over the holidays I’ve been busy adding support for macros to PowerDNS on Rails.

Macros allow a DNS administrator to setup a predefined sequence of steps that will later be applied to any domain they choose, via the web interface or API access.

Where is this used? Well, lets take a simple example related around web hosting. Lets say you have zone templates configured for three data centers, one in South Africa, one in Europe and one in the US. By default you’ll probably use one of these templates when new domains are added to the system. The template might contain everything you need for web hosting and email to work. Later the client asks to be shifted to another continent, for whatever reason, and you’ll have to update a load of records for that domain.

Macros solves this by allowing you to predefine several actions which either creates, removes or updates records for the domain. Macros can then be applied on any domain to have these changes take affect on that domain.

Just like zone templates, macros are available to owners and administrators alike.

PowerDNS on Rails Macro Screen (click for full version)

PowerDNS on Rails Macro Screen (click for full version)

I’ve also started creating a new official website for the PowerDNS on Rails project, and it lives over here.

Authentication Tokens, what are they all about?

Posted by Kenneth Kalmer on October 07, 2008

Yesterday I pushed a slew of changes to the PowerDNS on Rails repo. The sole focus of the work was to extend the authentication system to have temporary authentication tokens. What are authentication tokens? Allow me to explain…

Some background

Almost all applications these days are expected to provide some kind of REST interface, over and above HTML. It is just part of the whole programmable web paradigm, and makes applications just so much more useful.

PowerDNS on Rails does sport a limited REST interface for adding new domains, and I’ll extend it over time to provide a full ActiveResource compatible interface to the system. The REST paradigm works great, make no mistake, but in a lot of cases it falls flat…

Don’t re-invent the wheel

You spend a couple of hours getting PowerDNS on Rails installed and tweaked, you even get new domain additions plugged in via the REST interface. This works great. For some of the bigger clients you provide full access to manage their own domains. They’re happy, you’re happy.

For some time this works, but then smaller clients start bothering you with requests for CNAME’s and other misc A records. Initially it doesn’t matter much, until they start realizing it takes you a minute to make the changes, so they start requesting more often, and more often, and more…

Now you sit with some tough decisions…

Rebuild PowerDNS into your own app, and leverage a full REST API.

This makes sense, since most ISP’s (us included) have some other form of management system that the clients use to add & remove domains. In a lot of cases we completely hide the complexities of the DNS system from the users, they only know about their domains, nothing else.

But why rebuild an already complete interface? Why bother when the open source community will maintain your interfaces for you?

Sold? Thought so, now you might have one option left…

Manage users & domain ownerships

This reinvents another wheel all together. Some folks might argue that PowerDNS on Rails could leverage external authentication mechanisms like LDAP… I don’t believe this will solve any problems, I believe it would only make it worse.

And once you start giving people access to the system you have to deal with forgotten password requests, amongst other things. Enabling the forgotten password request functionality for a system that performs core backbone functions is not really an option, the damage done would really hurt domain owners and users dependent on DNS…

So what is a man to do?

One possible solution

So we agreed we’re not building our own interface on top of PowerDNS on Rails’ existing one, we alse agreed that we’re not going into the external authentication debate.

So we need a mechanism that will provide the user with pre-defined access to a specific domain so they can do their own updates, without bothering us.

The mechanism should ideally have the following characteristics:

  • Linked to a user that issued the access, gives accountability
  • Linked to a specific domain, prevents snooping around the system
  • Default policy of deny everything
  • Restrict alterations to the RR’s
    • We host you mail, you can’t change the MX records
    • We host your site, you can’t change some A records
    • You cannot alter the SOA or NS records, ever
    • You can add a CNAME, then remove it later
    • Add/remove additional A records that won’t affect other hosted services
    • Protect RR’s by type (MX, A, TXT, CNAME, etc…)
  • Prevent adding RR’s
  • Prevent removing RR’s
  • An expiry mechanism, only valid until X
  • Hook into the audit trails

This is more or less the conversation our support guys would have with a person before they would login for the first time. Why have the conversation when you could restrict their movements completely? Since you provide them with the DNS and other services, its up to specify how they can enhance their naming system, or destroy it totally.

Enter authentication tokens!

Currently authentication tokens can only be created via HTTP post, and only by token_user role members. The web interface is forth coming. Authentication tokens restrict user movements to a specific domain, and specific RR’s. They have all the characteristics mentioned earlier, and the interfaces adapt dynamically to show the user only what they can do.

You can now easily hook PowerDNS on Rails into your existing systems by providing users with a ‘advanced DNS’ link. User selects, your systems asks PowerDNS on Rails for a token with the said restrictions in place, get a snippet of XML back with contains the token and full URL to the system. Then you just redirect your client to PowerDNS on Rails, et voila.

To get an idea of how to create authentication tokens, look at  spec/models/auth_token_spec.rb for complete examples. I know documentation is still an issue with the project…

And the disclaimers

In the entire history of the project this has been the first push to a public repo that hasn’t been battle tested in our production or staging environments. I’m busy setting up our staging environment for testing, and I’m sure the users will come up with some issues that will beed addressing.

I wanted to get the code out there for review as well, since I’m not an expert in application security there might be an issue or two that I’m not aware off. The code is extensively spec’ed, and if you don’t use the tokens the rest of the application still works as espected. A few minor bugs we’re squashed inadvertedly in the process, and I’ll update the tracker to reflect this.

Call for comments!

Please scrutinize the code, and give feedback. Hopefully the idea and implementation is proven solid and people can extract it for later use in other projects where the DRY principle of tokens really make a difference.

Open Source Rails projects, make sure you’re safe… 1

Posted by Kenneth Kalmer on September 27, 2008

An impending doom? Possibly. There was a thread on the Rails Core list not too long ago, titled “Cookie session security and open-source“, and they covered what seems to be an obvious security flaw. I distinctly remember following the events as it happened and thought to myself it makes a lot of sense, and yet I fell victim to the same thing.

PowerDNS on Rails uses the cookie store, and until b2ff9410de[...] had both the session key and session secret hard coded in the environment.rb file.

It came down on my like a ton of bricks when I was moderating a comment by JGeiger on my previous post (Using hoptoad in open source project deployments). I quickly jumped to fix the code using a solution put out by Trevor Turk which requires users to set both the session key and session secret in their database.yml files.

I know this is not an optimal solution, but works until the Core team (and us) have found a reasonable solution to the problem.

As part of stating the obvious (you gotta love hindsight), I recommend anyone who is running PowerDNS on Rails in a production environment to run it over SSL. Apart from session hijacking woes, having your zone data readable as plain text is just as bad as allowing zone transfers to any DNS client…

PowerDNS on Rails now sports basic audits

Posted by Kenneth Kalmer on September 25, 2008

Just as a quick update on the PowerDNS on Rails project, I’ve just pushed several updates to Github that most profoundly includes support for audits. Other smaller changes are also included, including plugin updates (HAML) and upgrading Rails to 2.0.4. As always, these updates have been running in production for a couple of hours already and has solicited some review from our support staff. Undoubtably there will be a lot of tweaks to the feature in the coming days…

Next on the radar is authentication tokens, allowing to give users one-time access to a specific domain for performing updates.

We’ll keep you posted!

  • Tags

    activerecord air amqp analytics audits bash bind capistrano cheat convert couchdb daemon-kit dlz dns elsewhere gentoo gist git hoptoad linux macros mercurial messaging mysql nginx olympics plugins postfix postini powerdns presentations projects quickies rails rake review ruby ruby19 ruote security shoes sitemap ssl svn webby
  • Recent Posts

  • Archives

  • Alltop. Seriously?! I got in?