// BootstrapUsers creates the initial admin user for the database, and sets // the initial password. func BootstrapUsers(st *state.State, cfg *config.Config, passwordHash string) error { logger.Debugf("adding admin user") // Set up initial authentication. u, err := st.AddUser("admin", "") if err != nil { return err } // Note that at bootstrap time, the password is set to // the hash of its actual value. The first time a client // connects to mongo, it changes the mongo password // to the original password. logger.Debugf("setting password hash for admin user") if err := u.SetPasswordHash(passwordHash); err != nil { return err } if err := st.SetAdminMongoPassword(passwordHash); err != nil { return err } return nil }