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

Allows specifying external account binding credentials in Caddyfile #3492

Merged
merged 9 commits into from
Jun 12, 2020

Conversation

chrisortman
Copy link
Contributor

No description provided.

@CLAassistant
Copy link

CLAassistant commented Jun 12, 2020

CLA assistant check
All committers have signed the CLA.

@francislavoie
Copy link
Member

francislavoie commented Jun 12, 2020

Hmm. I think we want it to look more like this:

acme_ca <url> {
    key_id <value>
    hmac <value>
}

This means modifying the acme_ca parse function to handle a block (with nextBlock) with some sub-options.

@chrisortman
Copy link
Contributor Author

I initially didn't go that route because I think that means the acme_ca global option will no longer store a string and will have to store a struct? I wasn't sure if external modules might depend on being able to find global options?

I think I could make the parse work this way and but store multiple global options values, but that will break the symmetry of the way the method is right now

@francislavoie
Copy link
Member

francislavoie commented Jun 12, 2020

Well, not necessarily - the Caddyfile config and internal Go structs don't need to match 1:1.

I also don't like the current naming of the keys in the config, they're very opaque and not user-friendly. From a user's perspective, what the heck is "eab"? What's "kid"? Why is there a child in my config? 😂

Having the keys be nested within acme_ca, it's easier to understand what they're for without having a prefix on them, and you can use more user-friendly names for the options.

Take a look at parseOptOnDemand, that's the parsing approach you should take here. Make a new function parseAcmeCa. It should take one argument (the URL) and optionally, a block with some sub-options.

@chrisortman
Copy link
Contributor Author

I matched the key names to the certbot arguments with the assumption that people will probably have started with that

@francislavoie
Copy link
Member

Yeah we don't really are about what certbot does frankly 😛

We can take the opportunity to provide friendlier UX with the Caddyfile.

@chrisortman
Copy link
Contributor Author

Will changing the value stored in the global_options[acme_ca] be considered a breaking change? Are modules allowed to pull values from that map?

@mholt
Copy link
Member

mholt commented Jun 12, 2020

I agree with @francislavoie on this one -- I prefer the block syntax, to keep everything together.

I will have a chance to review in more detail this in a bit!

@francislavoie
Copy link
Member

Modules could probably pull from that map, but I can't envision any usecase where they really would. It's not important to external modules. This is config for the tls app in Caddy, and it's only a Caddyfile-specific thing.

None of the modules in this list have any business doing something like that, so I'm not concerned.

@chrisortman
Copy link
Contributor Author

chrisortman commented Jun 12, 2020

What do I do to fix the lint check? go fmt didn't change any files when I ran it ..

My mistake, I assumed go fmt was recursive on it's own.

@@ -7,7 +7,6 @@
storage file_system {
root /data
}
acme_ca https://example.com
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should leave this in, actually. That should continue to work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can put it back, I removed it so that I had something testing when the option wasn't specified at all,

@chrisortman
Copy link
Contributor Author

I suspect this is why the IBM check fails? #3493

@francislavoie
Copy link
Member

Yeah, don't mind that for the time being. We're fixing it 😄

@mholt
Copy link
Member

mholt commented Jun 12, 2020

@chrisortman Thanks for this -- I think I have a slightly better idea than what I proposed before. I'lll submit a new commit to your branch (building on what you've implemented here) in a little while and see what you think!

@mholt
Copy link
Member

mholt commented Jun 12, 2020

@chrisortman Okay, see what you think of this. Revised syntax:

{
    acme_eab {
       key_id <key>
       hmac   <hmac>
    }
}

It's separate from acme_ca but still grouped together.

Please try it out and let me know what you think!

@mholt mholt added this to the v2.1.0 milestone Jun 12, 2020
@francislavoie
Copy link
Member

francislavoie commented Jun 12, 2020

Does it need to be eab? That's so opaque. Could it just be acme_account? Docs can elaborate.

@mholt
Copy link
Member

mholt commented Jun 12, 2020

I thought about that. That's the technical, unambiguous term, though. And it's actually not the ACME account, it's specifically an external account binding -- not sure there's a way around that. The ACME account is based on your user key pair, which is managed by CertMagic according to your email parameter.

@chrisortman
Copy link
Contributor Author

I like this better, makes it so there doesn't have to be the extra ACMECaConfig struct too

@mholt
Copy link
Member

mholt commented Jun 12, 2020

@chrisortman Great! If it works for you, we'll merge this in.

@chrisortman
Copy link
Contributor Author

Yes works for me.

@chrisortman
Copy link
Contributor Author

On a side note, I did not expect that you would be able to push directly to my fork, has github always done that? Is it limited to the original owner or all collaborators?

@mholt mholt merged commit d84a5d8 into caddyserver:master Jun 12, 2020
@mholt
Copy link
Member

mholt commented Jun 12, 2020

@chrisortman I believe it has always done that. There's a checkbox you can check/uncheck when making the pull request to allow commits from maintainers. I think we can only push to the branch you propose.

@chrisortman
Copy link
Contributor Author

Thanks @mholt I have never noticed that before.

@chrisortman chrisortman deleted the eab-credentials branch June 15, 2020 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants