
Product
A New Overview in our Dashboard
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
omniauth-google-id-token
Advanced tools
lib/omniauth/strategies/google_id_token.rb
A omnitauth strategy primarily used for validating Google ID tokens (JWT encoded) generated by Google authentication servers. As with other Omniauth strategies, it can also redirect to Google's Sign In page.
As a validation strategy only this used by backend servers to validate Google ID tokens (Google authenticated users) passed on by mobile or webapps e.g. ios, Android, websites.
This makes use of google-id-token for validating the ID token.
Add this line to your application's Gemfile:
gem 'omniauth-google-id-token'
And then execute:
$ bundle
Or install it yourself as:
$ gem install omniauth-google-id-token
You use OmniAuth::Strategies::GoogleIdToken just like you do any other OmniAuth strategy:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :developer, :callback_path => "/nexus-api/auth/developer/callback", provider_ignores_state: true if Rails.env.development?
# provider :google-oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], scope: 'email, profile', provider_ignores_state: true , :callback_path => "/nexus-api/auth/google-oauth2/callback"
provider :'google-id-token', client_id: ENV['GOOGLE_CLIENT_ID']
# or
# to rename the provider
use OmniAuth::Strategies::GoogleIdToken,name: "google-oauth2", client_id: ENV['GOOGLE_CLIENT_ID']
end
OmniAuth.config.allowed_request_methods = %i[get post]
If this strategy is used primarily for validating a Google ID token, then the only required fields are aud_claim and azp_claim.
If this strategy is also used for redirecting a user to the Google Sign In page before validation, then a client_id is also required. An example of the URL can be found at https://developers.google.com/identity/protocols/OAuth2WebServer#handlingresponse Sample OAuth 2.0 server response section.
google_id_token
but it can be changed to any value, for
example google
. The OmniAuth URL will thus change to /auth/google
and the provider
key in the auth hash will
then return google
.sub
['name', 'email']
['name', 'email', 'openid']
name
and email
to the same in the info hash.When you authenticate through omniauth-google-id-token
you can send users to /auth/google-id-token
and it will redirect them to the URL https://accounts.google.com/o/oauth2/auth (and example can be
found at https://developers.google.com/identity/protocols/OAuth2WebServer#handlingresponse
Sample OAuth 2.0 server response).
From there, Google generates a ID token and sends to the redirect_uri passed in URL query params. The redirect_uri will look like '/auth/google-id-token/callback`. This is the endpoint to send the id token to if coming from a mobile or web app looking to validate a user with the backend server:
/auth/google-id-token/callback?id_token=ENCODEDJWTGOESHERE
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that omniauth-google-id-token demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We redesigned Socket's first logged-in page to display rich and insightful visualizations about your repositories protected against supply chain threats.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.