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

Revert "Remove 2FA bypass (#47288)" #49671

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ const (

// MinimumEtcdVersion is the minimum version of etcd supported by Teleport
MinimumEtcdVersion = "3.3.0"

// EnvVarAllowNoSecondFactor is used to allow disabling second factor auth
// todo(tross): DELETE WHEN ABLE TO
EnvVarAllowNoSecondFactor = "TELEPORT_ALLOW_NO_SECOND_FACTOR"
)

const (
Expand Down
10 changes: 6 additions & 4 deletions lib/auth/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"errors"
"fmt"
"log/slog"
"os"
"slices"
"strings"
"sync"
Expand Down Expand Up @@ -786,14 +787,15 @@ func initializeAuthPreference(ctx context.Context, asrv *Server, newAuthPref typ
}

if !shouldReplace {
if err := modules.ValidateResource(storedAuthPref); err != nil {
if os.Getenv(teleport.EnvVarAllowNoSecondFactor) != "true" {
err := modules.ValidateResource(storedAuthPref)
rosstimothy marked this conversation as resolved.
Show resolved Hide resolved
if errors.Is(err, modules.ErrCannotDisableSecondFactor) {
return trace.Wrap(err, secondFactorUpgradeInstructions)
}

return trace.Wrap(err)
if err != nil {
return trace.Wrap(err)
}
}

return nil
}

Expand Down
6 changes: 5 additions & 1 deletion lib/modules/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"crypto"
"errors"
"fmt"
"os"
"runtime"
"sync"
"time"
Expand Down Expand Up @@ -332,7 +333,10 @@ var ErrCannotDisableSecondFactor = errors.New("cannot disable multi-factor authe

// ValidateResource performs additional resource checks.
func ValidateResource(res types.Resource) error {
if GetModules().Features().Cloud || !IsInsecureTestMode() {
// todo(tross): DELETE WHEN ABLE TO [remove env var, leave insecure test mode]
if GetModules().Features().Cloud ||
(os.Getenv(teleport.EnvVarAllowNoSecondFactor) != "yes" && !IsInsecureTestMode()) {

switch r := res.(type) {
case types.AuthPreference:
if !r.IsSecondFactorEnforced() {
Expand Down
Loading