Skip to content

feat(auth): Adds ability to enable MFA on a Google Cloud Identity Platform tenant #930

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

Merged
merged 15 commits into from
Aug 11, 2020

Conversation

bojeil-google
Copy link
Contributor

@bojeil-google bojeil-google commented Jul 7, 2020

This includes the following capabilities:

  • Ability to enable / disable MFA on a tenant.
  • Configure the MFA supported type.
  • Configure the test phone number / code pairs on the tenant.

RELEASE NOTE: Added the ability to enable / disable multi-factor authentication with SMS on a Google Cloud Identity Platform tenant. Existing APIs like createTenant() and updateTenant() now support configuring multi-factor authentication and test phone number / code pairs on a specified tenant.

This includes the following capabilities:
- Ability to enable disable MFA on a tenant.
- Configure the MFA supported type.
- Configure the test phone number / code pairs on the tenant.
Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

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

Looks mostly good. Several suggestions to improve the implementation.

*/
export function generateUpdateMask(obj: {[key: string]: any}): string[] {
export function generateUpdateMask(
obj: any, maxPaths: {[key: string]: boolean} = {}, currentPath = ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we retain the type of obj as {[key: string]: any}?

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 changed it to Set<string>. I think that is the best data structure here as it is more efficient than array to check for existence.

Copy link
Contributor Author

@bojeil-google bojeil-google 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 quick review and helpful feedback!

* @param options The options object to convert to a server request.
* @return The resulting server request.
*/
public static buildServerRequest(options: MultiFactorConfig): MultiFactorAuthServerConfig {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This follows the same pattern as other config classes here. Personally, I think this is an adequate place for it. If you don't agree, I think we should then refactor the other config classes here in a separate PR to be consistent.

public toJSON(): object {
return {
state: this.state,
factorIds: this.factorIds.concat(),
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 was added to ensure that modification of the returned reference would not update class property. Anyway not a big deal. I removed it.

Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM with a comment.

*/
export function generateUpdateMask(obj: {[key: string]: any}): string[] {
export function generateUpdateMask(
obj: any, terminalPaths: Set<string> = new Set(), root = ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Set is a bit okverkill here. Let's use a regular array and terminalPaths.indexOf() to check membership. This array will be very short in practice, so performance shouldn't be an issue.

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 Set would have been ok. It is pretty lightweight and readily available to us as we are using ES6. But since the array won't grow too large, I switched to string[].

* @param options The options object to convert to a server request.
* @return The resulting server request.
*/
public static buildServerRequest(options: MultiFactorConfig): MultiFactorAuthServerConfig {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. Let's do that refactor in a future PR.

@bojeil-google bojeil-google changed the title feat(auth): Adds ability to enable MFA on a tenant. feat(auth): Adds ability to enable MFA on a Google Cloud Identity Platform tenant Aug 11, 2020
@bojeil-google bojeil-google merged commit ef33c3c into master Aug 11, 2020
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.

2 participants