Skip to content

Commit

Permalink
Add a direct Bootstrap OTP login link in email message.
Browse files Browse the repository at this point in the history
  • Loading branch information
rgooch committed Jun 13, 2020
1 parent 78975d7 commit 8ec4d63
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/keymasterd/2fa_bootstrapOTP.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (state *RuntimeState) BootstrapOtpAuthHandler(w http.ResponseWriter,
if state.sendFailureToClientIfLocked(w, r) {
return
}
if r.Method != "POST" {
if r.Method != "GET" && r.Method != "POST" {
state.writeFailureResponse(w, r, http.StatusMethodNotAllowed, "")
return
}
Expand Down
15 changes: 11 additions & 4 deletions cmd/keymasterd/email.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ From: {{.InitiatorAddr}}
To: {{.UserAddr}}
Subject: Welcome to Keymaster
Hi, {{.Username}}. Welcome to Keymaster. Please log in to:
Hi, {{.Username}}. Welcome to Keymaster. To complete your registration, please
use the direct login link:
{{.LoginLink}}
If the direct login link does not work, please log in to:
{{.HostIdentity}}
with your username and password. After this step you will be asked to enter
with your username and password. On the next screen you will be asked to enter
your one-time passcode (Bootstrap OTP) which is:
{{.OTP}}
Expand All @@ -56,6 +60,7 @@ type bootstrapOtpEmailData struct {
HostIdentity string
InitiatorAddr string
InitiatorUser string
LoginLink string
OTP string
UserAddr string
Username string
Expand All @@ -81,8 +86,10 @@ func (state *RuntimeState) setupEmail() error {
func (state *RuntimeState) sendBootstrapOtpEmail(hash []byte, OTP string,
duration time.Duration, initiatorUser, targetUser string) error {
emailData := bootstrapOtpEmailData{
Duration: duration,
HostIdentity: state.Config.Base.HostIdentity,
Duration: duration,
HostIdentity: state.Config.Base.HostIdentity,
LoginLink: "https://" + state.Config.Base.HostIdentity +
bootstrapOtpAuthPath + "?OTP=" + OTP,
OTP: OTP,
InitiatorAddr: initiatorUser + "@" + state.Config.Email.Domain,
InitiatorUser: initiatorUser,
Expand Down

0 comments on commit 8ec4d63

Please sign in to comment.