awslabs / ssosync

Populate AWS SSO directly with your G Suite users and groups using either a CLI or AWS Lambda
Apache License 2.0
530 stars 182 forks source link

Feature: Avoid impersonation #202

Open philomory opened 5 months ago

philomory commented 5 months ago

Issue #, if available:

192

Description of changes: Replaces --google-admin (and associated environment variables, template options) with --customer-id, while incorporating @behobu's changes from #192. This allows the app to function without needing to impersonate an Google Workspace admin user.

I'm not as confident in the CF/SAM changes as I am in the code changes; if desired, I have an alternative branch I can recreate the PR using, which only changes the app code, and which would allow you to handle the templates as you see fit.

Also note that as-implemented, the code currently replaces the --google-admin option with the --customer-id option. For my own purposes, this was acceptable, even desirable, but if retaining the option to do user impersonation is desirable it probably wouldn't be too hard to adjust things so you can pass either option (though not both).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

philomory commented 5 months ago

I've just noticed that my editor seems to have made some unnecessary whitespace changes, I'll try to revert those.

bburky commented 1 month ago

Thanks, this feature looks nice. I was hoping to avoid domain-wide delegation, and impersonating a real Google account.

You could leave--google-admin as an optional argument (when omitted, use the service account).

Similarly --customer-id could be optional too, defaulting to my_customer. But it would be confusing to have these two options' defaults be opposites and incompatible. It's probably clearer to have it be a required option, and tell users to provide my_customer if they want to use domain-wide delegation to an impersonated super admin user and provide the user email as --google-admin.

(I'm not sure if there's any real advantage to an impersonated user, it seems worse to me. But supporting both may allow easier migration between them? Switching over entirely to non-impersonated seems better to me, but is a bigger breaking change.)

Because the Google docs aren't too clear on this, it's probably worth adding a note to the README to point specifically to the "Assign a role to a service account" docs section and explain how to set up the service account: https://developers.google.com/workspace/guides/create-credentials#assign_a_role_to_a_service_account