omniauth-zalo 0.1.2 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 30740d3b00ef67d9af52350a8ae7523b1f5a5431
4
- data.tar.gz: 66443d4bc30f181a326472f72c19d4ff714f883f
2
+ SHA256:
3
+ metadata.gz: 292344ac127119e787f65937437da02b1b78695e0619449e87bddca5af2be89d
4
+ data.tar.gz: b8e4311dd36265f0a86cfaa015f92002ae5e19503493672515e123e63db55dc2
5
5
  SHA512:
6
- metadata.gz: 1200ff766fcf66f85d0c6aefcce9b6dda5632757a929493a699cd8bef99ee7addfbb8bc11b3b6613e83f1f08c8b930e9c0132aa26f90b0ee5325a64cc5b9d348
7
- data.tar.gz: 0c19e9ce61ba54472f224e74b20372859d8c507729bf210ee799a97f4eab754aaad4dcaf3f651ee3575fa3a852021da117e9d330ae60603af65e2f229d01a761
6
+ metadata.gz: a60be850cc6fccb9f2f6d00e53091f971a64e21abbd94af369e121422182f88919abb8b97099e7f8baf3c2c9ad4c796135fdac365db3395076956a477203518d
7
+ data.tar.gz: 964626fc00cfacb419a7baf1f0f9d1355181169ac51cfaa1dde481efb065e543c0f441f8a726d59ccc8d529f2f361fbb1c251c7cc9a3512f226126fe786aea7d
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omniauth-zalo (0.1.1)
5
- omniauth-oauth2 (~> 1.3.1)
4
+ omniauth-zalo (0.1.4)
5
+ omniauth-oauth2 (~> 1.6)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -32,7 +32,7 @@ GEM
32
32
  concurrent-ruby (1.1.5)
33
33
  crass (1.0.4)
34
34
  erubi (1.8.0)
35
- faraday (0.15.4)
35
+ faraday (0.17.1)
36
36
  multipart-post (>= 1.2, < 3)
37
37
  hashie (3.6.0)
38
38
  i18n (1.6.0)
@@ -44,13 +44,13 @@ GEM
44
44
  method_source (0.9.2)
45
45
  mini_portile2 (2.4.0)
46
46
  minitest (5.11.3)
47
- multi_json (1.13.1)
47
+ multi_json (1.14.1)
48
48
  multi_xml (0.6.0)
49
49
  multipart-post (2.1.1)
50
50
  nokogiri (1.10.4)
51
51
  mini_portile2 (~> 2.4.0)
52
- oauth2 (1.4.1)
53
- faraday (>= 0.8, < 0.16.0)
52
+ oauth2 (1.4.2)
53
+ faraday (>= 0.8, < 2.0)
54
54
  jwt (>= 1.0, < 3.0)
55
55
  multi_json (~> 1.3)
56
56
  multi_xml (~> 0.5)
@@ -58,9 +58,9 @@ GEM
58
58
  omniauth (1.9.0)
59
59
  hashie (>= 3.4.6, < 3.7.0)
60
60
  rack (>= 1.6.2, < 3)
61
- omniauth-oauth2 (1.3.1)
62
- oauth2 (~> 1.0)
63
- omniauth (~> 1.2)
61
+ omniauth-oauth2 (1.6.0)
62
+ oauth2 (~> 1.1)
63
+ omniauth (~> 1.9)
64
64
  rack (2.0.7)
65
65
  rack-test (1.1.0)
66
66
  rack (>= 1.0, < 3)
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Omniauth::Zalo
1
+ # OmniAuth::Zalo
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/omniauth/zalo`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ OmniAuth strategy for [Sign In with Zalo](https://developers.zalo.me/).
6
4
 
7
5
  ## Installation
8
6
 
@@ -14,30 +12,27 @@ gem 'omniauth-zalo'
14
12
 
15
13
  And then execute:
16
14
 
17
- $ bundle
15
+ $ bundle install
18
16
 
19
17
  Or install it yourself as:
20
18
 
21
19
  $ gem install omniauth-zalo
22
20
 
23
21
  ## Usage
22
+ omniauth.rb
24
23
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+ ```ruby
25
+ Rails.application.config.middleware.use OmniAuth::Builder do
26
+ provider :zalo, ENV['APP_ID'], env['SERECT_ID']
27
+ end
28
+ ```
30
29
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
30
 
33
31
  ## Contributing
34
32
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omniauth-zalo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nguyenthanhcong101096/omniauth-zalo
36
34
 
37
35
  ## License
38
36
 
39
37
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
38
 
41
- ## Code of Conduct
42
-
43
- Everyone interacting in the Omniauth::Zalo project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/omniauth-zalo/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,46 @@
1
+ module OmniAuth
2
+ module Strategies
3
+ module BuildAccessToken
4
+ def oauth2_access_token
5
+ access_token_response = client.request(access_token_method, access_token_url, headers: access_token_headers, parse: :json).parsed
6
+
7
+ hash = {
8
+ :access_token => access_token_response["access_token"],
9
+ :expires_in => access_token_response["expires_in"],
10
+ }
11
+
12
+ ::OAuth2::AccessToken.from_hash(client, hash)
13
+ end
14
+
15
+ def get_user_info
16
+ @raw_info ||= JSON.load(access_token.get("https://graph.zalo.me/v2.0/me?access_token=#{access_token.token}&fields=id,birthday,name,gender,picture,phone").body)
17
+ rescue ::Errno::ETIMEDOUT
18
+ raise ::Timeout::Error
19
+ end
20
+
21
+ private
22
+
23
+ def access_token_method
24
+ options.client_options.token_method
25
+ end
26
+
27
+ def access_token_headers
28
+ { "secret_key" => options.client_secret }
29
+ end
30
+
31
+ def access_token_url
32
+ client.token_url(access_token_params)
33
+ end
34
+
35
+ def access_token_params
36
+ {}.tap do |params|
37
+ params[:redirect_uri] = callback_url
38
+ params[:app_id] = options.client_id
39
+ params[:code] = request.params['code']
40
+ params[:code_verifier] = options.client_options.code_verifier
41
+ params[:grant_type] = options.client_options.grant_type
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -4,27 +4,41 @@ require 'json'
4
4
  module OmniAuth
5
5
  module Strategies
6
6
  class Zalo < OmniAuth::Strategies::OAuth2
7
+ include BuildAccessToken
8
+
7
9
  option :name, 'zalo'
8
10
 
9
11
  option :client_options, {
10
12
  site: 'https://oauth.zaloapp.com',
11
- authorize_url: '/v3/auth',
12
- token_url: '/v3/access_token',
13
- token_method: :get
13
+ authorize_url: '/v4/permission',
14
+ token_url: '/v4/access_token',
15
+ token_method: :post,
16
+ grant_type: 'authorization_code',
17
+ code_challenge: 'is5SvnFPQzBNP-nb-poEaFlsvK1a6S3NpVCz0vcHh0w',
18
+ code_verifier: 'h57bycdwryntewreomnbSyDrAG4kX7BeqS7g-luzvBE'
14
19
  }
15
20
 
16
- uid { raw_info['userId'] }
21
+ option :provider_ignores_state, true
22
+
23
+ uid { raw_info['id'] }
17
24
 
18
25
  info do
19
26
  {
20
- name: raw_info['displayName'],
21
- image: raw_info['pictureUrl'],
22
- description: raw_info['statusMessage']
27
+ name: raw_info['name'],
28
+ image: raw_info['picture']['data']['url'],
23
29
  }
24
30
  end
25
31
 
26
32
  def authorize_params
27
- super.merge(app_id: self.options.client_id)
33
+ super.merge(app_id: self.options.client_id, code_challenge: options.client_options.code_challenge)
34
+ end
35
+
36
+ def build_access_token
37
+ oauth2_access_token
38
+ end
39
+
40
+ def raw_info
41
+ get_user_info
28
42
  end
29
43
 
30
44
  alias :old_callback_url :callback_url
@@ -36,22 +50,6 @@ module OmniAuth
36
50
  old_callback_url
37
51
  end
38
52
  end
39
-
40
- def callback_path
41
- params = session['omniauth.params']
42
-
43
- if params.nil? || params['callback_url'].nil?
44
- super
45
- else
46
- URI(params['callback_url']).path
47
- end
48
- end
49
-
50
- def raw_info
51
- @raw_info ||= JSON.load(access_token.get('https://graph.zalo.me/v2.0/me').body)
52
- rescue ::Errno::ETIMEDOUT
53
- raise ::Timeout::Error
54
- end
55
53
  end
56
54
  end
57
55
  end
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Zalo
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
data/lib/omniauth/zalo.rb CHANGED
@@ -2,6 +2,7 @@ require 'rails'
2
2
  require 'set'
3
3
  require 'active_support/dependencies'
4
4
  require 'omniauth/zalo/version'
5
+ require 'omniauth/strategies/build_access_token'
5
6
  require 'omniauth/strategies/zalo'
6
7
 
7
8
  module Omniauth
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_development_dependency "bundler", "~> 1.17"
27
27
  spec.add_development_dependency 'web-console', '~> 3.3', '>= 3.3.0'
28
28
  # spec.add_development_dependency "rake", "~> 10.0"
29
- spec.add_dependency 'omniauth-oauth2', '~>1.3.1'
29
+ spec.add_dependency 'omniauth-oauth2', '~>1.6'
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-zalo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - nguyenthanhcong101096
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-12 00:00:00.000000000 Z
11
+ date: 2022-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: 1.3.1
53
+ version: '1.6'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: 1.3.1
60
+ version: '1.6'
61
61
  description: Write a longer description or delete this line.
62
62
  email:
63
63
  - nguyenthanhcong101096@gmail.com
@@ -74,18 +74,16 @@ files:
74
74
  - Rakefile
75
75
  - bin/console
76
76
  - bin/setup
77
+ - lib/omniauth/strategies/build_access_token.rb
77
78
  - lib/omniauth/strategies/zalo.rb
78
79
  - lib/omniauth/zalo.rb
79
- - lib/omniauth/zalo/oauth.rb
80
80
  - lib/omniauth/zalo/version.rb
81
- - omniauth-zalo-0.1.0.gem
82
- - omniauth-zalo-0.1.1.gem
83
81
  - omniauth-zalo.gemspec
84
82
  homepage: https://github.com/nguyenthanhcong101096/omniauth-zalo
85
83
  licenses:
86
84
  - Apache-2.0
87
85
  metadata: {}
88
- post_install_message:
86
+ post_install_message:
89
87
  rdoc_options: []
90
88
  require_paths:
91
89
  - lib
@@ -100,9 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
98
  - !ruby/object:Gem::Version
101
99
  version: '0'
102
100
  requirements: []
103
- rubyforge_project:
104
- rubygems_version: 2.5.2.3
105
- signing_key:
101
+ rubygems_version: 3.1.6
102
+ signing_key:
106
103
  specification_version: 4
107
104
  summary: this is the all module for wakuwaku appkication
108
105
  test_files: []
@@ -1,25 +0,0 @@
1
- # module Omniauth
2
- # class Zalo::Oauth
3
- # attr_reader :app_id, :app_secret, :redirect_uri, :state
4
-
5
- # # client_options = {
6
- # # site: 'https://oauth.zaloapp.com',
7
- # # authorize_url: "/v3/auth?app_id=#{app_id}&redirect_uri=#{redirect_uri}&state=#{state}",
8
- # # access_token_url: "/v3/access_token?app_id=#{app_id}&app_secret=#{app_secret}&code=#{code}",
9
- # # account_info_url: "https://graph.zalo.me/v2.0/me?access_token=#{token}&fields=id,birthday,name,gender,picture,phone"
10
- # # }
11
-
12
- # def initialize(app_id, app_secret, redirect_uri)
13
- # @app_id = app_id
14
- # @app_secret = app_secret
15
- # @redirect_uri = redirect_uri
16
- # @state = state_hex
17
- # end
18
-
19
- # private
20
-
21
- # def state_hex
22
- # SecureRandom.hex
23
- # end
24
- # end
25
- # end
Binary file
Binary file