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

supporting google authenticator with Okta auth #14985

Merged
merged 7 commits into from
Apr 14, 2022

Conversation

hghaf099
Copy link
Contributor

@hghaf099 hghaf099 commented Apr 8, 2022

When authenticating via Okta, Vault does not recognize the Google provider TOTP type.
Addresses #14535

@vercel vercel bot temporarily deployed to Preview – vault April 8, 2022 23:48 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 8, 2022 23:48 Inactive
@hghaf099 hghaf099 requested a review from kalafut April 11, 2022 12:38
@vercel vercel bot temporarily deployed to Preview – vault April 11, 2022 12:42 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 11, 2022 12:42 Inactive
@kalafut kalafut removed their request for review April 11, 2022 15:10
Copy link
Contributor

@raskchanky raskchanky left a comment

Choose a reason for hiding this comment

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

The change itself looks ok. Do you mind adding some tests to cover this new functionality?

@hghaf099
Copy link
Contributor Author

The change itself looks ok. Do you mind adding some tests to cover this new functionality?

I have tested it manually, as it would need Okta credentials. I will push the manual script into the vault-tools repo shortly. Do you still think a GO test would be needed?

@hghaf099 hghaf099 requested a review from calvn April 11, 2022 19:25
@hghaf099 hghaf099 marked this pull request as ready for review April 12, 2022 15:48
@hghaf099 hghaf099 requested a review from a team April 12, 2022 15:48
@vercel vercel bot temporarily deployed to Preview – vault April 12, 2022 22:06 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 12, 2022 22:12 Inactive
changelog/14985.txt Outdated Show resolved Hide resolved
Comment on lines +183 to +185
if preferredProvider != "" && preferredProvider != v.Provider {
continue
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this check necessary, or does the strutil.ListContains call below handle this already (both the empty provider case and the matching provider checks)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is needed. Suppose I enabled Google totp, and Okta push and totp on my account. Then, this loop goes through an array containing all three enabled providers methods as the result.Embedded.Factors is populated by the third party Okta api. In this case, suppose I pass in the Google totp to the login command. However, when the loop ends, the totp factor could be populated by the okta totp. Then, MFA validation fails since I have passed in the Google totp code. The reason I introduced the provider in the command line is this. Cause without it, there is no way to distinguish whether the totp code is for Okta or Google.
The below strutil.ListContains just makes sure that we only accept Google and Okta as there are more providers than these two as mentioned in the Okta documentation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yes that makes sense! Somehow I overlooked where preferredProvider is coming from.

Choose a reason for hiding this comment

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

Does this mean that if I only have Google TOTP enabled, that I'd have to explicitly set Google as the provider? Because that seems like an unworkable situation -- our org has folks with a mix of either Okta Verify or Google TOTP (but not Okta TOTP), and we can't know in advance which provider to use.

Insisting that the provider be specified should only be required if both Okta and Google TOTP are present.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, if you only have Google TOTP enabled in your Okta account, you don't need to pass in the provider, as result.Embedded.Factors would only have one element. The problem raises when in a single Okta account, both Okta TOTP and Google TOTP are enabled as possible providers. Here, you would need to pass in the provider. Note that if you have enabled Okta Push and Google TOTP, you would NOT need to pass in the provider.

Choose a reason for hiding this comment

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

Thanks for clarifying @hghaf099! 🙇‍♂️

Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com>
@vercel vercel bot temporarily deployed to Preview – vault April 13, 2022 02:11 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 13, 2022 02:11 Inactive
Copy link
Contributor

@calvn calvn left a comment

Choose a reason for hiding this comment

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

One last nit: Can we also update the docs page to make a mention of the new provider parameter that's present on the login endpoint?

@hghaf099
Copy link
Contributor Author

Should this be backported as well?

@calvn
Copy link
Contributor

calvn commented Apr 13, 2022

This is more of an enhancement/improvement than a bug, so I'd think that it doesn't need to be backported.

@hghaf099 hghaf099 merged commit 3def286 into main Apr 14, 2022
@hghaf099 hghaf099 deleted the okta-auth-enable-google-authenticator-totp branch April 14, 2022 12:37
kitography pushed a commit that referenced this pull request Apr 24, 2022
* supporting google authenticator with Okta auth

* minor fix

* CL

* feedback

* Update changelog/14985.txt

Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com>

* updating docs

Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com>
schultz-is pushed a commit that referenced this pull request Apr 27, 2022
* supporting google authenticator with Okta auth

* minor fix

* CL

* feedback

* Update changelog/14985.txt

Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com>

* updating docs

Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com>
schultz-is pushed a commit that referenced this pull request May 2, 2022
* supporting google authenticator with Okta auth

* minor fix

* CL

* feedback

* Update changelog/14985.txt

Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com>

* updating docs

Co-authored-by: Calvin Leung Huang <1883212+calvn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants