Skip to content

Commit

Permalink
Merge pull request #65 from rgooch/self-service-bootstrap
Browse files Browse the repository at this point in the history
Add UserHasRegistered2ndFactor field to user profile.
  • Loading branch information
cviecco committed Jun 5, 2020
2 parents 20b3b55 + 61df6d2 commit d3b9076
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions cmd/keymasterd/2fa_totp.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ func (state *RuntimeState) validateNewTOTP(w http.ResponseWriter, r *http.Reques
newIndex := newTOTPAuthData.CreatedAt.Unix()
profile.TOTPAuthData[newIndex] = &newTOTPAuthData
profile.PendingTOTPSecret = nil
profile.UserHasRegistered2ndFactor = true
err = state.SaveUserProfile(authUser, profile)
if err != nil {
logger.Printf("Saving profile error: %v", err)
Expand Down
9 changes: 5 additions & 4 deletions cmd/keymasterd/2fa_u2f.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"encoding/json"
"fmt"
"net/http"
"strings"
"time"
Expand Down Expand Up @@ -166,14 +167,14 @@ func (state *RuntimeState) u2fRegisterResponse(w http.ResponseWriter, r *http.Re
CreatedAt: time.Now(),
CreatorAddr: r.RemoteAddr,
}
if authUser != assumedUser {
newReg.Name = fmt.Sprintf("Registered by %s", authUser)
}
newIndex := newReg.CreatedAt.Unix()
profile.U2fAuthData[newIndex] = &newReg
//registrations = append(registrations, *reg)
//counter = 0

logger.Printf("Registration success: %+v", reg)

profile.RegistrationChallenge = nil
profile.UserHasRegistered2ndFactor = true
err = state.SaveUserProfile(assumedUser, profile)
if err != nil {
logger.Printf("Saving profile error: %v", err)
Expand Down
1 change: 1 addition & 0 deletions cmd/keymasterd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ type userProfile struct {
LastSuccessfullTOTPCounter int64
TOTPAuthData map[int64]*totpAuthData
BootstrapOTP bootstrapOTPData
UserHasRegistered2ndFactor bool
}

type localUserData struct {
Expand Down

0 comments on commit d3b9076

Please sign in to comment.