identity-toolkit-ruby-client

Apache
Ruby
Windows
Google
2015-04-24
大胖森

identity-toolkit-ruby-client 是 Ruby 上的 Google Identity Toolkit 客户端的开发包。

示例:

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" : "service-account-email@developer.gserviceaccount.com",
#   "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 = '1234@example.com'
user1.user_id = '1234'
user1.salt = 'salt-1'
user1.password_hash = calc_sha1(hash_key, '1111', 'salt-1')

user2 = GitkitLib::GitkitUser.new
user2.email = '5678@example.com'
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('1234@example.com')

# 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}


加载中

评论(0)

暂无评论

暂无资讯

暂无问答

.NET库、工具、框架和软件的集合

善于总结,养成良好学习习惯!.NET库、工具、框架和软件的集合

2015/11/21 13:01
336
0
windows下搭建Ruby(基于eclipse的环境)开发环境

windows下搭建Ruby(基于eclipse的环境)开发环境

2015/06/25 00:17
38
0
More On REST

Jon Flanders Contents Which is better, REST or SOAP? What about security? Isn't SOAP more secure than REST? What about transactions? What about interoperability? Isn't SOAP supp...

2011/04/28 23:47
84
0
Defining service endpoints

Defining service endpoints Each of the services in our cloud environment runs on a particular URL and port—these are the endpoint addresses for our services. When a client comm...

2013/08/14 16:21
40
0
.NET Open Source Developer Projects

This community maintained list showcases .NET open source developer projects. It is intended to include projects that are useful for any aspect of the development process. For c...

2015/08/26 18:51
128
0
Window7上安装Ruby on Rails

最近开始学习ruby,安装环境发现要注意的地方不少,籍此记录下

2014/01/23 00:11
439
0
linux Centos 6.5 安装桌面环境GNOME

在某种场合之下,我们使用的Linux还是要选择安装桌面环境的,所以在这里介绍一下如何给没有安装桌面环境的系统安装桌面环境。以Centos 6.5 为例演示一下如何安装桌面环境。

2016/02/03 11:23
64
1
Kerberos - Authentication

The Internet is an insecure place. Many of the protocols used in the Internet do not provide any security. Tools to "sniff" passwords off of the network are in common use by mal...

2012/08/10 14:44
95
0

没有更多内容

加载失败,请刷新页面

返回顶部
顶部