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

Add second_factors #47233

Merged
merged 14 commits into from
Oct 11, 2024
Merged

Add second_factors #47233

merged 14 commits into from
Oct 11, 2024

Conversation

Joerger
Copy link
Contributor

@Joerger Joerger commented Oct 4, 2024

Add second_factors and prefer it over second_factor.

We don't currently plan on removing second_factor, as this would require a more complicated migration process. Instead we will just derive second_factors from second_factor (and vice versa) and output a warning log when second_factor is set.

There is no plan to deprecate second_factor completely. When second_factor is set and second_factors is not, or vice versa, we convert from one to the other.

In a follow up PR I will update as much logic as possible to use second_factors instead of second_factor, as they are two sources of the same information.

In this PR I've also added the SSO second_factor type. It is currently completely unused, but we'd rather get the proto changes into v17 rather than waiting until SSO MFA is fully released in a minor version.

Follow up TODO: Update docs.

Changelog: Add new second_factors field to cluster auth preference for more clarity and granularity over which 2fa methods are enabled in a cluster.

Depends on #47230

@Joerger Joerger changed the title Joerger/add second factors Add second_Factors Oct 4, 2024
@Joerger Joerger force-pushed the joerger/add-second-factors branch from 3e32b81 to d536667 Compare October 4, 2024 21:24
@Joerger Joerger marked this pull request as ready for review October 4, 2024 21:24
@github-actions github-actions bot requested review from gzdunek and tigrato October 4, 2024 21:24
@Joerger Joerger force-pushed the joerger/add-second-factors branch 2 times, most recently from cd71433 to 10c8b33 Compare October 4, 2024 21:32
@Joerger Joerger mentioned this pull request Oct 5, 2024
@zmb3 zmb3 added the release-notes A reminder label to into the release notes of the Teleport Release. label Oct 5, 2024
api/proto/teleport/legacy/types/types.proto Show resolved Hide resolved
api/types/authentication.go Show resolved Hide resolved
api/types/authentication.go Outdated Show resolved Hide resolved
@Joerger Joerger requested a review from tigrato October 7, 2024 19:58
Copy link
Contributor

@codingllama codingllama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the separate PR, Brian! Apologies for the delay.

api/types/authentication.go Outdated Show resolved Hide resolved
api/types/authentication.go Show resolved Hide resolved
api/types/authentication.go Outdated Show resolved Hide resolved
api/types/authentication.go Outdated Show resolved Hide resolved
api/types/authentication.go Outdated Show resolved Hide resolved
api/types/authentication.go Outdated Show resolved Hide resolved
default:
slog.WarnContext(context.Background(), "Found unknown second_factor setting", "second_factor", sf)
return "" // Unsure, say nothing.
return nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this error instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just validate SecondFactor in CheckAndSetDefaults.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would erroring here make for a clearer error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib/config/fileconf.go Outdated Show resolved Hide resolved
lib/config/fileconf.go Outdated Show resolved Hide resolved
lib/config/fileconf.go Show resolved Hide resolved
@Joerger Joerger changed the base branch from joerger/enum-helper to master October 8, 2024 18:40
@Joerger Joerger force-pushed the joerger/add-second-factors branch from a170f2f to 653babe Compare October 8, 2024 19:20
api/types/authentication.go Outdated Show resolved Hide resolved
api/types/second_factor.go Outdated Show resolved Hide resolved
api/types/second_factor.go Outdated Show resolved Hide resolved
api/types/second_factor.go Outdated Show resolved Hide resolved
api/types/second_factor.go Outdated Show resolved Hide resolved
api/types/second_factor.go Outdated Show resolved Hide resolved
@Joerger Joerger requested a review from codingllama October 8, 2024 19:45
@Joerger Joerger force-pushed the joerger/add-second-factors branch 2 times, most recently from a543532 to 06ce4f1 Compare October 9, 2024 01:16
Copy link

github-actions bot commented Oct 9, 2024

🤖 Vercel preview here: https://docs-4jw07zxys-goteleport.vercel.app/docs/ver/preview

api/types/authentication.go Outdated Show resolved Hide resolved
@@ -771,6 +775,16 @@ func (c *AuthPreferenceV2) CheckAndSetDefaults() error {
return trace.BadParameter("missing required Webauthn configuration for headless=true")
}

// Prevent accidental local lockout by disabling local second factor methods, (likely leaving only sso enabled).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we get test coverage for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api/types/authentication.go Outdated Show resolved Hide resolved
api/types/second_factor.go Outdated Show resolved Hide resolved
api/types/authentication.go Outdated Show resolved Hide resolved
@Joerger Joerger changed the title Add second_Factors Add second_factors Oct 10, 2024
@Joerger Joerger added this pull request to the merge queue Oct 10, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 10, 2024
@Joerger Joerger added this pull request to the merge queue Oct 10, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 10, 2024
Copy link

🤖 Vercel preview here: https://docs-6xrjugnkq-goteleport.vercel.app/docs/ver/preview

@Joerger Joerger added this pull request to the merge queue Oct 11, 2024
github-merge-queue bot pushed a commit that referenced this pull request Oct 11, 2024
* Add proto.

* Add decoding logic for SecondFactorType.

* Update auth preference methods to use and prefer SecondFactors.

* Add fileconf and warning logs.

* Fix tests.

* Address comments.

* Address comments.

* Validate SecondFactor; Disallow SecondFactor and SecondFactors to both be set.

* Address comments.

* Treat second factor SSO as SecondFactor=on; Prevent local user lockout when SSO is the only enabled MFA method; Ensure SecondFactors=[] is disallowed.

* Upate terraform schema, docs, crds.

* Address comments.

* Address comments.

* Fix lint, fix test.
Merged via the queue into master with commit dbe08e0 Oct 11, 2024
42 of 43 checks passed
@Joerger Joerger deleted the joerger/add-second-factors branch October 11, 2024 00:35
mvbrock pushed a commit that referenced this pull request Oct 16, 2024
* Add proto.

* Add decoding logic for SecondFactorType.

* Update auth preference methods to use and prefer SecondFactors.

* Add fileconf and warning logs.

* Fix tests.

* Address comments.

* Address comments.

* Validate SecondFactor; Disallow SecondFactor and SecondFactors to both be set.

* Address comments.

* Treat second factor SSO as SecondFactor=on; Prevent local user lockout when SSO is the only enabled MFA method; Ensure SecondFactors=[] is disallowed.

* Upate terraform schema, docs, crds.

* Address comments.

* Address comments.

* Fix lint, fix test.
@zmb3
Copy link
Collaborator

zmb3 commented Nov 12, 2024

@Joerger did we ever got docs updates for this one?

@Joerger
Copy link
Contributor Author

Joerger commented Nov 12, 2024

@Joerger did we ever got docs updates for this one?

No not yet, it's on my TODO list, along with SSO MFA docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes A reminder label to into the release notes of the Teleport Release. size/md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants