Skip to content
This repository was archived by the owner on Sep 15, 2021. It is now read-only.

google/identity-toolkit-ruby-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Google Identity Toolkit Ruby Client

Google Identity Toolkit (Gitkit) ruby client library is for third party sites to easily integrate with Gitkit service.

Installation

gem install identity-toolkit-ruby-client

Examples

require 'gitkit_client'

# Create a server config file or download it from Google Developer Console
# The config file contains Gitkit library config in json format
# {
#   "clientId" : "oauth2-web-client-id.apps.googleusercontent.com",
#   "serviceAccountEmail" : "[email protected]",
#   "serviceAccountPrivateKeyFile" : "path-to-service-account-private-key-file.p12",
#   "widgetUrl" : "full-url-of-gitkit-widget-on-your-site",
#   "cookieName" : "gtoken",
#   "serverKey" : "devconsole-server-key"
# }

# Create a Gitkit client
gitkit_client = GitkitLib::GitkitClient.create_from_config_file 'gitkit-server-config.json'

# Verify the Gitkit token in the incoming http request
token = request.cookies["gtoken"]
user = gitkit_client.verify_gitkit_token token

# Upload passwords
def calc_sha1(key, plain_text, salt)
  hmac = OpenSSL::HMAC.new key, 'sha1'
  hmac << plain_text
  hmac << salt
  hmac.digest
end

hash_key = 'hash-key'

user1 = GitkitLib::GitkitUser.new
user1.email = '[email protected]'
user1.user_id = '1234'
user1.salt = 'salt-1'
user1.password_hash = calc_sha1(hash_key, '1111', 'salt-1')

user2 = GitkitLib::GitkitUser.new
user2.email = '[email protected]'
user2.user_id = '5678'
user2.salt = 'salt-2'
user2.password_hash = calc_sha1(hash_key, '5555', 'salt-2')
user2.name = '56 78'

gitkit_client.upload_users 'HMAC_SHA1', hash_key, [user1, user2]

# Get user by email
user = gitkit_client.get_user_by_email('[email protected]')

# Get user by id
user = gitkit_client.get_user_by_id('5678')

# Delete a user
gitkit_client.delete_user '5678'

# Download all accounts
gitkit_client.get_all_users(2) { |account| pp account}

About

Google Identity Toolkit client library for Ruby

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6

Languages