From 377c90d39fa29cea3ce1fce098eb0571255df02d Mon Sep 17 00:00:00 2001 From: joerger Date: Wed, 30 Oct 2024 16:37:31 -0700 Subject: [PATCH] Rename package to mfatypes. --- lib/auth/{mfa/mfa.go => mfatypes/types.go} | 2 +- lib/auth/sso_mfa.go | 4 ++-- lib/auth/sso_mfa_test.go | 24 +++++++++++----------- lib/auth/webauthn/login.go | 4 ++-- lib/auth/webauthn/login_test.go | 4 ++-- lib/auth/webauthntypes/webauthn.go | 4 ++-- lib/services/sso_mfa.go | 4 ++-- 7 files changed, 23 insertions(+), 23 deletions(-) rename lib/auth/{mfa/mfa.go => mfatypes/types.go} (98%) diff --git a/lib/auth/mfa/mfa.go b/lib/auth/mfatypes/types.go similarity index 98% rename from lib/auth/mfa/mfa.go rename to lib/auth/mfatypes/types.go index 68fd022ba09f9..dd81db37e0720 100644 --- a/lib/auth/mfa/mfa.go +++ b/lib/auth/mfatypes/types.go @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -package mfa +package mfatypes import mfav1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/mfa/v1" diff --git a/lib/auth/sso_mfa.go b/lib/auth/sso_mfa.go index cd4fbb6097ce0..9441e667df8b9 100644 --- a/lib/auth/sso_mfa.go +++ b/lib/auth/sso_mfa.go @@ -26,7 +26,7 @@ import ( "github.com/gravitational/teleport/api/constants" mfav1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/mfa/v1" "github.com/gravitational/teleport/api/types" - "github.com/gravitational/teleport/lib/auth/mfa" + "github.com/gravitational/teleport/lib/auth/mfatypes" "github.com/gravitational/teleport/lib/authz" "github.com/gravitational/teleport/lib/defaults" "github.com/gravitational/teleport/lib/services" @@ -142,7 +142,7 @@ func (a *Server) upsertSSOMFASession(ctx context.Context, user string, sessionID RequestID: sessionID, ConnectorID: connectorID, ConnectorType: connectorType, - ChallengeExtensions: &mfa.ChallengeExtensions{ + ChallengeExtensions: &mfatypes.ChallengeExtensions{ Scope: ext.Scope, AllowReuse: ext.AllowReuse, }, diff --git a/lib/auth/sso_mfa_test.go b/lib/auth/sso_mfa_test.go index 4a1de559dfdad..831cbf5f26d94 100644 --- a/lib/auth/sso_mfa_test.go +++ b/lib/auth/sso_mfa_test.go @@ -34,7 +34,7 @@ import ( mfav1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/mfa/v1" "github.com/gravitational/teleport/api/types" "github.com/gravitational/teleport/lib/auth/authclient" - "github.com/gravitational/teleport/lib/auth/mfa" + "github.com/gravitational/teleport/lib/auth/mfatypes" "github.com/gravitational/teleport/lib/authz" "github.com/gravitational/teleport/lib/defaults" "github.com/gravitational/teleport/lib/services" @@ -276,7 +276,7 @@ func TestSSOMFAChallenge_Creation(t *testing.T) { Username: samlUser.GetName(), ConnectorID: samlConnector.GetName(), ConnectorType: samlConnector.GetKind(), - ChallengeExtensions: &mfa.ChallengeExtensions{ + ChallengeExtensions: &mfatypes.ChallengeExtensions{ Scope: mfav1.ChallengeScope_CHALLENGE_SCOPE_LOGIN, }, }, sd) @@ -315,7 +315,7 @@ func TestSSOMFAChallenge_Creation(t *testing.T) { Username: oidcUser.GetName(), ConnectorID: oidcConnector.GetName(), ConnectorType: oidcConnector.GetKind(), - ChallengeExtensions: &mfa.ChallengeExtensions{ + ChallengeExtensions: &mfatypes.ChallengeExtensions{ Scope: mfav1.ChallengeScope_CHALLENGE_SCOPE_LOGIN, }, }, sd) @@ -481,7 +481,7 @@ func TestSSOMFAChallenge_Validation(t *testing.T) { Username: "wrong-user", ConnectorID: samlConnector.GetName(), ConnectorType: samlConnector.GetKind(), - ChallengeExtensions: &mfa.ChallengeExtensions{ + ChallengeExtensions: &mfatypes.ChallengeExtensions{ Scope: mfav1.ChallengeScope_CHALLENGE_SCOPE_LOGIN, }, Token: "token", @@ -505,7 +505,7 @@ func TestSSOMFAChallenge_Validation(t *testing.T) { Username: samlUser.GetName(), ConnectorID: samlConnector.GetName(), ConnectorType: samlConnector.GetKind(), - ChallengeExtensions: &mfa.ChallengeExtensions{ + ChallengeExtensions: &mfatypes.ChallengeExtensions{ Scope: mfav1.ChallengeScope_CHALLENGE_SCOPE_LOGIN, }, Token: "token", @@ -529,7 +529,7 @@ func TestSSOMFAChallenge_Validation(t *testing.T) { Username: samlUser.GetName(), ConnectorID: samlConnector.GetName(), ConnectorType: samlConnector.GetKind(), - ChallengeExtensions: &mfa.ChallengeExtensions{ + ChallengeExtensions: &mfatypes.ChallengeExtensions{ Scope: mfav1.ChallengeScope_CHALLENGE_SCOPE_LOGIN, }, }, @@ -552,7 +552,7 @@ func TestSSOMFAChallenge_Validation(t *testing.T) { Username: samlUser.GetName(), ConnectorID: samlConnector.GetName(), ConnectorType: samlConnector.GetKind(), - ChallengeExtensions: &mfa.ChallengeExtensions{ + ChallengeExtensions: &mfatypes.ChallengeExtensions{ Scope: mfav1.ChallengeScope_CHALLENGE_SCOPE_LOGIN, }, Token: "token", @@ -576,7 +576,7 @@ func TestSSOMFAChallenge_Validation(t *testing.T) { Username: samlUser.GetName(), ConnectorID: samlConnector.GetName(), ConnectorType: samlConnector.GetKind(), - ChallengeExtensions: &mfa.ChallengeExtensions{ + ChallengeExtensions: &mfatypes.ChallengeExtensions{ Scope: mfav1.ChallengeScope_CHALLENGE_SCOPE_LOGIN, AllowReuse: mfav1.ChallengeAllowReuse_CHALLENGE_ALLOW_REUSE_YES, }, @@ -602,7 +602,7 @@ func TestSSOMFAChallenge_Validation(t *testing.T) { Username: noMFASAMLUser.GetName(), ConnectorID: noMFASAMLConnector.GetName(), ConnectorType: noMFASAMLConnector.GetKind(), - ChallengeExtensions: &mfa.ChallengeExtensions{ + ChallengeExtensions: &mfatypes.ChallengeExtensions{ Scope: mfav1.ChallengeScope_CHALLENGE_SCOPE_LOGIN, }, Token: "token", @@ -626,7 +626,7 @@ func TestSSOMFAChallenge_Validation(t *testing.T) { Username: standardUser.GetName(), ConnectorID: samlConnector.GetName(), ConnectorType: samlConnector.GetKind(), - ChallengeExtensions: &mfa.ChallengeExtensions{ + ChallengeExtensions: &mfatypes.ChallengeExtensions{ Scope: mfav1.ChallengeScope_CHALLENGE_SCOPE_LOGIN, }, Token: "token", @@ -650,7 +650,7 @@ func TestSSOMFAChallenge_Validation(t *testing.T) { Username: samlUser.GetName(), ConnectorID: samlConnector.GetName(), ConnectorType: samlConnector.GetKind(), - ChallengeExtensions: &mfa.ChallengeExtensions{ + ChallengeExtensions: &mfatypes.ChallengeExtensions{ Scope: mfav1.ChallengeScope_CHALLENGE_SCOPE_LOGIN, AllowReuse: mfav1.ChallengeAllowReuse_CHALLENGE_ALLOW_REUSE_NO, }, @@ -680,7 +680,7 @@ func TestSSOMFAChallenge_Validation(t *testing.T) { Username: samlUser.GetName(), ConnectorID: samlConnector.GetName(), ConnectorType: samlConnector.GetKind(), - ChallengeExtensions: &mfa.ChallengeExtensions{ + ChallengeExtensions: &mfatypes.ChallengeExtensions{ Scope: mfav1.ChallengeScope_CHALLENGE_SCOPE_LOGIN, AllowReuse: mfav1.ChallengeAllowReuse_CHALLENGE_ALLOW_REUSE_YES, }, diff --git a/lib/auth/webauthn/login.go b/lib/auth/webauthn/login.go index 5cfdc9267fbbf..2ed9f085155a6 100644 --- a/lib/auth/webauthn/login.go +++ b/lib/auth/webauthn/login.go @@ -35,7 +35,7 @@ import ( mfav1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/mfa/v1" "github.com/gravitational/teleport/api/types" - "github.com/gravitational/teleport/lib/auth/mfa" + "github.com/gravitational/teleport/lib/auth/mfatypes" wantypes "github.com/gravitational/teleport/lib/auth/webauthntypes" ) @@ -191,7 +191,7 @@ func (f *loginFlow) begin(ctx context.Context, user string, challengeExtensions if err != nil { return nil, trace.Wrap(err) } - sd.ChallengeExtensions = &mfa.ChallengeExtensions{ + sd.ChallengeExtensions = &mfatypes.ChallengeExtensions{ Scope: challengeExtensions.Scope, AllowReuse: challengeExtensions.AllowReuse, UserVerificationRequirement: challengeExtensions.UserVerificationRequirement, diff --git a/lib/auth/webauthn/login_test.go b/lib/auth/webauthn/login_test.go index 01aaf37409cbc..9995d87930fe5 100644 --- a/lib/auth/webauthn/login_test.go +++ b/lib/auth/webauthn/login_test.go @@ -34,7 +34,7 @@ import ( mfav1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/mfa/v1" "github.com/gravitational/teleport/api/types" - "github.com/gravitational/teleport/lib/auth/mfa" + "github.com/gravitational/teleport/lib/auth/mfatypes" "github.com/gravitational/teleport/lib/auth/mocku2f" wanlib "github.com/gravitational/teleport/lib/auth/webauthn" wantypes "github.com/gravitational/teleport/lib/auth/webauthntypes" @@ -442,7 +442,7 @@ func TestPasswordlessFlow_BeginAndFinish(t *testing.T) { AllowCredentials: [][]uint8{}, // aka unset ResidentKey: false, // irrelevant for login UserVerification: string(protocol.VerificationRequired), - ChallengeExtensions: &mfa.ChallengeExtensions{ + ChallengeExtensions: &mfatypes.ChallengeExtensions{ Scope: mfav1.ChallengeScope_CHALLENGE_SCOPE_PASSWORDLESS_LOGIN, AllowReuse: mfav1.ChallengeAllowReuse_CHALLENGE_ALLOW_REUSE_NO, }, diff --git a/lib/auth/webauthntypes/webauthn.go b/lib/auth/webauthntypes/webauthn.go index a0e076b64b8c6..2ae1b318a0ad0 100644 --- a/lib/auth/webauthntypes/webauthn.go +++ b/lib/auth/webauthntypes/webauthn.go @@ -27,7 +27,7 @@ import ( "github.com/go-webauthn/webauthn/webauthn" "github.com/gravitational/trace" - "github.com/gravitational/teleport/lib/auth/mfa" + "github.com/gravitational/teleport/lib/auth/mfatypes" ) // CredentialAssertion is the payload sent to authenticators to initiate login. @@ -405,7 +405,7 @@ type SessionData struct { // An empty value is treated equivalently to "discouraged". UserVerification string `json:"userVerification,omitempty"` // ChallengeExtensions are Teleport extensions that apply to this webauthn session. - ChallengeExtensions *mfa.ChallengeExtensions `json:"challenge_extensions,omitempty"` + ChallengeExtensions *mfatypes.ChallengeExtensions `json:"challenge_extensions,omitempty"` } // SessionDataFromProtocol converts a [webauthn.SessionData] struct to an diff --git a/lib/services/sso_mfa.go b/lib/services/sso_mfa.go index 4045f212191c4..a43e557fb38f6 100644 --- a/lib/services/sso_mfa.go +++ b/lib/services/sso_mfa.go @@ -18,7 +18,7 @@ package services -import "github.com/gravitational/teleport/lib/auth/mfa" +import "github.com/gravitational/teleport/lib/auth/mfatypes" // SSOMFASessionData SSO MFA Session data. type SSOMFASessionData struct { @@ -34,5 +34,5 @@ type SSOMFASessionData struct { // ConnectorType is SSO type of the corresponding Auth connector (SAML, OIDC). ConnectorType string `json:"connector_type,omitempty"` // ChallengeExtensions are Teleport extensions that apply to this SSO MFA session. - ChallengeExtensions *mfa.ChallengeExtensions `json:"challenge_extensions"` + ChallengeExtensions *mfatypes.ChallengeExtensions `json:"challenge_extensions"` }