-
Notifications
You must be signed in to change notification settings - Fork 390
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
Conversation
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.
There was a problem hiding this 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.
src/utils/index.ts
Outdated
*/ | ||
export function generateUpdateMask(obj: {[key: string]: any}): string[] { | ||
export function generateUpdateMask( | ||
obj: any, maxPaths: {[key: string]: boolean} = {}, currentPath = '' |
There was a problem hiding this comment.
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}
?
There was a problem hiding this comment.
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.
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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.
src/auth/auth-config.ts
Outdated
public toJSON(): object { | ||
return { | ||
state: this.state, | ||
factorIds: this.factorIds.concat(), |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
src/utils/index.ts
Outdated
*/ | ||
export function generateUpdateMask(obj: {[key: string]: any}): string[] { | ||
export function generateUpdateMask( | ||
obj: any, terminalPaths: Set<string> = new Set(), root = '' |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
This includes the following capabilities:
RELEASE NOTE: Added the ability to enable / disable multi-factor authentication with SMS on a Google Cloud Identity Platform tenant. Existing APIs like
createTenant()
andupdateTenant()
now support configuring multi-factor authentication and test phone number / code pairs on a specified tenant.