getredash / redash

Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data.
http://redash.io/
BSD 2-Clause "Simplified" License
26.32k stars 4.37k forks source link

Add `hd` parameter for optimized Google Apps login #1924

Open benmanns opened 7 years ago

benmanns commented 7 years ago

https://github.com/getredash/redash/blob/53268989c5fe5c619b399b488094c501cb286af4/redash/authentication/google_oauth.py#L91

Would it be possible to add the hd parameter to this authorization URL in the event that there's a single allowed Google Apps domain? It optimizes the sign in experience by limiting the suggested accounts to those for the passed Google domain.

If you're signed in to a single account on the domain and already authorized Redash: instant redirect to login.

If you're signed in on the domain and haven't authorized Redash: present only accounts from the authorized Google domain.

screen shot 2017-08-09 at 3 36 34 pm

If you're not signed in: present the login dialog with your domain pre-filled.

screen shot 2017-08-09 at 3 33 25 pm

If you're interested in merging something like this but can't prioritize this as a feature I can put together a PR with the changes required.

arikfr commented 7 years ago

Just to make sure I understand: when there is only one Google Apps domain defined, we will pass the hd param but otherwise do what we do today?

benmanns commented 7 years ago

Yeah, exactly.

Edit: Actually, I'm not familiar with the multi-org login sequence, but if session.get('org_slug') is set on login for an organization we could probably add hd in that case, too, to optimize the sign in experience.

arikfr commented 7 years ago

It's practically the same, the only thing that changes is how you find current org:

https://github.com/getredash/redash/blob/53268989c5fe5c619b399b488094c501cb286af4/redash/authentication/google_oauth.py#L109-L112