diff --git a/lib/auth/webauthncli/platform_other.go b/lib/auth/webauthncli/platform_other.go new file mode 100644 index 0000000000000..62df791131543 --- /dev/null +++ b/lib/auth/webauthncli/platform_other.go @@ -0,0 +1,24 @@ +// Copyright 2021 Gravitational, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build !windows +// +build !windows + +package webauthncli + +// HasPlatformSupport returns true if the platform supports client-side +// WebAuthn-compatible logins. +func HasPlatformSupport() bool { + return true +} diff --git a/lib/auth/webauthncli/platform_windows.go b/lib/auth/webauthncli/platform_windows.go new file mode 100644 index 0000000000000..9733d74f3b187 --- /dev/null +++ b/lib/auth/webauthncli/platform_windows.go @@ -0,0 +1,21 @@ +// Copyright 2021 Gravitational, Inc +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package webauthncli + +// HasPlatformSupport returns true if the platform supports client-side +// WebAuthn-compatible logins. +func HasPlatformSupport() bool { + return false +} diff --git a/lib/client/mfa.go b/lib/client/mfa.go index 4fb082be8fa2f..e0de94f934944 100644 --- a/lib/client/mfa.go +++ b/lib/client/mfa.go @@ -57,6 +57,16 @@ func PromptMFAChallenge(ctx context.Context, proxyAddr string, c *proto.MFAAuthe // either Webauthn (preferred) or U2F. hasTOTP := c.TOTP != nil hasNonTOTP := len(c.U2F) > 0 || c.WebauthnChallenge != nil + + // Does the current platform support hardware MFA? Adjust accordingly. + switch { + case !hasTOTP && !wancli.HasPlatformSupport(): + return nil, trace.BadParameter("hardware device MFA not supported by your platform, please register an OTP device") + case !wancli.HasPlatformSupport(): + // Do not prompt for hardware devices, it won't work. + hasNonTOTP = false + } + var numGoroutines int if hasTOTP && hasNonTOTP { numGoroutines = 2