Skip to content

Commit 8686202

Browse files
committed
Merge branch 'master' into pr/1
2 parents d6c1ed9 + 73be0d8 commit 8686202

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

cmd/accounts_storage.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const (
5858
// │ └── root accounts directory
5959
// └── "path" option
6060
type AccountsStorage struct {
61+
noEmail bool
6162
userID string
6263
rootPath string
6364
rootUserPath string
@@ -68,8 +69,14 @@ type AccountsStorage struct {
6869

6970
// NewAccountsStorage Creates a new AccountsStorage.
7071
func NewAccountsStorage(ctx *cli.Context) *AccountsStorage {
71-
// TODO: move to account struct? Currently MUST pass email.
72-
email := getEmail(ctx)
72+
var userID string
73+
noEmail := ctx.IsSet("no-email")
74+
if noEmail {
75+
userID = "default"
76+
} else {
77+
// TODO: move to account struct?
78+
userID = getEmail(ctx)
79+
}
7380

7481
serverURL, err := url.Parse(ctx.String(flgServer))
7582
if err != nil {
@@ -79,10 +86,11 @@ func NewAccountsStorage(ctx *cli.Context) *AccountsStorage {
7986
rootPath := filepath.Join(ctx.String(flgPath), baseAccountsRootFolderName)
8087
serverPath := strings.NewReplacer(":", "_", "/", string(os.PathSeparator)).Replace(serverURL.Host)
8188
accountsPath := filepath.Join(rootPath, serverPath)
82-
rootUserPath := filepath.Join(accountsPath, email)
89+
rootUserPath := filepath.Join(accountsPath, userID)
8390

8491
return &AccountsStorage{
85-
userID: email,
92+
noEmail: noEmail,
93+
userID: userID,
8694
rootPath: rootPath,
8795
rootUserPath: rootUserPath,
8896
keysPath: filepath.Join(rootUserPath, baseKeysFolderName),
@@ -110,6 +118,9 @@ func (s *AccountsStorage) GetRootUserPath() string {
110118
}
111119

112120
func (s *AccountsStorage) GetUserID() string {
121+
if s.noEmail {
122+
return ""
123+
}
113124
return s.userID
114125
}
115126

cmd/flags.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ func CreateFlags(defaultPath string) []cli.Flag {
7272
Aliases: []string{"m"},
7373
Usage: "Email used for registration and recovery contact.",
7474
},
75+
&cli.BoolFlag{
76+
Name: "no-email",
77+
Aliases: []string{"M"},
78+
EnvVars: []string{"LEGO_NO_EMAIL"},
79+
Usage: "Create an ACME request without including an email address.",
80+
},
7581
&cli.StringFlag{
7682
Name: flgCSR,
7783
Aliases: []string{"c"},

docs/data/zz_cli_help.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ GLOBAL OPTIONS:
2323
--server value, -s value CA hostname (and optionally :port). The server certificate must be trusted in order to avoid further modifications to the client. (default: "https://acme-v02.api.letsencrypt.org/directory") [$LEGO_SERVER]
2424
--accept-tos, -a By setting this flag to true you indicate that you accept the current Let's Encrypt terms of service. (default: false)
2525
--email value, -m value Email used for registration and recovery contact.
26+
--no-email, -M Create an ACME request without including an email address. (default: false) [$LEGO_NO_EMAIL]
2627
--csr value, -c value Certificate signing request filename, if an external CSR is to be used.
2728
--eab Use External Account Binding for account registration. Requires --kid and --hmac. (default: false) [$LEGO_EAB]
2829
--kid value Key identifier from External CA. Used for External Account Binding. [$LEGO_EAB_KID]

0 commit comments

Comments
 (0)