class SimpleGoogleAuth::AuthDataPresenter
Constants
- FIELDS
- InvalidAuthDataError
Public Class Methods
new(auth_data)
click to toggle source
# File lib/simple_google_auth/auth_data_presenter.rb, line 24 def initialize(auth_data) raise InvalidAuthDataError if auth_data["id_token"].nil? token_data = unpack_json_web_token(auth_data["id_token"]) @data = auth_data.merge(token_data) end
Public Instance Methods
[](field)
click to toggle source
# File lib/simple_google_auth/auth_data_presenter.rb, line 31 def [](field) @data[field.to_s] end
Private Instance Methods
unpack_json_web_token(id_token)
click to toggle source
# File lib/simple_google_auth/auth_data_presenter.rb, line 41 def unpack_json_web_token(id_token) # We don't worry about validating the signature because we got this JWT directly # from Google over HTTPS (see # https://developers.google.com/identity/protocols/OpenIDConnect#obtainuserinfo) signature, id_data_64 = id_token.split(".") id_data_64 << "=" until id_data_64.length % 4 == 0 JSON.parse(Base64.decode64(id_data_64)) end