datawire / ambassador-pro

Other
2 stars 0 forks source link

Add Support for Google as an IdP #10

Closed iNoahNothing closed 5 years ago

iNoahNothing commented 5 years ago

We've had a user asking for support for Google as an IdP. After attempting configuration, some changes will need to be made to the code to support the call to google authorization server. Here is an example request format:

https://accounts.google.com/o/oauth2/v2/auth?
 scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&
 access_type=offline&
 include_granted_scopes=true&
 state=state_parameter_passthrough_value&
 redirect_uri=http%3A%2F%2Foauth2.example.com%2Fcallback&
 response_type=code&
 client_id=client_id

Current request when using present configurations:

https://accounts.google.com/authorize?
audience=https://accounts.google.com/o/oauth2/auth&
response_type=code&
redirect_uri=http://domain3.nkrause.k736.net/callback&
client_id=client_id&
scope=offline_access openid profile

(Configuration)

        env:
#         Configure to your callback URL
          - name: AUTH_CALLBACK_URL
            value: http://domain3.nkrause.k736.net/callback
#         Configure to your Auth0 domain
          - name: AUTH_DOMAIN
            value: accounts.google.com
#         Configure to your Auth0 API Audience
          - name: AUTH_AUDIENCE
            value: https://accounts.google.com/o/oauth2/auth
#         Configure to your Auth0 Application client ID
          - name: AUTH_CLIENT_ID
            value: <client-id>
#          Uncomment if you want the Auth0 management API to validate your configurations
          - name: AUTH_CLIENT_SECRET
            value: <client-secret>

The OAuth 2.0 server will respond with the authorization code ex:

https://oauth2.example.com/auth?code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7

Here is a guide for setting [configuring the Google OAuth 2.0 for Web Server Apps].(https://developers.google.com/identity/protocols/OAuth2WebServer)

The OAuth 2.0 client ID I was using is named ambassador-pro-test.