Skip to content

Add OTP fallback for SSHAgentMFAWebSessionLogin#57133

Merged
okraport merged 6 commits intomasterfrom
okraport/weblogin-otp-fallback
Jul 24, 2025
Merged

Add OTP fallback for SSHAgentMFAWebSessionLogin#57133
okraport merged 6 commits intomasterfrom
okraport/weblogin-otp-fallback

Conversation

@okraport
Copy link
Copy Markdown
Contributor

@okraport okraport commented Jul 24, 2025

In the case Teleport second_factor is set to on, it is possible for a user to only have OTP configured. Prior to this commit this would result in a auth fail as the created challenge only supported TOTP.

Server side would recieve an incomplete AuthenticateWebUserRequest object, which fails validation via CheckAndSetDefaults and as such only a failed login audit event was emitted with no additional logs.

This mode of failure can be reproduced with
tsh bench -d web sessions --auth=local.

changelog: Fixed fallback for web login when second factor is set to on but only OTP is configured.

okraport added 2 commits July 24, 2025 11:30
In the case Teleport `second_factor` is set to `on`,
it is possible for a user to only have OTP configured.
Prior to this commit this would result in a auth fail
as the created challenge only supported TOTP.

Server side would recieve an incomplete `AuthenticateWebUserRequest`
object, which fails validation via `CheckAndSetDefaults` and
as such only a failed login audit event was emitted with no
additional logs.

This mode of failure can be reproduced with
`tsh bench -d web sessions --auth=local`.

changelog: Fixed fallback for web login when second factor is set to `on` but only OTP is configured.
Comment thread lib/client/weblogin.go Outdated
Comment thread lib/client/weblogin.go Outdated
}

// sshAgentLoginWebCreateSession takes an existing client and login details and attempts to create a web session using OTP token
func sshAgentLoginWebCreateSession(ctx context.Context, clt *WebClient, login SSHLoginDirect) (*WebClient, types.WebSession, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we take a WebClient there's no need to return it (potentially niled).

Suggested change
func sshAgentLoginWebCreateSession(ctx context.Context, clt *WebClient, login SSHLoginDirect) (*WebClient, types.WebSession, error) {
func sshAgentLoginWebCreateSession(ctx context.Context, clt *WebClient, login SSHLoginDirect) (types.WebSession, error) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I pass it through to keep the caller code simpler, so the call site would be:

session, err := sshAgentLoginWebCreateSession(ctx, clt, SSHLoginDirect{})
return clt, session, err

Instead of just:

return sshAgentLoginWebCreateSession(ctx, clt, SSHLoginDirect{})

Nilling the client on error is consistent with the callers and so I have kept it the same, let me know if that changes your mind!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree with Edoard, this function signature feels off.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay dokay, ask and you shall receive! Updated, I restructured sshAgentMFAWebSessionLogin to fit and I think it looks better now!

Comment thread lib/client/weblogin.go Outdated
Comment thread lib/client/weblogin.go Outdated
okraport and others added 3 commits July 24, 2025 05:33
Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
@okraport okraport requested a review from rosstimothy July 24, 2025 12:47
@okraport okraport marked this pull request as ready for review July 24, 2025 12:59
@github-actions github-actions bot requested review from hugoShaka and juliaogris July 24, 2025 12:59
@rosstimothy rosstimothy requested a review from espadolini July 24, 2025 14:54
@okraport okraport added this pull request to the merge queue Jul 24, 2025
Merged via the queue into master with commit f71f14e Jul 24, 2025
40 checks passed
@okraport okraport deleted the okraport/weblogin-otp-fallback branch July 24, 2025 17:51
@backport-bot-workflows
Copy link
Copy Markdown
Contributor

@okraport See the table below for backport results.

Branch Result
branch/v16 Failed
branch/v17 Failed
branch/v18 Create PR

okraport added a commit that referenced this pull request Jul 25, 2025
* Add OTP fallback for SSHAgentMFAWebSessionLogin

In the case Teleport `second_factor` is set to `on`,
it is possible for a user to only have OTP configured.
Prior to this commit this would result in a auth fail
as the created challenge only supported TOTP.

Server side would recieve an incomplete `AuthenticateWebUserRequest`
object, which fails validation via `CheckAndSetDefaults` and
as such only a failed login audit event was emitted with no
additional logs.

This mode of failure can be reproduced with
`tsh bench -d web sessions --auth=local`.

changelog: Fixed fallback for web login when second factor is set to `on` but only OTP is configured.

* improve errors for unsupported web login mfa challenge

* Update lib/client/weblogin.go

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* Update lib/client/weblogin.go

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* unexport SSHAgentMFAWebSessionLogin and SSHAgentLoginWeb

* update sshAgentLoginWebCreateSession signature

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
okraport added a commit that referenced this pull request Jul 25, 2025
* Add OTP fallback for SSHAgentMFAWebSessionLogin

In the case Teleport `second_factor` is set to `on`,
it is possible for a user to only have OTP configured.
Prior to this commit this would result in a auth fail
as the created challenge only supported TOTP.

Server side would recieve an incomplete `AuthenticateWebUserRequest`
object, which fails validation via `CheckAndSetDefaults` and
as such only a failed login audit event was emitted with no
additional logs.

This mode of failure can be reproduced with
`tsh bench -d web sessions --auth=local`.

changelog: Fixed fallback for web login when second factor is set to `on` but only OTP is configured.

* improve errors for unsupported web login mfa challenge

* Update lib/client/weblogin.go

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* Update lib/client/weblogin.go

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* unexport SSHAgentMFAWebSessionLogin and SSHAgentLoginWeb

* update sshAgentLoginWebCreateSession signature

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
github-merge-queue bot pushed a commit that referenced this pull request Jul 25, 2025
* Add OTP fallback for SSHAgentMFAWebSessionLogin

In the case Teleport `second_factor` is set to `on`,
it is possible for a user to only have OTP configured.
Prior to this commit this would result in a auth fail
as the created challenge only supported TOTP.

Server side would recieve an incomplete `AuthenticateWebUserRequest`
object, which fails validation via `CheckAndSetDefaults` and
as such only a failed login audit event was emitted with no
additional logs.

This mode of failure can be reproduced with
`tsh bench -d web sessions --auth=local`.

changelog: Fixed fallback for web login when second factor is set to `on` but only OTP is configured.

* improve errors for unsupported web login mfa challenge

* Update lib/client/weblogin.go



* Update lib/client/weblogin.go



* unexport SSHAgentMFAWebSessionLogin and SSHAgentLoginWeb

* update sshAgentLoginWebCreateSession signature

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
github-merge-queue bot pushed a commit that referenced this pull request Jul 25, 2025
* Add OTP fallback for SSHAgentMFAWebSessionLogin

In the case Teleport `second_factor` is set to `on`,
it is possible for a user to only have OTP configured.
Prior to this commit this would result in a auth fail
as the created challenge only supported TOTP.

Server side would recieve an incomplete `AuthenticateWebUserRequest`
object, which fails validation via `CheckAndSetDefaults` and
as such only a failed login audit event was emitted with no
additional logs.

This mode of failure can be reproduced with
`tsh bench -d web sessions --auth=local`.

changelog: Fixed fallback for web login when second factor is set to `on` but only OTP is configured.

* improve errors for unsupported web login mfa challenge

* Update lib/client/weblogin.go



* Update lib/client/weblogin.go



* unexport SSHAgentMFAWebSessionLogin and SSHAgentLoginWeb

* update sshAgentLoginWebCreateSession signature

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants