Skip to content

Multiple deploy keys #242

Closed
Closed

Description

@asmeurer

We currently cannot support multiple deploy keys. You need this, for instance, if you want to push to gh-pages for drdoctr/doctr and also to master of drdoctr/drdoctr.github.io (which we do want to do, to test it). See #190.

You can easily have two different deploy private key files, but the problem is that we encrypt that with a secret encryption key, which is stored in DOCTR_DEPLOY_ENCRYPTION_KEY. That key is generated when doctr configure is run, and is encrypted with the Travis public key.

So we either need to:

  1. Allow multiple encryption keys (like rename the environment variable based on the repo it is encrypted for).
  2. Allow doctr configure to create multiple deploy keys at once, each encrypted with the same encryption key.

Activity

  1. asmeurer commented on Aug 22, 2017

    @asmeurer
    MemberAuthor

    Or

    1. Skip the fernet encryption and simply encrypt the deploy key itself with the Travis public key in an environment variable (which was discussed at Allow specific users setup to deploy PR on their forks. #166).

    I don't like 2 because unlike 1 and 3, if the environment variable leaks, it leaks all deploy keys, whereas with 1 and 3 a single environment variable leaking would only leak one deploy key.

    3 would probably be best if environment variables can actually be that long (supposedly they can). That will require some testing.

  2. asmeurer commented on Aug 22, 2017

    @asmeurer
    MemberAuthor
  3. asmeurer commented on Aug 22, 2017

    @asmeurer
    MemberAuthor

    3 will be better in the long run, but 1 is easier to implement (considering that for either case, we need to continue to support the previous way of doing things).

  4. asmeurer commented on Aug 22, 2017

    @asmeurer
    MemberAuthor

    I want to brood on this for a little bit. I do want to have this fixed before we do any releases, so that the github.io stuff is actually tested. But I also don't want to make a change that we'd want to change later, since we need to support any scheme we implement indefinitely, unless we want to force people to re-configure doctr.

    @gforsyth any thoughts?

    @danielballan are you pining for a release or can you still use the git version for the time being?

  5. danielballan commented on Aug 22, 2017

    @danielballan
    Contributor

    The git version is fine.

  6. danielballan commented on Aug 22, 2017

    @danielballan
    Contributor

    Thanks for giving this so much thought today. :- )

  7. gforsyth commented on Aug 22, 2017

    @gforsyth
    Member

    Hey @asmeurer -- just back from traveling and catching up on email. I don't think I understand yet how 1 would work but I'll try to look into it more tomorrow. I think that 3 would also allow us to more easily extend doctr to CircleCI (not sure how big a priority that is).
    Agreed on holding off on releases until we're sorted on this.

  8. asmeurer commented on Aug 22, 2017

    @asmeurer
    MemberAuthor

    1 and 3 are similar. 1 would mean having something like DOCTR_DEPLOY_ENCRYPTION_KEY_DRDOCTR_DOCTR and DOCTR_DEPLOY_ENCRYPTION_KEY_DRDOCTR_DRDOCTR_GITHUB_IO and 3 would mean having DOCTR_DEPLOY_KEY_DRDOCTR_DOCTR and DOCTR_DEPLOY_KEY_DRDOCTR_DRDOCTR_GITHUB_IO. In either case we have to figure out some way to put the repo name in the environment variable name (maybe we should just hash it). The difference is that 1 would continue to use the Fernet encryption to encrypt the deploy ssh key and store the encryption key in the environment variable, and 3 would do away with the Fernet encryption and storing of the ssh key in the file and just store the ssh key in the environment variable ("stored in the environment variable" here means "encrypted with the Travis public key and then stored as a secure env var", obviously).

    The Fernet encryption is a level of indirection that seems to be unnecessary (I didn't realize at the time that the private ssh key would fit in an environment variable by itself). It also isn't really more secure because the encrypted private ssh key file is publicly available, just sitting there in the git repo, so if the Fernet encryption key (the contents of the DOCTR_DEPLOY_ENCRYPTION_KEY environment variable) were leaked, it would be no different than if the private ssh key itself were leaked. Maybe it's marginally better for a private repo (I can't imagine how you would be able to access a leaked Travis.com environment variable and not have access to the repo, but maybe it could happen).

    The indirection also makes things quite confusing as there's three secret encryption keys, the Travis public/private key, the GitHub deploy public/private key, and the Fernet key, when really you only need the first two. The Fernet encryption only seems useful if you need to encrypt something that is too large to fit in an environment variable, and must be stored in a file. I think a deploy ssh key doesn't fit this bill.

  9. asmeurer commented on Sep 1, 2017

    @asmeurer
    MemberAuthor

    Another idea. Travis lets you set a secure environment variable to just one build of a matrix by putting secure under matrix instead of global (see f61ae37, which produces this build matrix: https://travis-ci.org/drdoctr/doctr).

    I can't tell however if this could be used to provide different values for the same secure variable in different builds. If so, we could just do one build for drdoctr/doctr and one build for drdoctr/drdoctr.github.io. It would suck that you'd have to have separate builds for it, but I think our use-case of doing this is relatively rare (no one else has requested it).

    I asked about this here: https://stackoverflow.com/questions/45993334/multiple-values-of-a-secure-encrypted-environment-variable-in-travis-yml

  10. danielballan commented on Sep 1, 2017

    @danielballan
    Contributor

    Interesting. That seems like the best idea so far (if different values for the same secure variable are supported).

  11. asmeurer commented on Sep 8, 2017

    @asmeurer
    MemberAuthor

    Might punt on this for the next release. Hopefully the .github.io stuff works. Let us know if you have issues. Implementing this would be a bit of work, and there's already a lot of changes since the last release that I want to stabilize first.

  12. asmeurer commented on Nov 20, 2017

    @asmeurer
    MemberAuthor

    Fixed by #280

  13. danielballan commented on Nov 20, 2017

    @danielballan
    Contributor

    @asmeurer Heh. I saw your tweet about os.environ.keys() and figured you might be tackling this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions