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

Improve question MFA prompt #458

Merged
merged 4 commits into from
Jul 11, 2024
Merged

Improve question MFA prompt #458

merged 4 commits into from
Jul 11, 2024

Conversation

boarnoah
Copy link
Member

@boarnoah boarnoah commented Jul 3, 2024

Why

This MFA factor (which incidentally I thought we didn't allow with D2L's Okta) looked like:

Okta org short name or domain name: dev-1234.oktapreview.com
Okta username: awijayathilaka
Okta password: *******************
MFA Required
[1] OKTA-question
[2] GOOGLE-token:software:totp
Select an available MFA option: 1
Answer: <answer in plain text>
Successfully logged in and Okta session has been cached.

Now, it will mask the input for the security question (which is a static value) + prompt with the question text rather than "Answer:"

Okta org short name or domain name: dev-1234.oktapreview.com
Okta username: awijayathilaka
Okta password: *******************
MFA Required
[1] OKTA-question
[2] GOOGLE-token:software:totp
Select an available MFA option: 1
What is your favorite security question?: ****************
Successfully logged in and Okta session has been cached.

Ticket

https://desire2learn.atlassian.net/browse/VUL-400

resolves #446

@boarnoah boarnoah self-assigned this Jul 3, 2024
@boarnoah boarnoah requested a review from a team as a code owner July 3, 2024 13:25
@github-actions github-actions bot added language/csharp size/M A medium-sized PR. labels Jul 3, 2024
@boarnoah boarnoah changed the title Aw/improve mfa prompt Improve question MFA prompt Jul 3, 2024

if( mfaInput is not null ) {
return mfaInput;
}
throw new BmxException( "Invalid MFA Input" );
}

private string GetMaskedInput( string prompt ) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Refactored this masked input read to be re-usable (for GetMfaResponse)

internal record OktaMfaFactor(
string Id,
string FactorType,
string Provider,
string VendorName
string VendorName,
OktaMfaQuestionProfile Profile
Copy link
Member Author

Choose a reason for hiding this comment

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

This I really do not like.

It isn't straightforward to handle extracting nested value & do type discrimination based on FactorType for de serialization.

Without using a custom convertor at least AFAICS, so went with this approach.

Copy link
Member

Choose a reason for hiding this comment

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

Isn't this what type discriminator is designed for? I don't see the need for a custom convertor.

Copy link
Member Author

Choose a reason for hiding this comment

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

Couple of reasons,

  1. Out of order discriminator isn't in as of .NET 8 ? [JsonSerializer] Add support for out-of-order metadata reads. dotnet/runtime#97474
  2. Need a bit more of a code change to differentiate between types without FactorType as a property (to not conflict with it's use as the type discriminator)
  3. It still looks kind of silly, how even with type discrimination we would still need need to do some additional work to hoist QuestionText up from nested profile, ex:
    // Binding to a nested property in polymorphic Profile
    [EditorBrowsable( EditorBrowsableState.Never )]
    public required OktaMfaQuestionProfile Profile { get; set; }
    public string QuestionText => Profile.QuestionText;

All of which to me suggests, a custom convertor is the way to go, if we want to take it all the way (even if we discard the third point)

Copy link
Member

Choose a reason for hiding this comment

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

  1. We can use the STJ preview package.
  2. Yes, which should be straightforward.
  3. Not following... why?

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to a separate PR targeting this ( #459 )since there is a few ways we can go about this.

re: 3,
Agreed it isn't necessary. Shouldn't really manipulate the Okta API types unnecessarily, after all its all still encapsulated within the context of the Okta authentication related code (no additional leak of implementation details involved).

gord5500
gord5500 previously approved these changes Jul 3, 2024
// On Windows, Console.ReadKey calls native console API, and will fail without a console attached
if( Console.IsInputRedirected ) {
Console.Error.WriteLine( """
====== WARNING ======
Copy link
Member Author

Choose a reason for hiding this comment

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

It is going to pop this twice once for password + security question, in this case. But meh, that is a very niche edge case

@github-actions github-actions bot added size/L A large PR. Could this be broken up? and removed size/M A medium-sized PR. labels Jul 8, 2024
@boarnoah boarnoah force-pushed the aw/improve-mfa-prompt branch from 643bd10 to 3b50357 Compare July 9, 2024 13:14
gord5500
gord5500 previously approved these changes Jul 10, 2024
@boarnoah
Copy link
Member Author

boarnoah commented Jul 10, 2024

Changed separator used in factor list, now that we can't use Factor Type directly & need to use a custom pretty name for Factor

Okta org short name or domain name: dev-1234.oktapreview.com
Okta username: awijayathilaka
Okta password: *******************
MFA Required
[1] OKTA : Security Question
[2] OKTA : Call
[3] OKTA : SMS
[4] GOOGLE : Software TOTP
[5] OKTA : Software TOTP
Select an available MFA option: 1
What is your favorite security question?: ****************
Successfully logged in and Okta session has been cached.

Probably shouldn't align factor list vertically with padding since vendor name length has unknown bounds + it remains closer to the original look.

@boarnoah boarnoah merged commit 78f403b into main Jul 11, 2024
9 checks passed
@boarnoah boarnoah deleted the aw/improve-mfa-prompt branch July 11, 2024 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language/csharp size/L A large PR. Could this be broken up?
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Authentication improvements for OKTA-question choice
3 participants